Index Ai Academy
Phase 1 · Building with LLMs · Prompting

Streaming responses

Show output as it's generated instead of waiting.

About 25 minutes · Free account required

Open this lesson Create a free account

Why it matters

A long reply from a reasoning model can take 30 seconds or more to finish. Without streaming, your user stares at a spinner for all of it; with streaming, words start appearing in a second or two. That's why chat products stream. Streaming also matters behind the scenes: requests with very large maxtokens values need it to avoid network timeouts, and the event format you'll learn here is the same one tool use and agents build on.

What you'll be able to do

  • Explain what streaming changes (how soon text appears) and what it doesn't (the reply, the cost)
  • Read a stream of server-sent events and rebuild the reply from its text deltas
  • Get the stop reason and token usage from a stream's events, and catch errors mid-stream
  • Decide when a feature should stream and when it should wait for the full reply

Before this lesson

Next in this phase: Conversations and memory