Create a run and stream events via SSE
Starts a new agent chat run (or resumes an existing one using the Idempotency-Key header) and streams run events back to the caller as Server-Sent Events.
Each SSE frame carries a JSON-encoded RunEvent. Control events: done, error, cancelled, notice, heartbeat. Streaming events include token (LLM text chunks), tool_start, tool_end, and runtime-specific progress frames.
Send Accept: application/json to use the polling transport instead: the response is 201 {runId, status} and events are drained via GET /agent/runs/{runId}/events.
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Headers
Client-generated idempotency key (UUID recommended). A retry with the same key + same body resumes the existing SSE stream. Same key + different body returns a 409 error event.
Body
The user message to send to the agent.
Client-generated session identifier for conversation continuity.
Organization ID the run belongs to. Must match the authenticated principal's org.
File thread ID for document-scoped conversations.
Action type. Only "chat" is accepted on this endpoint.
chat Optional client-supplied run ID. Idempotency-Key header takes precedence.
Response
SSE stream of run events. Each event line is a JSON-encoded RunEvent. The stream ends with a done, error, or cancelled control event.
W3C Server-Sent Events stream. Each frame: id: \n data: \n\n
RunEvent discriminated union: {type:"token", content:string} — LLM text chunk {type:"done", runId:string, threadId?:string} — terminal success {type:"error", error:string} — terminal failure {type:"cancelled", runIds:string[], timestamp:number} — terminal cancel {type:"notice", message:string, severity:"info"|"warning"} — non-terminal warning {type:"heartbeat", timestamp?:number} — keepalive {type:"tool_start"|"tool_end"|string, ...} — runtime streaming frames