Why SSE over WebSockets
SSE (Server-Sent Events) is one-way: server pushes, client listens. WebSockets are two-way. For a chat where the client sends one prompt and the server streams back tokens, SSE is the right shape: one direction, plain HTTP that middleware already understands, and nothing to negotiate. A reconnect is a different matter. The transport can come back on its own, but which events the client already holds, and whether the turn is still running on the server, are questions the application has to answer (the note below).
The wire format
SSE is just text/event-stream over HTTP. Each event is data: <payload>\n\n. The browser's EventSource API or any fetch + ReadableStream reader can parse it.
Async generator → SSE
FastAPI's StreamingResponse takes any iterable. An async generator yields strings; FastAPI flushes each one to the network. The event loop stays free to do other work between yields.