> ## Documentation Index
> Fetch the complete documentation index at: https://doc.tokendog.io/llms.txt
> Use this file to discover all available pages before exploring further.

# 流式输出

> 通过 SSE 流式接收增量内容

设置 `stream: true` 即可逐块接收增量内容（Server-Sent Events）。

<CodeGroup>
  ```bash curl theme={null}
  curl https://tokendog.io/v1/chat/completions \
    -H "Authorization: Bearer $TOKENDOG_API_KEY" \
    -H "Content-Type: application/json" \
    -N \
    -d '{"model":"gpt-5","stream":true,"messages":[{"role":"user","content":"数到5"}]}'
  ```

  ```python Python theme={null}
  from openai import OpenAI
  client = OpenAI(base_url="https://tokendog.io/v1", api_key="YOUR_TOKENDOG_API_KEY")
  stream = client.chat.completions.create(
      model="gpt-5", stream=True,
      messages=[{"role": "user", "content": "数到5"}],
  )
  for chunk in stream:
      print(chunk.choices[0].delta.content or "", end="")
  ```

  ```javascript Node theme={null}
  import OpenAI from "openai";
  const client = new OpenAI({ baseURL: "https://tokendog.io/v1", apiKey: "YOUR_TOKENDOG_API_KEY" });
  const stream = await client.chat.completions.create({
    model: "gpt-5", stream: true,
    messages: [{ role: "user", content: "数到5" }],
  });
  for await (const chunk of stream) process.stdout.write(chunk.choices[0]?.delta?.content || "");
  ```
</CodeGroup>
