Skip to main content
This tutorial is for readers who want to understand server-sent events by writing one. It assumes you have finished your first campaign, so the API is running and you are signed in. By the end you will have watched tokens arrive one at a time and will know which part of the system moves the bytes.

What you will build

A small script that sends a message and prints the reply as it is produced, rather than waiting for it to finish.

What you have learned

Streaming is a transport detail, not a different operation: the same use case answers both POST .../messages (one complete reply) and POST .../messages/stream (frames). See stream a reply for the browser-side recipe, and the generative pipeline for how the model is actually called.
Last modified on October 6, 2026