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
event | When | Key fields |
|---|---|---|
node_start | A node is about to run | nodeId, nodeType |
node_complete | A node finished | nodeId, outputs, durationMs |
node_update | Progress mid-node — typically token deltas from a model | nodeId, data |
node_error | A node failed | nodeId, errorMessage |
run_complete | Terminal success / partial | executionId, status, outputs, costSummary, timeline, durationMs |
run_error | Terminal failure | executionId, error |
done | Sentinel — 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