chat

Chat Completion

Handle POST /api/chat SSE streaming chat completion.

Authenticates via require_http_identity (HTTPBearer → NormalizedIdentity), builds a ChatExecutionContext from the request and identity, calls stream_turn(), and projects via project_sse() over an EventSourceResponse.

Cancellation is driven by request.is_disconnected() flipping cancel_flag["cancelled"]; the runtime's cancel_check polls the same flag.

post/api/chat

Request body

session_idstring nullable

Optional session identifier for restoring an existing session.

execution_mode'auto' | 'rlm_only' | 'tools_only' nullable

Per-turn execution mode hint. Accepts legacy values (auto/rlm_only/tools_only).

repo_urlstring nullable

Repository URL to attach to runs.

repo_refstring nullable

Optional branch, tag, or commit to checkout.

context_pathsstring[] nullable

Optional repository paths to prioritize as context.

batch_concurrencyinteger nullable

Optional concurrency hint for batched repository work.

docs_pathstring nullable

Optional local documentation path to preload before execution.

traceboolean nullable

Whether trace-oriented streaming events should be emitted.

trace_modestring nullable

Optional trace verbosity override.

selected_skill_idsstring[] nullable

Optional list of skill IDs to select for this turn.

attachment_refsstring[] nullable

Optional list of attachment IDs from a prior upload for this session.

Response

SSE streaming response. Returns a Server-Sent Events stream with Content-Type: text/event-stream and x-vercel-ai-ui-message-stream: v1 header.

Changes