v51

latestOpenAPI 3.1.0raw.githubusercontent.com2026-08-01302395850.8 KB
v2
chat
chat

Stream Chat Post

Start a new turn and return an AI SDK UI message stream.

Returns an SSE stream (text/event-stream) with Vercel AI SDK chunks (text fragments, tool-call UI, tool results). The generation runs in a background task that survives client disconnects; reconnect via GET /sessions/{session_id}/stream to resume.

Follow-up messages typed while a turn is already running should use POST /sessions/{session_id}/messages/pending. If an older client still posts that follow-up here, we queue it defensively but still return a valid empty UI-message stream so AI SDK transports never receive a JSON body from the stream endpoint.

Args: session_id: The chat session identifier. request: Request body with message, is_user_message, and optional context. user_id: Authenticated user ID.

post/api/chat/sessions/{session_id}/stream

Path parameters

session_idstring required

Request body

messagestring required
is_user_messageboolean
contextobject nullable
file_idsstring[] nullable
mode'fast' | 'extended_thinking' nullable

Autopilot mode: 'fast' for baseline LLM, 'extended_thinking' for Claude Agent SDK. If None, uses the server default (extended_thinking).

model'standard' | 'advanced' nullable

Model tier: 'standard' for the default model, 'advanced' for the highest-capability model. If None, the server applies per-user LD targeting then falls back to config.

message_idstring nullable

Optional per-click UUID generated by the frontend. Becomes the persisted ChatMessage.id (PK). Frontend / network / RMQ-redelivery retransmits of the same logical send reuse the id, so the Postgres unique-constraint on the PK is the atomic dedup primitive: a duplicate INSERT returns a subscribe-only response without creating a parallel turn. Distinct user clicks (even with identical text) MUST send different ids — the frontend's per-click crypto.randomUUID() guarantees that.

Response

Successful Response

{"stackTrail":"paths:/api/chat/sessions/{session_id}/stream:post:responses:200:content:application/json:schema","oasType":"schema","type":"unknown"}