Skip to content

Chat API

The Chat API manages conversations and message streaming. All endpoints are mounted under /api/chat (e.g., /api/chat/conversations).

MethodPathDescription
GET/api/chat/conversationsList conversations
POST/api/chat/conversationsCreate a conversation
GET/api/chat/conversations/{id}Get a conversation
PUT/api/chat/conversations/{id}Update a conversation
DELETE/api/chat/conversations/{id}Delete a conversation
GET/api/chat/conversations/{id}/modeGet conversation mode
PATCH/api/chat/conversations/{id}/modeSet conversation mode
GET/api/chat/conversations/{id}/execution-modeGet execution mode
PUT/api/chat/conversations/{id}/execution-modeSet execution mode
POST/api/chat/conversations/{id}/approval-responseSubmit approval response
POST/api/chat/messages/streamSend a message (streaming SSE)
POST/api/chat/messages/injectInject a message into a conversation
POST/api/chat/messages/truncateTruncate messages
POST/api/chat/welcomeGenerate a welcome message
GET/api/chat/sessions/{session_id}/streamRemote session SSE stream

GET /api/chat/conversations

Returns all conversations.


POST /api/chat/conversations

Creates a new conversation.


GET /api/chat/conversations/{id}

Returns a single conversation by ID.


PUT /api/chat/conversations/{id}

Updates a conversation (e.g., title).


DELETE /api/chat/conversations/{id}

Permanently deletes a conversation and its messages.


POST /api/chat/messages/stream

Sends a message and returns the response as a stream of Server-Sent Events (SSE). The connection stays open until the full response is delivered.

Each event in the stream uses standard SSE format. The following event types are emitted:

event: token
data: {"content": "def reverse_linked_list"}
event: tool_use
data: {"tool": "write_file", "input": {"path": "solution.py"}}
event: tool_result
data: {"tool": "write_file", "output": {"success": true}}
event: done
data: {"message_id": "msg_01j9abc123", "input_tokens": 120, "output_tokens": 245, "total_tokens": 365}
event: error
data: {"code": "rate_limit", "message": "Provider rate limit reached. Retry in 30s."}

POST /api/chat/messages/inject

Injects a message into a conversation without triggering an agent response. Useful for programmatically adding context or instructions.


POST /api/chat/messages/truncate

Truncates messages in a conversation.


POST /api/chat/welcome

Generates a welcome message for a new conversation.


GET /api/chat/conversations/{id}/mode
PATCH /api/chat/conversations/{id}/mode

Get or set the conversation mode for a specific conversation.


GET /api/chat/conversations/{id}/execution-mode
PUT /api/chat/conversations/{id}/execution-mode

Get or set the execution mode (e.g., autonomous vs. approval-required) for a conversation.


POST /api/chat/conversations/{id}/approval-response

Submit an approval or rejection for a pending action within a conversation.