قQabasAPI Docs
Streaming

Show the answer while it is being written.

Streaming makes chat feel faster. Your app receives small pieces of the answer as soon as they are ready.

Change one field

Set stream to true. Qabas then sends Server-Sent Events until the answer is complete.

  1. Your app opens one HTTPS request.
  2. Qabas sends text chunks as the model creates them.
  3. The stream ends with [DONE].

Try it in Terminal

The -N option tells cURL to show each chunk immediately.

cURL
curl -N https://api.qabas.ae/v1/chat/completions \
  -H "Authorization: Bearer $QABAS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen-2.5-7b",
    "messages": [{"role": "user", "content": "Explain Dubai in three sentences."}],
    "stream": true
  }'

Python

This works with the official OpenAI Python package.

Python
from openai import OpenAI
import os

client = OpenAI(
    api_key=os.environ["QABAS_API_KEY"],
    base_url="https://api.qabas.ae/v1",
)

stream = client.chat.completions.create(
    model="qwen-2.5-7b",
    messages=[{"role": "user", "content": "Explain Dubai in three sentences."}],
    stream=True,
)

for chunk in stream:
    text = chunk.choices[0].delta.content or ""
    print(text, end="", flush=True)

TypeScript or Node.js

This works with the official OpenAI JavaScript package.

TypeScript
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.QABAS_API_KEY,
  baseURL: "https://api.qabas.ae/v1",
});

const stream = await client.chat.completions.create({
  model: "qwen-2.5-7b",
  messages: [{ role: "user", content: "Explain Dubai in three sentences." }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}