https://platform.openai.com/docs/api-reference/responses/create
部分OpenAI模型仅支持Response格式,例如o3-pro,codex-mini-latest
POST
/v1/responses创建函数调用 Copy
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 项。
- 函数调用的 arguments 是 JSON 字符串,不是已经解析好的对象。解析、校验并在服务端执行后,再以 function_call_output 输入项继续请求。
请求示例
curl -X POST https://top.qingyuntop.ai/v1/responses \
-H "Authorization: Bearer ${QINGYUN_TOP_API_KEY}" \
-H "Content-Type: application/json" \
-d '
{
"input": [
{
"role": "user",
"content": "请同时帮我做以下几件事:\n1. 获取当前系统时间\n2. 查看系统信息(操作系统、内存等)\n3. 帮我计算 123.5 + 456.7 的结果\n4. 生成3个1-100之间的随机数\n\n这是一个并行工具调用测试,请同时执行这些任务。"
}
],
"metadata": {
"model_id": "32"
},
"model": "gpt-4.1",
"tool_choice": "auto",
"tools": [
{
"type": "function",
"name": "random_generator",
"description": "生成指定范围内的随机数,支持批量生成",
"parameters": {
"type": "object",
"properties": {
"min": {
"description": "最小值(默认1)",
"type": "integer"
},
"max": {
"description": "最大值(默认100)",
"type": "integer"
},
"count": {
"description": "生成数量(默认1,最大10)",
"type": "integer"
}
}
}
},
{
"type": "function",
"name": "system_info",
"description": "获取当前系统的基本信息,包括操作系统、Java版本、内存使用情况等",
"parameters": {
"type": "object",
"properties": {}
}
},
{
"type": "function",
"name": "math_calculator",
"description": "执行基本数学运算,支持加减乘除和幂运算",
"parameters": {
"type": "object",
"properties": {
"a": {
"description": "第一个数字",
"type": "number"
},
"b": {
"description": "第二个数字",
"type": "number"
},
"operation": {
"description": "运算类型: add, subtract, multiply, divide, power",
"type": "string"
}
},
"required": [
"operation",
"a",
"b"
]
}
},
{
"type": "function",
"name": "current_time",
"description": "获取当前系统时间",
"parameters": {
"type": "object",
"properties": {}
}
}
]
}'请求参数
| 参数 | 位置 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|---|
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",
"status": "completed",
"output": [
{
"type": "function_call",
"id": "fc_example",
"call_id": "call_example",
"name": "get_weather",
"arguments": "{\"city\":\"Shanghai\"}",
"status": "completed"
}
]
}来源原始接口定义(用于追溯)
以下内容来自 Apifox 快照,可能包含兼容层字段或旧示例;公开调用请以本页的协议说明和当前模型列表为准。
{
"id": 497676417,
"name": "创建函数调用 Copy",
"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": "\t\n{\n \"input\": [\n {\n \"role\": \"user\",\n \"content\": \"请同时帮我做以下几件事:\\n1. 获取当前系统时间\\n2. 查看系统信息(操作系统、内存等)\\n3. 帮我计算 123.5 + 456.7 的结果\\n4. 生成3个1-100之间的随机数\\n\\n这是一个并行工具调用测试,请同时执行这些任务。\"\n }\n ],\n \"metadata\": {\n \"model_id\": \"32\"\n },\n \"model\": \"gpt-4.1\",\n \n \"tool_choice\": \"auto\",\n \"tools\": [\n {\n \"type\": \"function\",\n \"name\": \"random_generator\",\n \"description\": \"生成指定范围内的随机数,支持批量生成\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"min\": {\n \"description\": \"最小值(默认1)\",\n \"type\": \"integer\"\n },\n \"max\": {\n \"description\": \"最大值(默认100)\",\n \"type\": \"integer\"\n },\n \"count\": {\n \"description\": \"生成数量(默认1,最大10)\",\n \"type\": \"integer\"\n }\n }\n }\n },\n {\n \"type\": \"function\",\n \"name\": \"system_info\",\n \"description\": \"获取当前系统的基本信息,包括操作系统、Java版本、内存使用情况等\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {}\n }\n },\n {\n \"type\": \"function\",\n \"name\": \"math_calculator\",\n \"description\": \"执行基本数学运算,支持加减乘除和幂运算\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"a\": {\n \"description\": \"第一个数字\",\n \"type\": \"number\"\n },\n \"b\": {\n \"description\": \"第二个数字\",\n \"type\": \"number\"\n },\n \"operation\": {\n \"description\": \"运算类型: add, subtract, multiply, divide, power\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"operation\",\n \"a\",\n \"b\"\n ]\n }\n },\n {\n \"type\": \"function\",\n \"name\": \"current_time\",\n \"description\": \"获取当前系统时间\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {}\n }\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": 186304025,
"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": "成功示例",
"responseId": 186304025,
"data": "{\n \"id\": \"resp_68ac1558e9488190bcc2cbb94c7d7a140b8064b15a091a77\",\n \"object\": \"response\",\n \"created_at\": 1756108120,\n \"status\": \"completed\",\n \"background\": false,\n \"content_filters\": null,\n \"error\": null,\n \"incomplete_details\": null,\n \"instructions\": null,\n \"max_output_tokens\": null,\n \"max_tool_calls\": null,\n \"model\": \"gpt-4.1-data\",\n \"output\": [\n {\n \"id\": \"fc_68ac15594be88190a58217f75a6a54cc0b8064b15a091a77\",\n \"type\": \"function_call\",\n \"status\": \"completed\",\n \"arguments\": \"{\\\"sign\\\":\\\"Aquarius\\\"}\",\n \"call_id\": \"call_6kbB2GTk62PPUNdGuBJPx9KQ\",\n \"name\": \"get_horoscope\"\n }\n ],\n \"parallel_tool_calls\": true,\n \"previous_response_id\": null,\n \"prompt_cache_key\": null,\n \"reasoning\": {\n \"effort\": null,\n \"summary\": null\n },\n \"safety_identifier\": null,\n \"service_tier\": \"default\",\n \"store\": true,\n \"temperature\": 1.0,\n \"text\": {\n \"format\": {\n \"type\": \"text\"\n }\n },\n \"tool_choice\": \"auto\",\n \"tools\": [\n {\n \"type\": \"function\",\n \"description\": \"Get today's horoscope for an astrological sign.\",\n \"name\": \"get_horoscope\",\n \"parameters\": {\n \"properties\": {\n \"sign\": {\n \"description\": \"An astrological sign like Taurus or Aquarius\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"sign\"\n ],\n \"type\": \"object\"\n },\n \"strict\": true\n }\n ],\n \"top_p\": 1.0,\n \"truncation\": \"disabled\",\n \"usage\": {\n \"input_tokens\": 62,\n \"input_tokens_details\": {\n \"cached_tokens\": 0\n },\n \"output_tokens\": 18,\n \"output_tokens_details\": {\n \"reasoning_tokens\": 0\n },\n \"total_tokens\": 80\n },\n \"user\": null,\n \"metadata\": {}\n}",
"description": "",
"oasKey": "",
"oasExtensions": "",
"id": "019fd230-6e93-77ce-8baf-0d829de510dc"
}
],
"codeSamples": [],
"projectId": 8662722,
"moduleId": 8310462,
"folderId": 92749343,
"ordering": 36,
"responsibleId": 0,
"commonResponseStatus": {},
"advancedSettings": {
"disabledSystemHeaders": {},
"isDefaultUrlEncoding": 1
},
"customApiFields": {},
"oasExtensions": "",
"mockScript": {},
"createdAt": "2026-08-05T15:08:32.000Z",
"updatedAt": "2026-08-06T12:15:55.000Z",
"creatorId": 2863449,
"editorId": 2863449,
"creatorUserId": 2863449,
"editorUserId": 2863449,
"responseChildren": [],
"visibility": "INHERITED",
"securityScheme": {},
"callbacks": ""
}