https://platform.openai.com/docs/api-reference/responses/create
部分OpenAI模型仅支持Response格式,例如o3-pro,codex-mini-latest
POST
/v1/responses创建模型响应 gpt-5启用思考
API Key application/json
Responses API
调用与返回说明
OpenAI 新项目的首选模型调用协议。它以 output 项目表达文本、工具调用和推理结果,不能按 Chat Completions 的 choices 结构读取。
请求时注意
- 模型 ID 不要从示例中照抄。先调用 GET /v1/models,再选择返回列表中实际可用且支持当前协议的完整 ID。
- Responses API 的 input 可以是字符串,也可以是带 role/content 的输入项目数组;图片、文件和工具调用必须使用官方规定的输入项目类型。
- 不要把 Chat Completions 的 choices、message 或 delta 结构混用于 Responses API。
返回时注意
- 先检查 HTTP 状态码,再检查 response.status。只有 status=completed 才应视为完整成功;incomplete、failed 等状态必须进入业务失败或补偿流程。
- 文本优先读取 SDK 的 response.output_text;直接 HTTP 客户端应遍历 output,并提取 message 内容中的 output_text 项。
- 流式结束以 response.completed 等事件为准;同时处理 response.failed、response.incomplete 和网络断开,不要只等待 [DONE]。
请求示例
curl -X POST https://top.qingyuntop.ai/v1/responses \
-H "Authorization: Bearer ${QINGYUN_TOP_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5-2025-08-07",
"input": [
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "1+2+3+4+5....9985"
}
]
}
],
"tools": [],
"text": {
"format": {
"type": "text"
},
"verbosity": "medium"
},
"reasoning": {
"effort": "medium",
"summary": "auto"
},
"stream": true,
"store": true
}'请求参数
| 参数 | 位置 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|---|
Content-Type | Header | string | 是 | - | application/json |
Accept | Header | string | 是 | - | application/json |
Authorization | Header | string | 否 | - | Bearer {{YOUR_API_KEY}} |
model | JSON body | string | 是 | 要使用的模型的 ID。有关哪些模型可与聊天 API 一起使用的详细信息,请参阅模型端点兼容性表。 必填。使用 GET /v1/models 返回的准确模型 ID;模型可用性和支持的协议由服务端配置决定。 | - |
input | JSON body | array<object> | 是 | 模型的文本、图像,用于生成响应。 必填。简单文本可传字符串;多轮、图片、文件或工具场景使用输入项目数组。 | - |
input[].role | JSON body | string | 是 | - | - |
input[].content | JSON body | array<object> | 是 | - | - |
input[].content[].type | JSON body | string | 否 | - | - |
input[].content[].text | JSON body | string | 否 | - | - |
tools | JSON body | array<string> | 否 | 模型可以调用的一组工具列表。目前,只支持作为工具的函数。使用此功能来提供模型可以为之生成 JSON 输入的函数列表。 可选。Responses 函数工具使用 type、name、description、parameters 等字段;与 Chat Completions 的嵌套 function 形状不同。 | - |
text | JSON body | object | 否 | 用于模型文本响应的配置选项。可以是纯文本或结构化 JSON 数据。 可选。需要结构化输出时使用 text.format,并先确认所选模型支持该格式。 | - |
text.format | JSON body | object | 否 | 指定模型必须输出的格式。 | - |
text.format.type | JSON body | string | 是 | 定义的响应格式类型。始终为text。 | - |
text.verbosity | JSON body | string | 否 | 限制模型响应的详细程度。较低的值为更简洁的响应,而较高的值会有更详细的响应。目前支持的值为low、medium和high。默认为medium | - |
reasoning | JSON body | object | 否 | 仅对支持推理配置的模型发送,并按该模型支持的 effort 值选择。不要假设所有模型都支持同一组值。 | - |
reasoning.effort | JSON body | string | 否 | 当前支持的值有minimal、low、medium和high。减少推理工作量可以加快响应速度,并减少响应中用于推理的标记。默认为medium | - |
reasoning.summary | JSON body | string | 否 | 模型执行的推理的摘要。这对于调试和理解模型的推理过程很有用。auto、concise或之一detailed。 | - |
stream | JSON body | boolean | 否 | 默认为 false 如果设置,则像在 ChatGPT 中一样会发送部分消息增量。标记将以仅数据的服务器发送事件的形式发送,这些事件在可用时,并在 data: [DONE] 消息终止流。Python 代码示例。 可选,默认 false。为 true 时返回 Responses 类型的 SSE 事件流,不是 Chat Completions 的 choices.delta。 | - |
store | JSON body | boolean | 否 | 是否存储生成的模型响应以供以后通过 API 检索。默认为true 可选。是否保存响应供后续检索;不要在含敏感数据的场景盲目开启。 | - |
返回响应 (200)
| 参数 | 位置 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|---|
id | 响应 JSON | string | 否 | 响应唯一标识。需要关联或排查请求时保存它。 | - |
object | 响应 JSON | string | 否 | 固定为 response。不要用 choices 判断 Responses API 的返回。 | - |
status | 响应 JSON | string | 否 | 响应状态,常见值包括 completed、incomplete、failed、in_progress。业务成功判定应检查此字段。 | - |
model | 响应 JSON | string | 否 | 实际使用的模型 ID。 | - |
output[] | 响应 JSON | array<object> | 否 | 输出项目数组,可能包含 message、function_call、reasoning 等不同类型。 | - |
output[].content[].text | 响应 JSON | string | 否 | 消息型输出中的文本内容。SDK 的 response.output_text 是便捷聚合值,不一定是原始 JSON 字段。 | - |
error | 响应 JSON | object|null | 否 | 失败信息。HTTP 200 仍可能对应 failed 或 incomplete 状态,必须同时检查此字段。 | - |
incomplete_details | 响应 JSON | object|null | 否 | 响应未完成时的原因和细节。 | - |
usage | 响应 JSON | object | 否 | token 用量,通常包含 input_tokens、output_tokens、total_tokens 及其 details。 | - |
响应示例
{
"id": "resp_example",
"object": "response",
"created_at": 1710000000,
"status": "completed",
"model": "MODEL_ID_FROM_V1_MODELS",
"output": [
{
"type": "message",
"id": "msg_example",
"status": "completed",
"role": "assistant",
"content": [
{
"type": "output_text",
"annotations": [],
"text": "你好,我可以帮助你。"
}
]
}
],
"usage": {
"input_tokens": 18,
"output_tokens": 12,
"total_tokens": 30
}
}流式事件示例
下面只展示事件形状。生产客户端应按事件类型处理增量、完成、失败和未完成事件,并设置读取超时。
event: response.output_text.delta
data: {"type":"response.output_text.delta","delta":"你好","item_id":"msg_example","output_index":0,"content_index":0}
event: response.completed
data: {"type":"response.completed","response":{"id":"resp_example","status":"completed","output":[]}}来源原始接口定义(用于追溯)
以下内容来自 Apifox 快照,可能包含兼容层字段或旧示例;公开调用请以本页的协议说明和当前模型列表为准。
{
"id": 497673482,
"name": "创建模型响应 gpt-5启用思考",
"type": "http",
"serverId": "",
"preProcessors": [],
"postProcessors": [],
"inheritPreProcessors": {},
"inheritPostProcessors": {},
"description": "https://platform.openai.com/docs/api-reference/responses/create\n部分OpenAI模型仅支持Response格式,例如o3-pro,codex-mini-latest",
"operationId": "",
"sourceUrl": "",
"method": "post",
"path": "/v1/responses",
"tags": [],
"status": 1,
"requestBody": {
"type": "application/json",
"parameters": [],
"jsonSchema": {
"type": "object",
"properties": {
"model": {
"type": "string",
"description": "要使用的模型的 ID。有关哪些模型可与聊天 API 一起使用的详细信息,请参阅模型端点兼容性表。"
},
"input": {
"type": "array",
"items": {
"type": "object",
"properties": {
"role": {
"type": "string"
},
"content": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"text": {
"type": "string"
}
},
"x-apifox-orders": [
"type",
"text"
]
}
}
},
"x-apifox-orders": [
"role",
"content"
],
"required": [
"content",
"role"
]
},
"description": "模型的文本、图像,用于生成响应。"
},
"tools": {
"type": "array",
"items": {
"type": "string"
},
"description": "模型可以调用的一组工具列表。目前,只支持作为工具的函数。使用此功能来提供模型可以为之生成 JSON 输入的函数列表。"
},
"text": {
"type": "object",
"properties": {
"format": {
"type": "object",
"properties": {
"type": {
"type": "string",
"description": "定义的响应格式类型。始终为text。"
}
},
"required": [
"type"
],
"x-apifox-orders": [
"type"
],
"description": "指定模型必须输出的格式。"
},
"verbosity": {
"type": "string",
"description": "限制模型响应的详细程度。较低的值为更简洁的响应,而较高的值会有更详细的响应。目前支持的值为low、medium和high。默认为medium"
}
},
"x-apifox-orders": [
"format",
"verbosity"
],
"description": "用于模型文本响应的配置选项。可以是纯文本或结构化 JSON 数据。"
},
"reasoning": {
"type": "object",
"properties": {
"effort": {
"type": "string",
"description": "当前支持的值有minimal、low、medium和high。减少推理工作量可以加快响应速度,并减少响应中用于推理的标记。默认为medium"
},
"summary": {
"type": "string",
"description": "模型执行的推理的摘要。这对于调试和理解模型的推理过程很有用。auto、concise或之一detailed。"
}
},
"x-apifox-orders": [
"effort",
"summary"
]
},
"stream": {
"type": "boolean",
"description": "默认为 false 如果设置,则像在 ChatGPT 中一样会发送部分消息增量。标记将以仅数据的服务器发送事件的形式发送,这些事件在可用时,并在 data: [DONE] 消息终止流。Python 代码示例。"
},
"store": {
"type": "boolean",
"description": "是否存储生成的模型响应以供以后通过 API 检索。默认为true"
}
},
"x-apifox-orders": [
"model",
"input",
"tools",
"text",
"reasoning",
"stream",
"store"
]
},
"examples": [
{
"value": "{\n \"model\": \"gpt-5-2025-08-07\",\n \"input\": [\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"input_text\",\n \"text\": \"1+2+3+4+5....9985\"\n }\n ]\n }\n ],\n \"tools\": [],\n \"text\": {\n \"format\": {\n \"type\": \"text\"\n },\n \"verbosity\": \"medium\"\n },\n \"reasoning\": {\n \"effort\": \"medium\",\n \"summary\": \"auto\"\n },\n \"stream\": true,\n \"store\": true\n}",
"mediaType": "application/json"
}
],
"mediaType": "",
"oasExtensions": "",
"required": false,
"additionalContentTypes": []
},
"parameters": {
"path": [],
"query": [],
"cookie": [],
"header": [
{
"id": "NQs7bxnpZf",
"name": "Content-Type",
"required": true,
"enable": true,
"description": "",
"type": "string",
"sampleValue": "application/json"
},
{
"id": "qb8tEQbCty",
"name": "Accept",
"required": true,
"enable": true,
"description": "",
"type": "string",
"sampleValue": "application/json"
},
{
"id": "gBxcCbXhsa",
"name": "Authorization",
"required": false,
"enable": true,
"description": "",
"type": "string",
"sampleValue": "Bearer {{YOUR_API_KEY}}"
}
]
},
"commonParameters": {
"query": [],
"body": [],
"cookie": [],
"header": []
},
"auth": {},
"responses": [
{
"id": 159726787,
"name": "OK",
"code": 200,
"contentType": "json",
"jsonSchema": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"object": {
"type": "string"
},
"created": {
"type": "integer"
},
"choices": {
"type": "array",
"items": {
"type": "object",
"properties": {
"index": {
"type": "integer"
},
"message": {
"type": "object",
"properties": {
"role": {
"type": "string"
},
"content": {
"type": "string"
}
},
"required": [
"role",
"content"
],
"x-apifox-orders": [
"role",
"content"
]
},
"finish_reason": {
"type": "string"
}
},
"x-apifox-orders": [
"index",
"message",
"finish_reason"
]
}
},
"usage": {
"type": "object",
"properties": {
"prompt_tokens": {
"type": "integer"
},
"completion_tokens": {
"type": "integer"
},
"total_tokens": {
"type": "integer"
}
},
"required": [
"prompt_tokens",
"completion_tokens",
"total_tokens"
],
"x-apifox-orders": [
"prompt_tokens",
"completion_tokens",
"total_tokens"
]
}
},
"required": [
"id",
"object",
"created",
"choices",
"usage"
],
"x-apifox-orders": [
"id",
"object",
"created",
"choices",
"usage"
]
},
"itemSchema": {},
"description": "",
"mediaType": "",
"headers": [],
"oasExtensions": ""
}
],
"responseExamples": [
{
"name": "OK",
"responseId": 159726787,
"data": "{\n \"id\": \"chatcmpl-123\",\n \"object\": \"chat.completion\",\n \"created\": 1677652288,\n \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": \"assistant\",\n \"content\": \"\\n\\nHello there, how may I assist you today?\"\n },\n \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 9,\n \"completion_tokens\": 12,\n \"total_tokens\": 21\n }\n}",
"description": "",
"oasKey": "",
"oasExtensions": "",
"id": "019fd25e-4bf0-76da-b34e-21fc4f60bae2"
}
],
"codeSamples": [],
"projectId": 8662722,
"moduleId": 8310462,
"folderId": 92749343,
"ordering": 30,
"responsibleId": 0,
"commonResponseStatus": {},
"advancedSettings": {
"disabledSystemHeaders": {},
"isDefaultUrlEncoding": 1
},
"customApiFields": {},
"oasExtensions": "",
"mockScript": {},
"createdAt": "2026-08-05T14:40:23.000Z",
"updatedAt": "2026-08-06T12:15:55.000Z",
"creatorId": 2863449,
"editorId": 2863449,
"creatorUserId": 2863449,
"editorUserId": 2863449,
"responseChildren": [
"BLANK.159726787"
],
"visibility": "INHERITED",
"securityScheme": {},
"callbacks": ""
}