# Agent

AI-powered DeFi agent interface — natural language to calldata

## AI-powered DeFi agent chat

> Natural language DeFi interface for autonomous agents. Send a message describing a trading intent and receive swap calldata, position summaries, or market analysis — ready for on-chain execution.\
> \
> \*\*Price:\*\* $0.01 USDC per request (paid via x402)

```json
{"openapi":"3.1.0","info":{"title":"RigoBlock Agent Trader API","version":"1.0.0"},"tags":[{"name":"Agent","description":"AI-powered DeFi agent interface — natural language to calldata"}],"servers":[{"url":"https://trader.rigoblock.com","description":"Production"}],"security":[{"x402":[]}],"components":{"securitySchemes":{"x402":{"type":"apiKey","in":"header","name":"X-Payment","description":"x402 payment header. Flow:\n1. Make the request without this header → receive `402 Payment Required`\n2. Submit USDC payment on Base (chain 8453) via `api.cdp.coinbase.com`\n3. Retry the request with this header set to the payment receipt\n\nSee https://github.com/rigoblock/agentic-operator/blob/main/AGENTS.md for full integration."}},"schemas":{"ChatRequest":{"type":"object","required":["messages"],"properties":{"messages":{"type":"array","description":"Conversation history in OpenAI message format","items":{"type":"object","required":["role","content"],"properties":{"role":{"type":"string","enum":["user","assistant","system"]},"content":{"type":"string"}}}},"vaultAddress":{"type":"string","description":"RigoBlock vault (smart pool) address for vault-scoped operations"},"contextDocs":{"type":"array","description":"Optional request-scoped context snippets (for example markdown excerpts) injected into the model prompt for this request.","items":{"type":"string"}},"routingMode":{"type":"string","description":"Workers AI orchestration mode.","enum":["deepseek_only","hybrid_fast_followup"],"default":"deepseek_only"},"chain":{"type":"string","description":"Target chain context","default":"base","enum":["base","arbitrum","ethereum","optimism","polygon","bsc","unichain"]}}},"ChatResponse":{"type":"object","properties":{"message":{"type":"string","description":"AI-generated response text"},"reasoning":{"type":"string","description":"DeepSeek R1 reasoning trace (contents of <think> block). Only present when using Workers AI DeepSeek model."},"modelsUsed":{"type":"array","description":"Ordered list of model identifiers that contributed to this output.","items":{"type":"string"}},"finalModel":{"type":"string","description":"Model that authored the final natural-language output (or 'tooling' when output is tool-native)."},"action":{"type":"object","description":"Executable on-chain action, if applicable","properties":{"type":{"type":"string","enum":["swap","position","analysis"],"description":"Action type"},"to":{"type":"string","description":"Contract address"},"calldata":{"type":"string","description":"Encoded transaction calldata"},"value":{"type":"string","description":"ETH value to attach"},"gasEstimate":{"type":"string","description":"Estimated gas"}}}}},"ErrorResponse":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"}}},"X402PaymentRequired":{"type":"object","description":"Standard x402 payment challenge","properties":{"x402Version":{"type":"integer"},"error":{"type":"string"},"accepts":{"type":"array","items":{"type":"object","properties":{"scheme":{"type":"string"},"network":{"type":"string"},"maxAmountRequired":{"type":"string"},"resource":{"type":"string"},"description":{"type":"string"},"mimeType":{"type":"string"},"payTo":{"type":"string","description":"USDC recipient address on Base"},"maxTimeoutSeconds":{"type":"integer"},"asset":{"type":"string","description":"USDC contract address on Base"},"extra":{"type":"object","properties":{"name":{"type":"string"},"version":{"type":"string"}}}}}}}}}},"paths":{"/api/chat":{"post":{"operationId":"agentChat","summary":"AI-powered DeFi agent chat","description":"Natural language DeFi interface for autonomous agents. Send a message describing a trading intent and receive swap calldata, position summaries, or market analysis — ready for on-chain execution.\n\n**Price:** $0.01 USDC per request (paid via x402)","tags":["Agent"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatRequest"}}}},"responses":{"200":{"description":"AI response with DeFi action or analysis","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatResponse"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"402":{"description":"Payment required (x402). Pay in USDC on Base and retry with `X-Payment` header.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/X402PaymentRequired"}}}}}}}}}
```
