---
title: "What are server-sent events (SSE)? The event-stream format"
description: "Server-sent events (SSE) is the text/event-stream format LLM APIs stream replies in. How data lines, blank-line framing, reconnection and data: [DONE] work."
url: https://broadrouter.com/glossary/sse/
lang: en
updated: 2026-11-14
publisher: BroadRouter (a BroadNet site); API by BroadNet Inference, https://inference.broadnet.ai
---

# Server-sent events (SSE)

Updated 2026-11-14

Server-sent events (SSE) is a web standard for a server to push a stream of text events to a client over one long-lived HTTP response with the content type text/event-stream. Each event is one or more field lines, such as data:, ended by a blank line.

Also called: SSE, server-sent events, text/event-stream, event stream, EventSource

SSE is the plain-text framing under almost every streamed LLM reply. Knowing the format helps when an SDK is not available or a stream misbehaves.

## How it works

The WHATWG HTML standard defines the format. The response has MIME type `text/event-stream` and is always UTF-8. The body is lines of `field: value`:

```text
: keep-alive comment, ignored by clients

event: update
id: 42
data: first line
data: second line

data: {"choices":[{"delta":{"content":"Hi"}}]}

data: [DONE]
```

The parsing rules that matter:

-   **A blank line dispatches the event.** Until it arrives, the client buffers.
-   **Several `data:` lines join with newlines** into one message.
-   **A line starting with a colon is a comment.** Servers send these to keep idle connections open.
-   **One space after the colon is stripped.** Lines may end in CRLF, LF or CR.
-   **`event`, `id` and `retry`** set the event type, the last event ID and the reconnection delay in milliseconds.

Network reads do not line up with events. One read can hold half an event or three of them, so a parser must buffer bytes and split on blank lines, not on reads.

## Reconnection, proxies and \[DONE\]

The standard builds in recovery for browsers: after a drop, `EventSource` reconnects and sends a `Last-Event-ID` header, and a server can stop retries with HTTP 204. The spec also warns that “legacy proxy servers” may drop HTTP connections after a short timeout, and suggests a comment line “every 15 seconds or so”.

LLM APIs use less of this. OpenAI’s Chat Completions stream sends only `data:` lines and ends with `data: [DONE]`, a convention of the API, not of SSE. There is no event ID to resume from, so a dropped stream cannot be continued; a retry is a new request. The general picture of [streaming](https://broadrouter.com/glossary/streaming/) and the time-to-first-token benefit are covered on that page.

## On BroadNet Inference

BroadNet’s docs say to set `stream=true` and “read Server-Sent Events until the literal `data: [DONE]` marker”. If the connection ends before it, treat the response as incomplete, record the `X-Request-ID` header, and decide whether a new inference request is safe. With `stream_options: {"include_usage": true}`, usage arrives in the last chunk. The docs’ curl example uses `-N` so curl does not buffer. A stream also holds one [concurrency](https://broadrouter.com/glossary/concurrency/) slot until it ends: 4 on a pay-as-you-go key, one on an hourly key. The docs ask you to verify streaming per model before production. Code for each SDK is in the [streaming guide](https://broadrouter.com/guides/streaming-chat-completions/), and the chunk contents are explained in [LLM streaming explained](https://broadrouter.com/blog/llm-streaming-sse-explained/).

## Questions

### Can I use the browser EventSource API with an LLM API?

Usually not directly. The spec's EventSource constructor takes only a URL and a withCredentials flag, so it cannot send a POST body or an Authorization header. Use fetch and parse the stream yourself, or an SDK.

### What does "data: \[DONE\]" mean?

It is not part of the SSE standard. OpenAI-style APIs send the literal line "data: \[DONE\]" as their last event to say the reply is complete.

### Why does my stream arrive all at once?

Something between the server and your code is buffering the response, such as a reverse proxy, a framework or curl without -N. Turn buffering off for that route.

## See also

-   [Streaming](https://broadrouter.com/glossary/streaming/) (term)
-   [Time to first token (TTFT)](https://broadrouter.com/glossary/time-to-first-token/) (term)
-   [Concurrency](https://broadrouter.com/glossary/concurrency/) (term)
-   [OpenAI-compatible API](https://broadrouter.com/glossary/openai-compatible-api/) (term)
-   [Idempotency key](https://broadrouter.com/glossary/idempotency-key/) (term)
-   [Stream chat completions and handle dropped connections](https://broadrouter.com/guides/streaming-chat-completions/) (guide)
-   [BroadNet Inference error codes and when to retry](https://broadrouter.com/guides/errors-and-retries/) (guide)
-   [LLM streaming explained: SSE chunks, deltas, usage and cancel](https://broadrouter.com/blog/llm-streaming-sse-explained/) (article)

Try it on your real workload. New accounts start with $5 of credit for Gemma and transcription. DeepSeek, GLM and Qwen3.8 need a top-up.

[Get started](https://inference.broadnet.ai/account/?utm_source=broadrouter&utm_medium=referral&utm_campaign=glossary-sse&utm_content=page-cta) ·

**Sources**

-   [WHATWG HTML Living Standard, server-sent events](https://html.spec.whatwg.org/multipage/server-sent-events.html)
-   [OpenAI API reference, create chat completion (stream, data \[DONE\])](https://developers.openai.com/api/reference/resources/chat/subresources/completions/methods/create)
-   [BroadNet Inference API reference, streaming text](https://inference.broadnet.ai/docs?utm_source=broadrouter&utm_medium=referral&utm_campaign=glossary-sse&utm_content=sources#requests)
