Sazabi
API

Streaming

Stream Sazabi agent run and thread events over Server-Sent Events.

Sazabi streams agent run and thread events over Server-Sent Events (SSE). Use streaming to render an agent's output as it is produced instead of polling for the final result.

Endpoints

Two GET endpoints return a text/event-stream response:

EndpointStreams
GET /v1/runs/{runId}/streamEvents for a single agent run.
GET /v1/threads/{threadId}/streamEvents for a thread's active run.

Both use the same authentication as the rest of the API — a secret key in the Authorization header — and enforce the same visibility as the corresponding GET endpoints for the run or thread.

Consuming the stream

curl -N https://api.sazabi.com/v1/runs/$RUN_ID/stream \
  -H "Authorization: Bearer $SAZABI_SECRET_KEY"

Each SSE frame carries one JSON event with a type field. Event types include run_started, message_started, text_chunk, reasoning_chunk, text_complete, tool_call_start, tool_call_complete, artifact, and error. Handle unknown type values by ignoring them so new event types do not break your client.

The stream ends with a [DONE] sentinel frame. When you have it, close the connection.

Resuming after a disconnect

If the connection drops, reconnect to the same endpoint with a cursor query parameter set to the position you last processed to resume without replaying the whole stream:

curl -N "https://api.sazabi.com/v1/runs/$RUN_ID/stream?cursor=$LAST_CURSOR" \
  -H "Authorization: Bearer $SAZABI_SECRET_KEY"