流式输出
设置 stream: true 即可启用流式输出,响应将以 Server-Sent Events (SSE) 格式逐块返回。
SSE 数据格式
每个数据块以 data: 开头,内容为 JSON 对象,包含增量内容 (delta)。
结束标记
流式响应以 data: [DONE] 作为结束标记。
流式数据块示例
SSE
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1700000000,"model":"deepseek-v4-flash","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]}
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1700000000,"model":"deepseek-v4-flash","choices":[{"index":0,"delta":{"content":"!"},"finish_reason":null}]}
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1700000000,"model":"deepseek-v4-flash","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: [DONE]