# Streaming

Streaming defaults to off: omit `stream` or set `"stream": false` for a
non-streaming response. Explicit `"stream": true` enables progressive,
OpenAI-compatible server-sent events (SSE) on `/v1/chat/completions`,
`/v1/completions`, and `/v1/responses`.

## Chat Completions and Completions usage

For `/v1/chat/completions` and `/v1/completions`, request an optional final
usage chunk with:

```json
{"stream": true, "stream_options": {"include_usage": true}}
```

With `stream_options.include_usage` set to `true`, one extra chunk arrives after the
last delta and before `[DONE]`, carrying token counts for the whole
response. Without the option, the usage chunk is omitted.

## Responses events

`/v1/responses` uses the distinct OpenAI Responses event protocol, not
Chat/Completions chunks or their `[DONE]` terminator. Consume it with a
Responses-aware event handler.

## Delivery mode

Streaming responses include `x-openmayhem-stream-mode: live`. The API forwards
emitted deltas without buffering the entire output. Delivery timing depends on
the provider backend: a backend that buffers its own output may not emit
token-by-token deltas.

## Recovery unavailable

`stream_recovery_unavailable` means the gateway does not yet support stream
recovery. The request fails before inference starts; use `"stream": false`
instead.

## Disconnecting mid-stream

Native Core durable jobs preserve billing and reconciliation for streamed
requests. Closing the connection does not guarantee cancellation or a refund.
The charge is settled exactly from the signed receipt for work performed.
Budget with `max_tokens`, not by hanging up.
