Topic 1 of 5 · 4 min read
Streaming output to cut perceived wait
Goal: Decide for four outputs whether to stream, stream then validate, or wait for the full result, based on whether partial output is safe to show.
Stream output when a partial answer is useful and safe to read, and hold it back when a partial answer could mislead or break something. Streaming does not make the model faster. It makes the wait feel shorter, because the user starts reading after the first words instead of staring at a spinner until the last one.
Check yourself · 1 of 3
What does streaming a model's reply change for the user?
Why it matters
A language model writes its answer one small piece (a token) at a time. A long answer can take 20 seconds or more. If you wait for the whole thing, the user sees nothing for 20 seconds. If you stream, they see words after a second or so and read at their own pace while the rest arrives. ChatGPT, Claude, Gemini and Copilot all work this way. Two numbers matter: the time to first token (how long before anything appears) and the total time. For a chat reply, the first one decides how the wait feels.
How to decide
Ask one question for each output: what happens if the user acts on, or the code reads, only the first half?
- Free text for a person to read (an answer, a draft, a summary): stream it. Half a paragraph is still readable.
- Structured output for code (JSON, a form fill, a function call): do not show or parse it half done. A cut-off JSON object is not valid and will crash the parser. Wait for the full result, or stream only to a hidden buffer and show it when it validates.
- Text that triggers an action (an email that sends itself, a refund amount): never act on a stream. Show the draft, validate it, and ask the user to confirm.
- Text that may be wrong in a harmful way (medical, legal, safety checks): stream into a draft area, or run your checks first. Once a user has read a sentence, you cannot take it back.
Avoiding layout jumps
Streaming text makes the page grow. Reserve space, keep the scroll position stable unless the user is at the bottom, and render markdown carefully: a half-written table or code fence flickers as it completes.
Before and after
Before: The assistant shows a spinner for 14 seconds, then drops a 400-word answer. Users think it froze and click Send again.
After: The first words appear after about one second. A Stop button sits where the Send button was. The same 14 seconds now feel like reading.
What goes wrong
- Streaming JSON straight into a parser and crashing on the first partial chunk.
- Showing a streamed answer, then replacing it after a safety check. The user already read the first version.
- Letting the page jump as each line arrives, so the user loses their place.
The Claude and OpenAI streaming docs describe the event stream and its chunks; read one to see how a stream can end early.
Optional code branch (engineers). Collect chunks into a buffer. Render text chunks at once; for JSON, only call the parser after the end-of-message event.
Examples
Four outputs, four decisions
| Output | Decision | Reason |
|---|---|---|
| Chat answer about a recipe | Stream | Half an answer is still readable |
| JSON that fills a booking form | Wait for the full result | A cut-off object cannot be parsed |
| Email the assistant will send | Stream a draft, then confirm | The user must approve before it leaves |
| Medical-style summary shown to a patient | Validate first, then show | A wrong sentence cannot be taken back |
A stream that stops halfway
A reply of 300 words stops at word 180 because the connection dropped. A good interface keeps the 180 words, marks the reply as incomplete, and offers Retry or Continue. A bad one shows the 180 words as if they were the whole answer.
Key points
- Streaming does not shorten the total time; it cuts the time to first token, which is what the wait feels like.
- Stream free text that a person reads; do not parse or act on structured output until it is complete.
- Anything that triggers an action, such as sending an email or issuing a refund, needs validation and a confirmation, not a live stream.
- Once a user has read a streamed sentence you cannot retract it, so risky content is checked before it is shown.
- Reserve space and keep the scroll steady so a growing answer does not make the page jump.
Common mistakes
- Parsing streamed JSON before the message has finished.
- Acting on, or sending, content that is still being generated.
- Showing a streamed answer and then silently swapping it after a safety check.
- Ignoring layout, so the page jumps while text arrives.
Check yourself · 2 of 3
An app asks a model for a JSON object that fills a booking form. What is the safest way to handle the output?
Check yourself · 3 of 3
A support bot streams a draft refund email that will be sent automatically. What should the team change?
Practice items, not counted towards your mastery.
Start here
- Response times: the 3 important limits (Nielsen Norman Group) (opens in a new tab)ArticleFree
The 0.1, 1 and 10 second limits that decide when a wait needs feedback.
- Progress Indicators Make a Slow System Less Insufferable (NN/g) (opens in a new tab)ArticleFree
When to show a progress indicator and why users tolerate a wait they can see.
- Skeleton Screens 101 (NN/g) (opens in a new tab)ArticleFree
What a skeleton screen is, when it helps and when a spinner is enough.
More for this topic
- Streaming messages (Claude) (opens in a new tab)DocsFree
How a streamed reply arrives as events, including what happens when a stream ends early.
- Streaming API responses (OpenAI) (opens in a new tab)DocsFree
The same idea from another vendor: semantic events as the response is generated.