Skip to main content
将 stream 设置为 true 后,服务会通过 Server-Sent Events 逐段返回内容。Responses 使用带 type 的事件;Chat Completions 使用 choices[].delta 数据块,两种消费者不能混用。
Responses 文本流常见事件包括 response.created、response.output_text.delta、response.completed 和 error。
把 Chat Completions 的 choices[0].delta 解析器用于 Responses 会丢失文本;把 Responses 的事件 type 解析器用于 Chat Completions 同样无效。

客户端处理

  • 不要假设每个数据块都包含文本。
  • 正确处理结束标记和连接中断。
  • 不要对同一条流式请求自动无限重连,否则可能重复计费。
  • 前端断开时,服务端应中止上游请求。
  • 工具调用参数可能跨多个事件或数据块返回,需要按当前协议拼接并通过 call_id 或工具调用 ID 关联。
最后修改于 2026年8月12日