POST https://geekapis.com/v1/responses 是 OpenAI 推出的新一代 Agentic 接口,相比传统 Chat Completions 提供了更强大的能力:内置工具(联网搜索)、自定义函数调用、服务端自动维护多轮上下文(previous_response_id)以及精细化推理力度控制(reasoning.effort)。
Responses Only 模型 以下模型仅支持 Responses API ,不支持 Chat Completions 接口,调用时请使用本端点:
gpt-5-pro-official
gpt-5.3-codex-official
完整模型列表及支持的接口类型请参阅模型一览 。
Bearer Token 认证。在请求头中添加: Authorization: Bearer YOUR_API_KEY
前往 API Key 管理页面 获取您的 API Key。
请求参数
模型名称。 示例:"gpt-5-pro-official"、"gpt-5.3-codex-official"、"gpt-5.2-official"
input
string | object[]
required
用户输入,支持两种格式:
字符串 :简单的单轮文本输入
消息数组 :多轮对话格式
消息角色:user、assistant 或 developer。
content
string | object[]
required
消息内容,支持纯文本字符串或包含图片的内容块数组。
系统指令,指导模型行为,等同于 Chat Completions 中的 system 消息。
是否启用流式输出(Server-Sent Events)。
核采样概率阈值。范围:0 ~ 1。建议不要同时修改 temperature 和 top_p。
上一次响应的 id,用于服务端自动拼接多轮对话上下文。使用此字段后无需客户端自行传递完整历史消息。
推理配置,控制模型的思考深度。 推理力度,可选值:high、medium、low、none。 值越高,模型思考越深入,消耗的 reasoning tokens 越多,响应时间也更长。
可用工具列表,模型可在响应中调用这些工具。 工具类型:
function:自定义函数调用
web_search_preview:内置联网搜索
函数名称,type 为 function 时必填。
函数参数的 JSON Schema 定义,type 为 function 时使用。
工具选择策略:
auto:由模型自行决定是否调用工具
none:禁止调用任何工具
required:强制调用至少一个工具
响应字段
响应的唯一标识符,可直接用作下次请求的 previous_response_id 以延续对话。
响应状态:completed(已完成)/ failed(失败)/ in_progress(处理中)。
输出项列表,可能包含以下一种或多种类型: 输出类型:
message:文本回复
function_call:函数调用请求
reasoning:推理过程(reasoning.effort 非 none 时出现)
web_search_call:联网搜索调用记录
消息角色,type 为 message 时为 assistant。
内容块列表,type 为 message 时包含。
content[].type:output_text
content[].text:生成的文本内容
函数名称,type 为 function_call 时包含。
函数调用参数(JSON 字符串),type 为 function_call 时包含。
token 消耗统计。 输出 token 详情,包含 reasoning_tokens(推理消耗的 token 数)。
代码示例
cURL(基础请求)
cURL(联网搜索)
cURL(多轮对话)
Python (openai SDK)
JavaScript (openai SDK)
curl --request POST \
--url https://geekapis.com/v1/responses \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-5.3-codex-official",
"instructions": "你是一个专业的代码助手",
"input": "用 Python 写一个快速排序"
}'
响应示例
{
"id" : "resp_abc123" ,
"object" : "response" ,
"status" : "completed" ,
"model" : "gpt-5.3-codex-official" ,
"output" : [
{
"type" : "message" ,
"role" : "assistant" ,
"content" : [
{
"type" : "output_text" ,
"text" : "```python \n def quicksort(arr): \n if len(arr) <= 1: \n return arr \n pivot = arr[len(arr) // 2] \n left = [x for x in arr if x < pivot] \n middle = [x for x in arr if x == pivot] \n right = [x for x in arr if x > pivot] \n return quicksort(left) + middle + quicksort(right) \n ```"
}
]
}
],
"usage" : {
"input_tokens" : 25 ,
"output_tokens" : 80 ,
"total_tokens" : 105
}
}
{
"id" : "resp_def456" ,
"object" : "response" ,
"status" : "completed" ,
"model" : "gpt-5.3-codex-official" ,
"output" : [
{
"type" : "function_call" ,
"name" : "get_weather" ,
"arguments" : "{ \" city \" : \" 北京 \" , \" unit \" : \" celsius \" }"
}
],
"usage" : {
"input_tokens" : 40 ,
"output_tokens" : 15 ,
"total_tokens" : 55
}
}
错误码
HTTP 状态码 说明 解决方案 400请求参数错误(如模型不支持该接口) 确认所用模型支持 Responses API,检查参数格式 401身份验证失败 检查 Authorization 头中的 API Key 是否有效 429请求频率超限 降低并发请求数或实现退避重试策略