API Reference
All endpoints are on the AgentX Cloudflare Worker. Base URL: https://agentx-worker.davirain-yin.workers.dev
All endpoints return JSON. CORS is open (*).
Health
/healthReturns worker health, version, and X Layer RPC gateway URL.
Response
{ "status": "ok", "version": "0.1.0", "gateway": "https://xlayertestrpc.okx.com" }Agents
/api/agentsReturns live agent wallet addresses, fees, and capabilities. Derived from NODE_PRIVATE_KEY via agent-sdk.
Response
{
"orchestrator": { "address": "0x...", "fee": "0.002 USDC", "capabilities": ["a2a_payment", "hire_agent", ...] },
"price-oracle": { "address": "0x...", "fee": "0.001 USDC", "capabilities": ["fetch_price", ...] },
"trade-strategy": { "address": "0x...", "fee": "0.005 USDC", "capabilities": ["analyze_strategy", ...] }
}A2A Workflow
/api/a2aStart a durable A2A payment workflow. Caller must have approved USDC for the orchestrator address first. Returns a jobId for polling.
Request body
{
"symbol": "ETH", // token to analyze
"budget": 1.0, // USDC budget (number)
"callerAddress": "0x...", // user wallet (must have approved USDC)
"type": "price_only", // "price_only" | "price_alert" | "auto_trade"
"threshold": 0, // price threshold (0 = always proceed)
"riskLevel": "medium" // "low" | "medium" | "high"
}Response
{ "jobId": "abc123", "status": "running" }/api/a2a/:jobIdPoll workflow status. Returns the full result once completed, including all A2A payment records.
Response
{
"status": "completed",
"symbol": "ETH",
"currentPrice": 2167.42,
"priceSource": "binance",
"action": "BUY",
"totalSpent": "0.0060",
"refunded": "0.994",
"payments": [
{ "step": "User → Orchestrator: budget deposit", "txHash": "0x...", "amount": "1.0 USDC" },
{ "step": "Orchestrator → PriceOracleAgent: A2A payment","txHash": "0x...", "amount": "0.001 USDC" },
{ "step": "Orchestrator → TradeStrategyAgent: A2A payment","txHash": "0x...","amount": "0.005 USDC"},
{ "step": "Orchestrator → User: refund unspent budget", "txHash": "0x...", "amount": "0.994 USDC" }
]
}/api/a2a/simulateRun workflow in simulation mode — no real USDC transfers. Useful for demos and testing.
Request body
{ "symbol": "ETH", "budget": 1.0, "type": "price_only", "threshold": 0 }Response
{
"status": "simulated",
"symbol": "ETH",
"currentPrice": 2167.42,
"action": "BUY",
"simulatedPayments": [
{ "step": "User → Orchestrator", "amount": "1.0" },
{ "step": "Orchestrator → PriceOracleAgent", "amount": "0.001" }
]
}Agent Sessions (AI Chat)
/api/deployProvision a new AI agent session backed by a Cloudflare Durable Object. Returns a sessionId.
Request body
{ "template": "orchestrator", "config": { "name": "My Agent" } }Response
{ "agentId": "uuid", "sessionId": "uuid", "status": "ready" }/agent/chat/:sessionIdSend a message to an agent session. Returns the AI response (Llama-3.3-70B via Workers AI).
Request body
{ "message": "What is the current ETH price?" }Response
{ "reply": "The current ETH price is $2,167.42 (Binance, 30s ago)." }/agent/history/:sessionIdReturns the message history for an agent session.
Response
{ "messages": [{ "role": "user", "content": "..." }, { "role": "assistant", "content": "..." }] }Tasks (Human-in-the-loop)
/tasks/:taskId/confirmConfirm a pending human-approval step for a workflow task.
Request body
{ "approved": true }Response
{ "status": "confirmed", "taskId": "123" }