Streaming
kenari supports streaming on both chat endpoints. When the request body sets "stream": true, the server sends the response gradually using Server-Sent Events with Content-Type: text/event-stream. Each event is one data: line containing a JSON chunk in the native format of the API you called.
How it works
Section titled “How it works”Chunk format follows the target API, not a merged format. Because of that, streams from the OpenAI-style endpoint have a different shape than streams from the Anthropic-style endpoint.
| Endpoint | Chunk format | End marker |
|---|---|---|
POST /v1/chat/completions | OpenAI-style delta | data: [DONE] |
POST /v1/messages | Anthropic-style event blocks | message_stop event |
OpenAI: chat completions
Section titled “OpenAI: chat completions”On /v1/chat/completions, each event carries an OpenAI-style delta chunk. Model tokens accumulate in choices[0].delta.content. The stream closes with one data: [DONE] line.
curl -N https://kenari.id/v1/chat/completions \ -H "Authorization: Bearer kn-..." \ -H "Content-Type: application/json" \ -d '{"model":"step-3-7-flash","stream":true,"messages":[{"role":"user","content":"Hitung 1 sampai 5."}]}'The -N flag turns off curl buffering so each event appears when it arrives, instead of waiting for the response to finish.
Anthropic: messages
Section titled “Anthropic: messages”On /v1/messages, the stream uses Anthropic-style event blocks. The order is: message_start, then content_block_start / content_block_delta / content_block_stop pairs for each content block, then message_delta and message_stop. Model text arrives through content_block_delta.
Reasoning
Section titled “Reasoning”Reasoning is not sent as a separate delta. See Reasoning for reasoning model behavior.
See also Chat completions and Messages for request body shapes and non-streaming responses.