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
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.