- All Courses
- Building LLM Applications
- Streaming and UX
- Streaming responses to the browser
Lesson 3.1
Streaming responses to the browser
A complete response can take ten seconds; the first token usually arrives in well under one.
9mIntermediate10.8k students
Overview
Time to first token is the number that matters
A complete response can take ten seconds; the first token usually arrives in well under one. Streaming converts a long wait into immediate feedback without making the model any faster.
The provider call stays server-side. The browser talks to your route, your route talks to the model, and the API key never leaves the server — streaming does not change that boundary.
Append to a buffer and render the whole buffer each time. Rendering per chunk causes visible flicker and breaks any markdown that spans chunks.
In this lesson you will:
- Stream tokens as they are generated
- Keep the model call on the server
- Render partial output without flicker
Resources
Notes are not saved yet — they clear when you leave this page.
Previous Lesson
Guardrails and failure modes
11m
Handling latency and cancellation
29m