> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ai-stats.phaseo.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Streaming SSE Events

> Understand frame structure and parse SSE streams safely.

All streaming endpoints use SSE-style frames:

`data: <json-or-sentinel>`

## Typical frame sequence

1. One or more progress/delta frames.
2. A completion frame with final status and usage.
3. `data: [DONE]` sentinel.

## JavaScript parser example

```typescript theme={null}
for await (const line of client.streamText({
  model: "openai/gpt-5-nano",
  messages: [{ role: "user", content: "Say hello." }],
  stream: true,
})) {
  if (!line.startsWith("data:")) continue;
  const payload = line.slice(5).trim();
  if (payload === "[DONE]") break;
  console.log(payload);
}
```

## Python parser example

```python theme={null}
for line in client.stream_response({
    "model": "openai/gpt-5-nano",
    "input": "Say hello.",
    "stream": True,
}):
    if not line.startswith("data:"):
        continue
    payload = line[5:].strip()
    if payload == "[DONE]":
        break
    print(payload)
```

## Endpoint format notes

* `/v1/chat/completions`: chunked `choices[].delta` style events.
* `/v1/responses`: responses-style output item/delta events.
* `/v1/messages`: Anthropic-style events (`message_start`, `content_block_delta`, `message_stop`).
