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

# 流式输出

> 使用 SSE 接收模型增量输出。

在支持流式输出的接口中，将 `stream` 设置为 `true`。

```bash theme={null}
curl -N -X POST "https://xxx.wengaocloud.com/v1/chat/completions" \
  -H "Authorization: Bearer $AI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-mini",
    "stream": true,
    "messages": [
      {"role": "user", "content": "写一段简短欢迎语"}
    ]
  }'
```

典型响应：

```text theme={null}
data: {"choices":[{"delta":{"content":"你"}}]}

data: {"choices":[{"delta":{"content":"好"}}]}

data: [DONE]
```

<Note>
  不同接口返回的最终 usage 结构可能略有差异。生产对账请以完整响应和账单记录为准。
</Note>

## 火山图片 SSE

`/volcengine/v3/images/generations` 的流式输出是图片事件流，不是文本 token 增量。常见事件有：

* `image_generation.partial_succeeded`：返回单张中间结果，通常带 `image_index`、`url` 或 `b64_json`、`size`
* `image_generation.completed`：返回最终 `data[]`
* `[DONE]`：流结束

如果模型没有开启流式能力，请求 `stream=true` 会直接返回 `400`。
