Streaming responses
For engineers
How server-sent event streams deliver tokens, how to assemble deltas, cancel cleanly and survive proxies and mid-stream errors
110 questions across four stages: Understand, Apply, Solve and Judge.
Try 5 questions
Practice items, not counted towards your mastery. No account needed.
Check yourself · 1 of 5
In a server-sent event stream, what ends one event?
Check yourself · 2 of 5
When can your server safely call JSON.parse on a streamed tool call's arguments?
Check yourself · 3 of 5
A user clicks Stop. Which chain stops the model generating?
Check yourself · 4 of 5
A streamed chat works on localhost but in production the whole answer appears at once. What is the most likely cause?
Check yourself · 5 of 5
In a Claude message stream, which event carries the stop reason and the final token usage?
Topics
- How server-sent event streams work5 min read · The event sequence of a streamed model response, from message start through text deltas to the final usage event
- Accumulating text and tool-call deltas5 min read · Assembling streamed text and partial tool-call JSON on the server before forwarding or parsing it
- Cancelling a stream cleanly mid-response5 min read · Propagating a user's stop from the browser through your server to the provider so generation and billing stop
- Proxy buffering and dropped-stream pitfalls5 min read · Buffering proxies, compression, idle timeouts and errors that arrive after a 200 status in the middle of a stream
Start here
- Streaming messages (Claude) (opens in a new tab)DocsFree
The full event sequence, delta types, partial tool JSON and mid-stream error behaviour of a Claude stream.
- Streaming API responses (OpenAI) (opens in a new tab)DocsFree
How another vendor names and orders its stream events, useful for comparing event shapes.
- Using server-sent events (MDN) (opens in a new tab)DocsFree
The wire format: data lines, blank-line separators, event names and the text/event-stream type.
Scenarios
Helps to know first
110 questions · last verified 2026-12