Skip to main content
You need an agent id and a key with the full permission (see Get your API key). All examples read them from three environment variables:

Send a message

POST /v1/agents/{agent_id}/chat sends one user message and waits for the reply. Two headers matter besides Content-Type:
  • Authorization: Bearer <key>
  • Idempotency-Key: any unique value of 1-255 characters per logical request. A UUID is a good choice. It is required on both chat endpoints; see Idempotency.

Read the reply

  • request_id is also returned as the X-Request-ID header.
  • conversation_id is the conversation the exchange was stored in. Send another message with the same external_user_id and it continues there.
  • usage.charged_usd is a decimal string with 8 places: what this request cost the owner’s balance.
The reply can take a while when the agent uses tools or a large knowledge base. Give the request a generous timeout (the examples use 120 seconds) or use the streaming endpoint to show text as it is produced.

Continue the conversation

Send a second message with the same external_user_id and a new Idempotency-Key:
The agent sees the earlier exchange as history. Sending a message for an external user whose previous reply is still being produced returns 409 conversation_busy with a Retry-After header; wait and retry.

Next steps

Streaming

Show the answer as it is generated.

Conversations

List conversations and page through messages.

Errors

Every code the API can return and what to do about it.

API reference

Full request and response schemas, with a playground.