Chat & Streaming

Send messages to an agent via REST or SSE and understand the event stream.

Synchronous chat

POST/api/chatX-Agent-Access-Token

Single JSON response after the full turn completes (LLM + tool calls).

curl -X POST http://127.0.0.1:8000/api/chat \
  -H "Content-Type: application/json" \
  -H "X-Agent-Access-Token: pa_..." \
  -d '{
    "agent_id": "agent-uuid",
    "message": "Compare gas on Arbitrum vs Base",
    "conversation_id": null
  }'

SSE streaming (recommended)

POST/api/chat/streamX-Agent-Access-Token

Server-Sent Events stream with token deltas, tool calls, and final message.

Event sequence:

  • start — turn began
  • text_delta — incremental assistant text
  • tool_calls_start / tool_call / tool_result — tool execution
  • final — completed message with chain_calls metadata
  • error — failure before close

Keepalive SSE comments (: keepalive) flush every ~15s during long tool gathers so proxies do not drop the connection.

Conversations

  • GET /api/conversations?agent_id=... — list threads
  • GET /api/conversations/{id}/messages — history
  • DELETE /api/conversations/{id} — remove thread
  • GET /api/conversations/{id}/stream — live tx confirmations

Request body fields

  • agent_id (required)
  • message (required)
  • conversation_id (optional — omit to start new)
  • connected_wallet_address (optional — user wallet context)