ai:chat scope.
Request
Body parameters
Non-streaming response
Whenstream: false:
Streaming response (SSE)
Whenstream: true (default), the response is a standard text/event-stream. Each event follows this envelope:
event: line naming the type and a data: line carrying a flat JSON payload. There is no envelope object and no id: line — the payload fields listed below are at the top level of data.
Event sequence
A successful run emits:run.started— inference initiatedmessage.delta(repeated) — content chunks as they arrivetool_call/provider_tool.completed(as they occur) — tool activity during the turnrun.completed— run finished, with final usage and credits
heartbeat may be interleaved at any point to keep the connection alive. On failure, error is emitted instead of run.completed.
Event types
run.started
message.delta
tool_call
provider_tool.completed
heartbeat
run.completed
finish_reason is the normalized reason; stop_reason_raw is the provider-native value, which is finer-grained (finish_reason collapses end-of-turn and stop-sequence together).
Error events
There is norun.failed event. A failure mid-stream emits error and the stream ends:
Consuming the stream (JavaScript)
event: line, not on a field inside data — the payload has no type field.
Cancellation
Close the SSE connection to cancel. The server detects the disconnect and halts the upstream call. No additional API call is needed, and no further events are emitted.Models
The endpoint serves both Anthropic and OpenAI models.
Premium (opt-in) models must be enabled by an org admin in Settings → AI Workspace → Models before requests using them are accepted. Requests for a model your org has not enabled return
403 MODEL_ACCESS_DENIED.