Chat with AI Agent
POST /api/v3/organizations/{organisation}/ai/agents/{agentId}/chat
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
Parameters
Path Parameters
The organisation ID
The agent ID
Request Body required
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)
Responses
200
Agent response generated successfully (sync mode)
object
object
object
object
202
Async execution started (when async: true in request)
object
Unique request identifier for polling
90fe0c53-a41b-4b28-b19e-5e900b3df959The agent processing the request
Human-readable agent name
Weather AssistantSession ID (if provided)
Initial status
queuedAgent execution started. Poll the status endpoint for updates.URL to poll for execution status
/ai/chat/executions/90fe0c53-a41b-4b28-b19e-5e900b3df959400
Invalid request parameters
403
Access denied
404
Agent not found
500
Failed to chat with agent