Why do LLM products stream responses, and how does streaming actually work over HTTP?
Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.
Model answer: the part to lead with
Because perceived latency is dominated by time to first visible output, not total time. A 600-token answer at 30 tokens/s takes ~20 s to finish - unacceptable as a blank spinner, perfectly fine as a stream that starts in 400 ms. Streaming converts the user-perceived latency from TTFT + TPOT × N to roughly TTFT. It also enables early cancellation (user stops a bad generation → you stop paying for output tokens) and progressive downstream processing.
Full worked answer
Because perceived latency is dominated by time to first visible output, not total time. A 600-token answer at 30 tokens/s takes ~20 s to finish - unacceptable as a blank spinner, perfectly fine as a stream that starts in 400 ms. Streaming converts the user-perceived latency from TTFT + TPOT × N to roughly TTFT. It also enables early cancellation (user stops a bad generation → you stop paying for output tokens) and progressive downstream processing.
Mechanics: the standard transport is Server-Sent Events (SSE) - a plain HTTP response with Content-Type: text/event-stream that the server keeps open, writing incremental events:
data: {"delta": {"text": "The"}}
data: {"delta": {"text": " answer"}}
data: [DONE]
Each event is a data: line terminated by a blank line; clients parse events as they arrive. OpenAI's Chat Completions streams token deltas and ends with a [DONE] sentinel; Anthropic's Messages API and OpenAI's newer Responses API stream named, typed events instead (for example message_start, content_block_delta, message_stop on Anthropic, response.output_text.delta on OpenAI). WebSockets are an alternative when you need bidirectional traffic (e.g., voice), but SSE is simpler and proxy-friendly for one-way token streams.
Going further: follow-up territory
Production gotchas worth mentioning: intermediate proxies/load balancers buffering responses (must disable buffering, watch idle timeouts); handling reconnects (most LLM APIs can't resume a stream - a retry restarts generation, so the client must handle replacement); heartbeats/keep-alives during long tool-use pauses; and the fact that usage/cost accounting typically arrives in the final event, so billing code can't assume it exists if the stream is aborted. Tool calls and JSON arrive as partial fragments and need accumulation before they're parseable.
What a good answer covers
- Because perceived latency is dominated by time to first visible output, not total time
- A 600-token answer at 30 tokens/s takes ~20 s to finish - unacceptable as a blank spinner, perfectly…
- Streaming converts the user-perceived latency from TTFT + TPOT × N to roughly TTFT
- It also enables early cancellation (user stops a bad generation → you stop paying for output tokens) and…
- Each event is a data: line terminated by a blank line; clients parse events as they arrive
Key terms: Server-Sent Events (SSE)
In the glossary: TTFT · TPOT / ITL · SSE · Tool call
Interviewer follow-ups to expect
How would you design retry behaviour for a stream that dies at token 400 of 600?
What breaks when you put a naive CDN or proxy in front of SSE?
Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep