Backend for AIintermediate11 min · 10 steps
Streaming with SSE
Server-sent events stream tokens, agent status and citations over one long-lived HTTP response, which is how model APIs stream and the simplest way to stream to a browser.
first visible text3.7s
requesttokenresponsetool calldataerror
metrics are illustrativeProblemStep 1 of 10
Nothing on screen until the whole answer is done
A user asks "Is my VPN ticket still open?". The agent looks up tickets, calls the model and writes ~120 tokens. Returned as one JSON response, the screen stays blank for almost 4 seconds.
Worse, the user can't see that anything is happening: no "looking up your tickets", no partial text, no sign the request didn't just hang.
Lesson 4 of 20 in Backend for AI