Why production chat UIs stream tokens token by token instead of returning the full reply
Streaming hides decode time behind the user's reading speed. The wait drops from TTFT plus full decode to TTFT alone, turning 20 seconds of blank screen into a few hundred milliseconds.
Imagine ordering at a restaurant where the kitchen could either hand you the full meal in 30 minutes or bring out each dish as it finishes. The total cook time is the same either way, but the wait feels completely different. With streaming dishes, you start eating in five minutes and the kitchen finishes the rest while you enjoy the appetizer. With the all at once approach, you stare at an empty table for half an hour. LLMs work the same way. The server takes the same time to decode either way, but streaming lets the user start reading the response immediately, so the wait shrinks to just the time before the first word appears.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Streaming is the defining UX pattern of modern LLM chat applications, and it works by exploiting a temporal overlap between model decoding and user reading. The model does the same amount of work whether or not the response is streamed; what changes is when the user starts seeing tokens, and that single change collapses the perceived wait from tens of seconds to a few hundred milliseconds.
Understanding streaming is foundational because it shifts the right SLA metric from wall-clock response latency to time to first token, which has cascading effects on how production serving is designed. Prefill-decode disaggregation, queue management, autoscaling signals, and tail latency optimization all aim at TTFT in streaming-first deployments.
This deep dive walks through the latency math, the user reading speed overlap that makes streaming work, the implementation specifics of Server-Sent Events, the workloads where streaming has no benefit, and the operational considerations that come with long-lived connections. By the end you should be able to defend why every production chat UI streams, identify which workloads do not benefit, and reason about the right latency SLOs for streamed deployments.
The latency formula and where streaming acts
Total response latency for an LLM request decomposes as:
Where TTFT is the time to first token (queue wait plus prefill plus first decode step), N is the number of output tokens, and TPOT is the per output token decode time at steady state.
Typical values for a production deployment: TTFT 200-500 ms (depending on prompt length and queue load), TPOT 15-30 ms per token (depending on hardware and quantization).
For a 1000-token reply, this gives 0.3 + 1000 * 0.02 = 20.3 seconds wall-clock. For a buffered response, this is also the perceived wait: the user sees nothing until decode completes.
Streaming pushes each token to the client as it is produced. The first token arrives after TTFT. Subsequent tokens arrive every TPOT. The user is no longer waiting for the entire response; they are watching it unfold.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- ChatGPT, Claude, and Gemini all stream by default; the streaming UX defined the category.
- OpenAI's GPT-5.5 API ships an explicit 'stream: true' parameter and is the most-used path for chat applications.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow does TTFT decompose further into prefill versus queue components?
TTFT = queue wait + prefill compute + first decode step. Queue wait is set by load and admission control. Prefill compute scales with prompt length and hardware (~50-200 ms for typical prompts on H100). First decode step is one TPOT (~20 ms). Optimizing TTFT means reducing all three; prefill is the largest typically and is the target of prefill-decode disaggregation.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Thinking streaming makes the model faster. It does not change decode time at all; it overlaps decode with the user's reading time, collapsing the perceived wait.
60 second bullets to scan on the way to the call.
Same topic, related formats. Practice these next.