Public preview: This API is in public preview. Endpoints, schemas, and limits may change before general availability.
Streaming
How EU GPT streams responses as Server-Sent Events, and when streaming is the right call.
EU GPT streams responses as Server-Sent Events (SSE) by default. The SDKs hide the wire format, but it helps to know what is on the wire.
When to stream#
| You want | Choose |
|---|---|
| To render output as the model produces it (chat UIs, dashboards). | stream: true |
| The shortest time to the first words of the answer. | stream: true |
A single JSON document you can JSON.parse or .json(). | stream: false |
| Back-end batch jobs that do not need partial output. | stream: false |
Streaming reduces perceived latency: the first words arrive while the rest is still being written, and a full answer can take many seconds. The first text takes longer when the model first searches the web or reads documents, but tool activity shows up in the stream right away. For anything user-facing, stream.
The wire format#
The HTTP response has Content-Type: text/event-stream. The body is a sequence of events separated by blank lines:
event: message
data: {"type":"response.created","sequence_number":1,"response":{…}}
event: message
data: {"type":"response.output_item.added","sequence_number":2,"output_index":0,"item":{…}}
event: message
data: {"type":"response.content_part.added","sequence_number":3,…}
event: message
data: {"type":"response.output_text.delta","sequence_number":4,…,"delta":"Hello"}
: ping - 2026-11-02 12:00:15.012345+00:00
event: message
data: {"type":"response.output_text.delta","sequence_number":5,…,"delta":", world"}
event: message
data: {"type":"response.output_text.done","sequence_number":6,…,"text":"Hello, world"}
event: message
data: {"type":"response.completed","sequence_number":7,"response":{…,"output_text":"Hello, world"}}
- Every
data:line is one JSON object with atypeand asequence_number. The full taxonomy is in Streaming events. - Lines end with
\r\n, so events are separated by\r\n\r\n. Standard SSE clients handle this; if you parse by hand, see Handling streams. - Lines that start with
:are comments. EU GPT sends a: pingcomment every 15 seconds to keep the connection open. Ignore them.
Ordering and gaps#
response.createdis always the first event, withsequence_number1.sequence_numbergoes up by one with every event.- The stream ends with
response.completed, withresponse.incompletewhen the answer was cut off bymax_output_tokens, or with anerrorevent. - An
errorevent means the response failed, even if aresponse.completedevent still follows it. - The connection closes (server-side) after the last event.
Buffering and proxies#
Some HTTP proxies and load balancers buffer responses, defeating the point of streaming. If your application sits behind a custom proxy:
- Disable response buffering on routes that forward
/v1/responses. - For Nginx, set
proxy_buffering off;andproxy_cache off;on that location. - For Cloudflare workers, set
cache: "no-store"and avoidResponsewrapping that re-reads the body.
The EU GPT edge does not buffer streams.
Server-side timeouts#
- A single request can run for at most 10 minutes. After that the connection is closed, so break very long jobs into smaller calls.
- If the model you named has not started answering after 45 seconds, EU GPT switches to another model and reports it with a
response.model.fallbackevent (see Models). - Because of the 15-second pings, a connection that stays completely silent for a minute is dead: disconnect and retry.
Parsing the stream#
You almost never need to parse SSE by hand:
- JavaScript: use the
openaiSDK’sAsyncIterableinterface. - Python: use the
openaiSDK’sstream=Truemode, which yields parsed events. - Other languages: any standard SSE client will work. The
data:payload is a JSON object.
For hand-rolled parsers, see Handling streams.