Skip to main content

Streaming

A flow run can return its result as a single JSON response, or stream as the run progresses — one event per node, ending with the final result. Streaming is how you build live token output or a progressive trace UI.

Turning it on

Set "stream": true in the body, or send Accept: text/event-stream:

curl -N -X POST https://api.zerowidth.ai/1.0/flows/<flowUuid>/runs \
  -H "Authorization: Bearer zw_live_…" \
  -H "Content-Type: application/json" \
  -d '{"input":{"kind":"chat","messages":[{"role":"user","content":"hi"}]},"stream":true}'

The response is text/event-stream. Each event is one node lifecycle step; a terminal event carries the same payload the non-streaming response would have returned, followed by a done sentinel.

Event types

eventWhenKey fields
node_startA node is about to runnodeId, nodeType
node_completeA node finishednodeId, outputs, durationMs
node_updateProgress mid-node — typically token deltas from a modelnodeId, data
node_errorA node failednodeId, errorMessage
run_completeTerminal success / partialexecutionId, status, outputs, costSummary, timeline, durationMs
run_errorTerminal failureexecutionId, error
doneSentinel — the stream is closed

A streaming response always carries the full per-node timeline in its terminal event, so the verbose flag is ignored when streaming.

The full request and response shape lives on the run-a-flow reference.

2 min read