API reference
Streaming
Get the reply as it is written, as server-sent events.
Why stream
Without streaming you wait until the whole reply is written, then get it in one piece. With streaming the words arrive as the model writes them, so your users see the answer start almost at once. It is the same request with one more field: "stream": true.
What comes back
The reply is text/event-stream (server-sent events). Each event is a data: {…} line holding a chat.completion.chunk; the next piece of text is in choices[0].delta.content. The stream ends with data: [DONE].
The last chunk before [DONE] carries usage with the token counts. We ask your instance for it on every streamed request, so you don't need to set stream_options yourself.
data: {"id":"chatcmpl-example","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant","content":"Hel"}}]}
data: {"id":"chatcmpl-example","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"lo!"},"finish_reason":"stop"}]}
data: {"id":"chatcmpl-example","object":"chat.completion.chunk","choices":[],"usage":{"prompt_tokens":12,"completion_tokens":3,"total_tokens":15}}
data: [DONE]Examples
curl -N https://openllmbuddy-proxy.openllmbuddy.workers.dev/v1/chat/completions \
-H 'Authorization: Bearer ob_sk_000000000000000000000000000000000000000000000001' \
-H 'Content-Type: application/json' \
-d '{"model":"gemma4-26b-a4b-uncensored","stream":true,"messages":[{"role":"user","content":"Hello!"}]}'Tips
- With curl, pass
-Nso it prints each piece as it arrives. - Behind your own proxy (nginx and the like), turn response buffering off, or the whole reply will arrive at the end.
- You can stop reading a stream half-way. The tokens written up to then still count in your usage.
Note
Errors before the stream starts come back as a normal JSON error with its status code, not as an event.