跳到主要内容

Responses

API 参考/Responses/创建回复

创建回复

POST/v1/responses

使用 OpenAI Responses API 格式创建非流式或流式模型响应,适合 GPT-5.5 等新协议模型。

认证

API Key 通过请求头传入。

Authorizationstring必填

API Key,格式为 Bearer YOUR_API_KEY。

默认值:-
Content-Typestring必填

请求体格式。

默认值:application/json
Request-Idstring可选

客户侧生成的唯一请求标识,用于追踪和排查。

默认值:-

请求

请求体必须包含 modelinput

modelstring必填

Responses API 模型 ID,例如 gpt-5.5 或 gpt-5.5-pro。

默认值:-
inputstring | array必填

输入内容,可以是字符串,也可以是结构化多轮消息。

默认值:-
instructionsstring可选

系统级指令,用于设定回答风格、角色或任务边界。

默认值:-
streamboolean可选

是否启用 SSE 流式输出。

默认值:false
temperaturenumber可选

采样温度,取值通常为 0 到 2。

默认值:1
top_pnumber可选

核采样参数。通常不要与 temperature 同时大幅调整。

默认值:1
max_output_tokensinteger可选

限制本次响应最多生成的输出 Token 数。

默认值:-
toolsarray可选

可供模型调用的工具列表。

默认值:-
tool_choicestring | object可选

工具调用策略,例如 auto、none 或指定工具。

默认值:-
textobject可选

文本输出格式配置,例如 JSON Schema。

默认值:-
reasoningobject可选

推理配置,用于支持推理模型的思考强度控制。

默认值:-
storeboolean可选

是否存储响应用于后续检索或延续上下文。

默认值:false

响应

非流式请求返回完整 response 对象。流式请求通过 SSE 逐步返回事件。

idstring必填

响应唯一标识。

默认值:-
objectstring必填

对象类型。

默认值:response
created_atinteger必填

创建时间,Unix 时间戳。

默认值:-
modelstring必填

实际执行请求的模型。

默认值:-
outputarray必填

模型输出列表,可能包含 message、function_call 等类型。

默认值:-
output[].contentarray可选

消息内容块列表,文本输出通常为 output_text。

默认值:-
usageobject可选

Token 用量统计。

默认值:-

流式响应

设置 stream: true 后,响应会以 SSE 事件返回。常见事件包括 response.createdresponse.output_item.addedresponse.output_text.deltaresponse.completed

data: {"type":"response.output_text.delta","delta":"量子"}
data: {"type":"response.output_text.delta","delta":"计算"}
data: {"type":"response.completed","response":{"id":"resp_abc123"}}

错误

状态码说明
400请求体字段错误或模型不支持指定参数
401API Key 缺失或无效
403当前账户无权调用该模型
429请求超过速率限制
500 / 503平台或上游模型服务异常

相关指南