Skip to content
mentoor

Streaming responses

For engineers

How server-sent event streams deliver tokens, how to assemble deltas, cancel cleanly and survive proxies and mid-stream errors

See where you stand

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?

Choose one answer

Check yourself · 2 of 5

When can your server safely call JSON.parse on a streamed tool call's arguments?

Choose one answer

Check yourself · 3 of 5

A user clicks Stop. Which chain stops the model generating?

Choose one answer

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?

Choose one answer

Check yourself · 5 of 5

In a Claude message stream, which event carries the stop reason and the final token usage?

Choose one answer

Topics

  1. 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
  2. Accumulating text and tool-call deltas5 min read · Assembling streamed text and partial tool-call JSON on the server before forwarding or parsing it
  3. 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
  4. 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

Helps to know first

110 questions · last verified 2026-12