跳转到主要内容
/v1/responses 端点实现了 OpenAI Responses API,支持带有内置对话历史管理的有状态多轮对话。对于需要 OpenAI 新版响应格式的工作流,它可作为 /v1/chat/completions 的替代方案。传入 previous_response_id 即可继续对话,无需重新发送完整消息历史。

端点

何时使用此端点

以下情况适合使用 /v1/responses
  • 应用基于 OpenAI Responses API 构建
  • 需要有状态的对话管理
  • 使用 previous_response_id 参数进行多轮对话
对大多数新集成,建议使用 /v1/chat/completions,它支持更广泛的模型。

请求

请求头

请求体参数

model
string
必填
要使用的模型 ID。此处仅支持兼容 Responses API 格式的模型。
input
string | array
必填
本轮的用户输入。可以是字符串或内容对象数组。
instructions
string
给模型的系统级指令,相当于对话补全中的 system 消息。
previous_response_id
string
上一次响应的 id。提供后,模型会从该位置继续对话,客户端无需发送历史记录。
max_output_tokens
integer
要生成的最大 token 数量。
stream
boolean
若为 true,则返回服务器发送事件流。默认值:false

请求示例

python

使用 previous_response_id 进行多轮对话

python

响应

响应字段

id
string
此响应的唯一标识符。将其作为 previous_response_id 传入,即可继续对话。
object
string
始终为 "response"
created_at
integer
创建响应时的 Unix 时间戳。
model
string
生成响应的模型。
output
array
模型生成的输出对象数组。
usage
object
用于计费的 token 数量。