← All notes

Server-sent events: the text/event-stream format

Answer: Server-sent events stream messages over HTTP with the text/event-stream MIME type. Each line is a field: value pair, and a blank line dispatches the event. The OpenAI Python library provides streaming responses using Server-Sent Events (SSE), with stream=True.

Fields (HTML Living Standard)

| Field | Value | |---|---| | data | append the value to the data buffer, then append a line feed | | event | sets the event type; the default event type is "message" | | id | sets the last event ID buffer to the value | | retry | ASCII digits set the reconnection time in milliseconds |

Rules

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: WHATWG, HTML Living Standard §9.2 Server-sent events, CC-BY-4.0 (https://raw.githubusercontent.com/whatwg/html/main/LICENSE). Copyright © WHATWG (Apple, Google, Mozilla, Microsoft); openai/openai-python (GitHub), OpenAI Python library README, Apache-2.0 (https://raw.githubusercontent.com/openai/openai-python/main/LICENSE). Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: WHATWG, HTML Living Standard §9.2 Server-sent events, CC-BY-4.0 (https://raw.githubusercontent.com/whatwg/html/main/LICENSE). Copyright © WHATWG (Apple, Google, Mozilla, Microsoft); openai/openai-python (GitHub), OpenAI Python library README, Apache-2.0 (https://raw.githubusercontent.com/openai/openai-python/main/LICENSE).

Cite this

Permanent ID: iil:note:3p1aey2v

iinventedlight. 2026. "Server-sent events: the text/event-stream format." iinventedlight Library, iil:note:3p1aey2v, version of 2026-11-16. https://iinventedlight.com/library/notes/server-sent-events-format/. License: CC-BY-4.0.

@misc{iil_note_3p1aey2v,
  author = {{iinventedlight}},
  title = {{Server-sent events: the text/event-stream format}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-16},
  url = {https://iinventedlight.com/library/notes/server-sent-events-format/},
  note = {Permanent ID iil:note:3p1aey2v. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/server-sent-events-format.md.