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.
文本生成端点支持 Server-Sent Events (SSE) 流式输出,设置 stream: true 即可逐 token 接收结果。
支持流式的端点
/v1/chat/completions — OpenAI 兼容
/v1/messages — Claude Messages
/v1/responses — OpenAI Responses API
使用示例
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 数据格式
每个 chunk 是一行 data: {json} 格式的 SSE 事件:
data: {"id":"chatcmpl-xxx","choices":[{"delta":{"content":"你"},"index":0}]}
data: {"id":"chatcmpl-xxx","choices":[{"delta":{"content":"好"},"index":0}]}
data: [DONE]
流结束时会收到 data: [DONE]。