Streaming
Streaming allows you to start showing parts of the response as they are being generated, reducing perceived latency.
Example Request (cURL)
curl https://api.qorebit.ai/v1/chat/completions \
-H "Authorization: Bearer qb_live_..." \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4o",
"messages": [
{ "role": "user", "content": "Write a long poem about AI." }
],
"stream": true
}'Handle with Code (Node.js)
const stream = await client.chat.completions.create({
model: 'openai/gpt-4o',
messages: [{ role: 'user', content: 'Say this is a test' }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || '');
}