Skip to main content
Stream mode sends the answer token by token over SSE (text/event-stream). The first token appears sooner, without waiting for the full answer. Enable it with "stream": true.

Quick start: curl

The -N flag matters: without it, curl buffers the output until the buffer fills or the stream ends. Chunk format:

Python — OpenAI SDK

Python — requests

Set stream=True on the request and read iter_lines(). Stop when you receive data: [DONE].

Node.js — OpenAI SDK

Hostlinku notes

  • The x-request-id header is still sent on streaming responses.
  • If the stream fails midway, the gateway sends a data: {"error": {...}} event and does not send a fake [DONE].
  • Billing uses actual usage after the stream ends; if usage is unavailable, the reserved estimate is used.
  • Do not buffer the response in a reverse proxy or CDN. Pass text/event-stream through as-is.