Streaming
Server-Sent Events, timeouts, and fallback behavior.
Set stream: true on a chat completion to receive tokens as they are
generated, over Server-Sent Events (text/event-stream).
Wire format
Each event is a data: line carrying a JSON chunk, terminated by a sentinel:
Kontinent injects stream_options: {"include_usage": true} upstream, so the
final chunk before [DONE] carries usage. If a provider omits it, the
gateway estimates tokens (billing still happens).
Timeouts
- Streams have no overall deadline.
- An idle upstream is cut after 90 s of silence. The provider’s own chunks act as keep-alives.
- Behind the load balancer the idle timeout is 120 s.
Fallback and errors
If the model defines fallback providers, upstream 429/5xx/connect errors are
retried on the next provider only before the first byte is streamed. Once
the first byte is out, an error surfaces mid-stream as a dropped connection —
handle a truncated stream gracefully.
Disconnecting mid-stream still bills for the tokens generated up to that point. Cancelling a request does not make it free.

