Streaming
Streaming defaults to off.
Set stream: true explicitly on /v1/chat/completions, /v1/completions or /v1/responses for progressive OpenAI-compatible server-sent events (SSE), with the response header x-openmayhem-stream-mode: live. The API forwards emitted deltas without buffering the entire output. Timing depends on the provider backend, which may buffer its own output rather than emit token by token.
Request
curl -N https://api.openmayhem.ai/v1/chat/completions \
-H "Authorization: Bearer $OPENMAYHEM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "hauhaucs/qwen3.6-35b-a3b-uncensored",
"messages": [{"role": "user", "content": "Hello"}],
"max_tokens": 2000,
"stream": true,
"stream_options": {"include_usage": true}
}'The usage chunk
For /v1/chat/completions and /v1/completions, 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:
data: {"choices":[{"delta":{"content":"Hello!"}}], ...}
data: {"choices":[{"delta":{},"finish_reason":"stop"}], ...}
data: {"choices":[],"usage":{"prompt_tokens":10,"completion_tokens":42,
"total_tokens":52,"completion_tokens_details":{"reasoning_tokens":30}}}
data: [DONE]Without this option, Chat/Completions streams omit the usage chunk. /v1/responses uses the distinct OpenAI Responses event protocol, not Chat/Completions chunks or their [DONE] terminator. The error stream_recovery_unavailable means the gateway does not yet support stream recovery: the request fails before inference starts; use stream: false instead.
