Chat with AI Agent
const url = 'https://dashboard.quantcdn.io/api/v3/organizations/example/ai/agents/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/chat';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"message":"example","sessionId":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","userId":"example","stream":false,"async":false,"system":"example","longContext":false,"maxToolIterations":1,"allowedCollections":["example"]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://dashboard.quantcdn.io/api/v3/organizations/example/ai/agents/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/chat \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "message": "example", "sessionId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "userId": "example", "stream": false, "async": false, "system": "example", "longContext": false, "maxToolIterations": 1, "allowedCollections": [ "example" ] }'Initiates a chat session with a specific AI agent. The agent’s configuration (system prompt, temperature, model, allowed tools) is automatically applied.
*
* Key Features:
* - Session Management: Automatic session creation and state tracking
* - Multi-turn Conversations: Full conversation history maintained server-side
* - Agent’s system prompt is prepended to conversation
* - Only agent’s allowed tools are available
* - All tools are auto-executed on cloud (no client confirmation needed)
* - Temperature and model from agent config
* - Supports sync, streaming, and async modes
*
* Execution Modes:
* - Sync Mode (default): Standard JSON response, waits for completion
* - Streaming Mode: Set stream: true for SSE token-by-token responses
* - Async Mode: Set async: true for long-running tasks with polling
*
* Async/Durable Mode (async: true):
* - Returns immediately with requestId and pollUrl (HTTP 202)
* - Uses AWS Lambda Durable Functions for long-running agent tasks
* - All tools are auto-executed on cloud (no waiting_callback state)
* - Poll /ai/chat/executions/{requestId} for status
* - Ideal for agents with slow tools (image generation, web search, etc.)
*
* Session Support:
* - Omit sessionId to create a new session automatically
* - Include sessionId to continue an existing conversation
* - Sessions expire after 60 minutes of inactivity
* - Sessions work in all modes (sync, streaming, async)
* - Use /sessions/{sessionId} to retrieve full conversation history
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The organisation ID
The agent ID
Request Bodyrequired
Section titled “Request Bodyrequired”object
The user’s message to the agent
Optional session ID to continue a conversation
Optional user identifier for session isolation
Whether to stream the response (SSE)
Enable async/durable execution mode. When true, returns 202 with pollUrl. Use for long-running agent tasks.
Optional additional system prompt (appended to agent’s configured prompt)
Per-request override to force 1M context window routing
Maximum tool auto-execution iterations for this request
Per-request override for vector DB collections the agent can query
Responses
Section titled “Responses”Agent response generated successfully (sync mode)
object
object
object
Cost of this inference call in US cents
object
Examplegenerated
{ "sessionId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "response": { "text": "example", "stopReason": "example", "usage": { "inputTokens": 1, "outputTokens": 1, "totalTokens": 1, "costCents": 1 }, "toolResults": [ {} ] }}Async execution started (when async: true in request)
object
Unique request identifier for polling
The agent processing the request
Human-readable agent name
Session ID (if provided)
Initial status
URL to poll for execution status
Example
{ "requestId": "90fe0c53-a41b-4b28-b19e-5e900b3df959", "agentName": "Weather Assistant", "status": "queued", "message": "Agent execution started. Poll the status endpoint for updates.", "pollUrl": "/ai/chat/executions/90fe0c53-a41b-4b28-b19e-5e900b3df959"}Invalid request parameters
Access denied
Agent not found
Failed to chat with agent
