Send Message

Send a message to an agent and receive a response.

POST/chat

Send a message to an agent. Returns the agent's complete response.

No parameters for this endpoint.


Request Body

FieldTypeRequiredDefaultDescription
agent_idstringYesTarget agent ID (ag_*)
messagestringYesUser message text
session_idstringNoAuto-generatedSession ID for conversation memory. Reuse to continue a conversation
streambooleanNofalseEnable streaming response (use Stream endpoint instead)
metadataobjectNonullAdditional context passed to the agent (e.g., user info, page URL)

Response 200

{
  "response": "Our business hours are Monday through Friday, 9 AM to 6 PM EST. We're also available on Saturdays from 10 AM to 2 PM.",
  "session_id": "sess_customer_001",
  "usage": {
    "input_tokens": 45,
    "output_tokens": 32,
    "total_tokens": 77
  },
  "tool_calls": []
}

Response Fields

FieldTypeDescription
responsestringAgent's text response
session_idstringSession ID — reuse for follow-up messages
usage.input_tokensintegerTokens consumed by the prompt
usage.output_tokensintegerTokens in the agent's response
usage.total_tokensintegerTotal tokens consumed (billed)
tool_callsarrayTools the agent invoked during this response

Example with Metadata

{
  "agent_id": "ag_c47e7c97_b2f2",
  "message": "I need help with my order",
  "session_id": "sess_customer_001",
  "metadata": {
    "user_name": "Jane Doe",
    "user_email": "jane@example.com",
    "page_url": "https://store.example.com/orders/12345"
  }
}

Errors

CodeDescription
401Missing or invalid authentication
402Insufficient balance
404Agent not found
429Rate limit exceeded

On this page