Most chatbot UIs feel slow when they wait for the complete LLM response before showing anything. Server-Sent Events (SSE) fix this: the backend streams tokens as they're generated, and users see output appear character by character. Here's how to wire that up with FastAPI.
Why SSE and Not WebSockets?
WebSockets are bidirectional. For a chatbot where the client sends one message and the server streams back a response, that's more complexity than you need. SSE is:
Unidirectional (server → client), which matches the LLM streaming model exactly
HTTP/1.1 compatible — no upgrade handshake, works through most proxies and CDNs






