Documentation
Documentation menu

Streaming

Enable streaming and parse events for the selected protocol.

On this page

Enable stream

If the selected model supports it, add stream: true. The response arrives as SSE events rather than one JSON document. In cURL, -N disables output buffering. The examples below use different protocols; set ETAGE_API_KEY in your environment beforehand. Running a request uses credits.

Bash
curl --fail-with-body -sS -N https://api.etage.one/v1/chat/completions \
  -H "Authorization: Bearer $ETAGE_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{"model":"deepseek-v4.1-flash","messages":[{"role":"user","content":"Hello"}],"stream":true}'

Parse events, not network chunks

A network chunk can contain part of an event or several SSE events. Buffer data until an event boundary, then parse data. Chat Completions sends text through choices[0].delta.content and ends the stream with [DONE]. Responses sends text changes as response.output_text.delta; handle response.completed, errors and incomplete completion separately. Do not use one JSON handler for both formats.

Do not confuse interruption with completion

HTTP 200 and the first characters do not establish a completed response. A stream interruption does not establish zero spending or guarantee execution was cancelled. Before retrying, check retained records in Usage; a missing record also does not prove there was no charge. Do not expect complete usage in every event or for every model.