https://platform.openai.com/docs/api-reference/responses/create
部分OpenAI模型仅支持Response格式,例如o3-pro,codex-mini-latest
POST
/v1/responses创建模型响应
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 项。
请求示例
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.1",
"input": [
{
"role": "user",
"content": "Write a one-sentence bedtime story about a unicorn."
}
]
}'请求参数
| 参数 | 位置 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|---|
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 | string | 否 | - | - |
返回响应 (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
}
}来源原始接口定义(用于追溯)
以下内容来自 Apifox 快照,可能包含兼容层字段或旧示例;公开调用请以本页的协议说明和当前模型列表为准。
{
"id": 497673477,
"name": "创建模型响应",
"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": "string"
}
},
"x-apifox-orders": [
"role",
"content"
]
}
}
},
"x-apifox-orders": [
"model",
"input"
]
},
"examples": [
{
"value": "{\n \"model\": \"gpt-5.1\",\n \"input\": [\n {\n \"role\": \"user\",\n \"content\": \"Write a one-sentence bedtime story about a unicorn.\"\n }\n ]\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": 132418106,
"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": 132418106,
"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-4bef-74ce-a302-b21f1c43994a"
}
],
"codeSamples": [],
"projectId": 8662722,
"moduleId": 8310462,
"folderId": 92749343,
"ordering": 0,
"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.132418106"
],
"visibility": "INHERITED",
"securityScheme": {},
"callbacks": ""
}