> For the complete documentation index, see [llms.txt](https://docs.rigoblock.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rigoblock.com/agent.md).

# Agent

AI-powered DeFi agent interface — natural language to calldata

## AI-powered DeFi agent chat

> Natural language DeFi interface. Send a message describing a trading intent and receive unsigned swap calldata, position summaries, bridge transactions, or market analysis. The agent internally uses Kimi K2.7 Code for reasoning and tool calling.\
> \
> \*\*Price:\*\* up to $0.10 USDC per request (x402 \`upto\` scheme, eip155:8453) — billed by actual inference cost, typical $0.003–$0.015\
> \
> \*\*Supported operations (one per request):\*\*\
> \- Swap tokens via Uniswap v4 or 0x aggregator\
> \- Bridge tokens cross-chain via Across Protocol\
> \- Add/remove Uniswap v4 LP positions\
> \- Open/close GMX perpetual positions\
> \- Stake/unstake GRG governance tokens\
> \- Deploy and fund Rigoblock smart pool vaults\
> \- Query vault NAV, token balances, active positions\
> \- Create/manage automated trading strategies\
> \- Schedule TWAP orders (time-weighted average price execution)\
> \
> \*\*Execution modes:\*\*\
> \- manual (default): Returns unsigned calldata — operator signs and broadcasts\
> \- delegated: Agent wallet executes on-chain directly (requires operator auth + on-chain delegation)\
> \
> \*\*Safety:\*\* Every transaction passes NAV shield (≤10% loss), Swap Shield (oracle price check), 7-point execution validation, and on-chain selector whitelist.

```json
{"openapi":"3.1.0","info":{"title":"Rigoblock","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` and, for protected routes, a `PAYMENT-REQUIRED` header describing accepted payment requirements\n2. Create the x402 payment payload for USDC on Base (chain 8453), typically via `@x402/core` and the CDP facilitator at `api.cdp.coinbase.com`\n3. Retry the request with this header set to the encoded payment payload\n\nSuccessful 2xx responses may include a `PAYMENT-RESPONSE` settlement receipt. See 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"}},"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":"Reasoning trace from the model, when available."},"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. Send a message describing a trading intent and receive unsigned swap calldata, position summaries, bridge transactions, or market analysis. The agent internally uses Kimi K2.7 Code for reasoning and tool calling.\n\n**Price:** up to $0.10 USDC per request (x402 `upto` scheme, eip155:8453) — billed by actual inference cost, typical $0.003–$0.015\n\n**Supported operations (one per request):**\n- Swap tokens via Uniswap v4 or 0x aggregator\n- Bridge tokens cross-chain via Across Protocol\n- Add/remove Uniswap v4 LP positions\n- Open/close GMX perpetual positions\n- Stake/unstake GRG governance tokens\n- Deploy and fund Rigoblock smart pool vaults\n- Query vault NAV, token balances, active positions\n- Create/manage automated trading strategies\n- Schedule TWAP orders (time-weighted average price execution)\n\n**Execution modes:**\n- manual (default): Returns unsigned calldata — operator signs and broadcasts\n- delegated: Agent wallet executes on-chain directly (requires operator auth + on-chain delegation)\n\n**Safety:** Every transaction passes NAV shield (≤10% loss), Swap Shield (oracle price check), 7-point execution validation, and on-chain selector whitelist.","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"}}}}}}}}}
```
