Docs / For renters
Streaming
Read the reply as it is written, in OpenAI's chunk format, and know what happens if a host drops.
Set "stream": true and the reply arrives as server-sent events in OpenAI's chat.completion.chunk format. The first chunk carries the role with empty content, then come the pieces of text, then a chunk with a finish_reason, and the stream ends with data: [DONE]. When an idle host has the model loaded, the first text usually shows up in under 5 seconds.
Token counts while streaming
Add "stream_options": {"include_usage": true} and the stream gets one more chunk before [DONE]. Its choices list is empty and its usage field holds the prompt, completion and total token counts.
If a host drops
Before the first token, Ballast retries on another host, up to 3 tries and never the same host twice. You see one unbroken reply and you pay once. After the first token has reached you, the stream cannot move to a different host. If the host dies then, the stream ends with finish_reason: "error" and you pay only for the tokens that arrived.
Time and length
A request runs for at most 120 seconds. max_tokens is capped at 4,096. A reply that hits either one stops there and comes back with finish_reason: "length", and you are billed for the tokens produced.
Something here wrong or missing? Tell us on Support.