Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.qingbo.dev/llms.txt

Use this file to discover all available pages before exploring further.

Overview

Text generation endpoints support Server-Sent Events (SSE) streaming. Set stream: true to receive output token by token as it’s generated.

Streaming-Enabled Endpoints

  • /v1/chat/completions — OpenAI compatible
  • /v1/messages — Claude Messages
  • /v1/responses — OpenAI Responses API

Example

from openai import OpenAI

client = OpenAI(
    base_url="https://www.qingbo.dev/v1",
    api_key="your-api-key"
)

stream = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "写一首短诗"}],
    stream=True
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")

SSE Data Format

Each chunk is a single data: {json} SSE event:
data: {"id":"chatcmpl-xxx","choices":[{"delta":{"content":"你"},"index":0}]}

data: {"id":"chatcmpl-xxx","choices":[{"delta":{"content":"好"},"index":0}]}

data: [DONE]
When the stream ends, you’ll receive data: [DONE].