Skip to main content
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
完整模型列表及支持的接口类型请参阅模型一览

鉴权

Authorization
string
required
Bearer Token 认证。在请求头中添加:
Authorization: Bearer YOUR_API_KEY
前往 API Key 管理页面 获取您的 API Key。

请求参数

model
string
required
模型名称。示例:"gpt-5-pro-official""gpt-5.3-codex-official""gpt-5.2-official"
input
string | object[]
required
用户输入,支持两种格式:
  • 字符串:简单的单轮文本输入
  • 消息数组:多轮对话格式
instructions
string
系统指令,指导模型行为,等同于 Chat Completions 中的 system 消息。
stream
boolean
default:"false"
是否启用流式输出(Server-Sent Events)。
max_output_tokens
integer
生成内容的最大 token 数量。
temperature
number
default:"1"
采样温度,控制输出随机性。范围:0 ~ 2
top_p
number
default:"1"
核采样概率阈值。范围:0 ~ 1。建议不要同时修改 temperaturetop_p
previous_response_id
string
上一次响应的 id,用于服务端自动拼接多轮对话上下文。使用此字段后无需客户端自行传递完整历史消息。
reasoning
object
推理配置,控制模型的思考深度。
tools
object[]
可用工具列表,模型可在响应中调用这些工具。
tool_choice
string
default:"auto"
工具选择策略:
  • auto:由模型自行决定是否调用工具
  • none:禁止调用任何工具
  • required:强制调用至少一个工具

响应字段

id
string
响应的唯一标识符,可直接用作下次请求的 previous_response_id 以延续对话。
object
string
固定为 response
status
string
响应状态:completed(已完成)/ failed(失败)/ in_progress(处理中)。
model
string
实际使用的模型名称。
output
object[]
输出项列表,可能包含以下一种或多种类型:
usage
object
token 消耗统计。

代码示例

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 写一个快速排序"
  }'

响应示例

200 - 文本响应
{
  "id": "resp_abc123",
  "object": "response",
  "status": "completed",
  "model": "gpt-5.3-codex-official",
  "output": [
    {
      "type": "message",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "```python\ndef 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
  }
}
200 - 函数调用响应
{
  "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请求频率超限降低并发请求数或实现退避重试策略