Overview
Send a message to the chat agent and receive a real-time streamed response. The response uses Server-Sent Events (SSE) to stream text incrementally as the LLM generates it. Authentication:Authorization: Bearer {session_token}
Content-Type: text/event-stream
Request
Path Parameters:| Parameter | Type | Required | Description |
|---|---|---|---|
conversation_id | string | ✅ | Session ID from create session response |
Request Fields
| Field | Type | Required | Validation |
|---|---|---|---|
message | string | ✅ | 1-10,000 characters |
Response
Status:200 OK
Content-Type: text/event-stream
Format: SSE stream with event types
SSE Event Format
Each event consists of:\n\n).
Event Types
stream_start
Fired when agent starts generating response.chunk
Fired for each text delta.tool_call
Fired when agent calls a function/tool.tool_result
Fired when tool completes.handoff
Fired during multi-agent handoff.stream_end
Fired when response complete.- Clear loading state
- Check
end_sessionflag - If
true, call/endendpoint
error
Fired on error.Parsing SSE Stream
JavaScript Example
React Hook Example
Session Lock
The API automatically acquires a session lock when processing messages:- Prevents concurrent message processing
- Ensures message order
- Prevents race conditions
Conversation History
The API maintains conversation history internally:- Last 40 items (20 exchanges) sent to LLM
- Prevents unbounded growth
- Automatic capping
Token Tracking
Automatic tracking of:- Input tokens (user messages)
- Output tokens (assistant responses)
- Total usage per session
stream_end event’s usage field.
Error Responses
400 Bad Request
401 Unauthorized
403 Forbidden
404 Not Found
Best Practices
1. Show Loading State
2. Handle All Event Types
3. Check end_session Flag
4. Handle Disconnections
5. Use keepalive for /end
Related Endpoints
- Create Session — Start new session
- Get History — Retrieve messages
- End Session — End and cleanup
Next Steps
End Session
Always end sessions explicitly to trigger cleanup.
Get History
Retrieve message history for resuming conversations.