Skip to content

Streaming

Streaming

Set stream: true untuk menerima response secara streaming lewat SSE. Berlaku untuk /v3/chat/completions (juga /messages & /responses).

Terminal window
curl https://balitechsolution.com/v3/chat/completions \
-H "Authorization: Bearer sk-xxx" \
-H "Content-Type: application/json" \
-d '{
"model": "bt/qwen3.8-flash",
"messages": [{"role": "user", "content": "Ceritakan tentang AI"}],
"stream": true,
"stream_options": {"include_usage": true}
}'

Event format

data: {"choices":[{"delta":{"content":"Halo"}}]}
data: {"choices":[{"delta":{"content":" dunia"}}]}
data: [DONE]

Usage di stream

Tambah stream_options: { include_usage: true } untuk dapat info token di chunk akhir. Gateway auto-inject include_usage kalau kamu lupa, tapi set eksplisit lebih aman.

Settings lengkap (backpressure MAX_CONCURRENT, fallback header, dsb): Settings API.