Skip to content

Streaming ​

Streaming exposes model or agent progress before the complete response is available.

Explore streaming ​

PageLearn how to
Completion streamsConsume normalized events from one model call.
Agent streamsFollow turns, tools, text, usage, and final output.
Event typesUnderstand completion and agent event contracts.
Server transportReturn JSONL or SSE from an HTTP route safely.
Errors and cancellationMap failures and stop unnecessary work.
Resumable streamsRecover after navigation or connection loss.

Choose the stream level ​

StreamUse when
Completion streamThe application needs provider-neutral deltas from one direct model call.
Agent streamThe application needs the full runtime loop, including turns, tools, nested agents, usage, and a final result.

Direct completion streams do not execute local tools. Agent streams expose the runtime while it executes them.

Treat streams as workflow state ​

Text is only one part of an agent stream. Product surfaces should also decide what tool progress, final usage, cancellation, and errors mean. Keep raw reasoning, tool arguments, tool results, and provider metadata off user-facing transports unless explicitly reviewed.

Built for Anvia.