ModelSiteAPI

Responses(OpenAI)

POST /v1/responses — OpenAI Responses API,按场景给出完整示例

OpenAI 较新的 Responses API(/v1/responses)。上游原生支持 Responses 的模型,请求与响应基本原样透传;其余模型由平台转换为 Chat Completions 走同一路由管线,再把响应转回 Responses 格式。适合用 OpenAI 新 SDK 的 responses 接口的代码。

本页按「场景」组织:先看场景总览,再到对应小节看请求、响应和注意事项。每个示例都标注了证据:已实测表示用线上测试账号真实调用过(2026-10-19),响应字段取自真实返回,id、时间戳、文本等取值替换为占位;依官方文档(未实测)表示按 OpenAI 官方文档写成,我们没有真实调用验证。

同一个模型的响应形态可能不同:一个模型可能同时有原生和转换两类上游,每次请求落在哪类由路由决定。实测 glm-5.3-flash 的两次请求分别拿到了两种形态:原生形态带有大量回显字段(background、tools、top_p 等)和上游自有字段;转换形态没有上游自有字段。转换形态已按官方形态对齐:每个事件带 sequence_number,id 以 resp_ 开头,响应对象回显请求参数,思考用 summary,output 里思考在前。两种形态读取方式相同:用 output[] 和 usage,不要依赖回显字段的具体取值。本页的示例会注明属于哪种形态。

场景总览

场景划分参照 OpenAI 官方的 Text generation、Streaming、Function calling、Structured outputs、Reasoning、Images and vision、Conversation state、Tools 等指南。

场景官方是否提供我们的情况示例入口
基础对话(input 字符串、instructions)是支持基础对话
多轮对话(input 数组带历史、developer / user 角色)是支持多轮对话
流式输出是支持流式输出
函数调用(function_call / function_call_output)是支持函数调用
结构化输出(text.format 的 json_schema)是支持结构化输出
推理(reasoning)是支持推理
图像输入(input_image)是部分支持:需视觉模型;base64 已实测,公网 URL 未实测,不支持 file_id图像输入
有状态续接(previous_response_id、conversation)是不支持:平台不保存响应。实测带 previous_response_id 的请求,模型看不到上一轮内容;多轮请自己带完整 input—
内置工具(web_search、file_search、code_interpreter、computer_use、mcp、image_generation)是不支持:转换路径只保留 function / custom,其余内置工具被丢弃;web_search 会转成 web_search_options,实测对已上线模型没有联网效果—
自定义工具与文法约束(custom 工具、CFG)是部分支持:custom 转成只有一个字符串参数的函数,不支持文法约束;未实测—
后台任务与 Webhook(background)是不支持:转发给上游,没有 Responses 语义,不会后台执行—
对话压缩(/v1/responses/compact)是部分支持:端点存在,未实测—
取回 / 删除 / 取消(GET、DELETE、cancel)是部分支持:只对原生上游创建的响应有效,见「其他方法」—

基础对话

何时用:一问一答;用 instructions 设定角色和语气。

证据:已实测(线上测试账号,2026-10-19)。响应是原生形态。

请求

curl https://api.modelsite.ai/v1/responses \
  -H "Authorization: Bearer $MODELSITE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-5.3-flash",
    "input": "用一句话解释量子纠缠",
    "instructions": "用中文回答,简洁",
    "max_output_tokens": 1500
  }'

响应

取回复文本:output[] 里 type 为 message 的项的 content[].text(SDK 的 output_text 已帮你拼好);状态看 status(completed / incomplete;被截断时 incomplete_details.reason 为 max_output_tokens,被内容安全拦截时为 content_filter);用量看 usage。

{
  "background": false,
  "created_at": 1760000000,
  "ec_transfer_params": null,
  "error": null,
  "frequency_penalty": 0.0,
  "id": "resp_xxxx",
  "incomplete_details": null,
  "input_messages": null,
  "instructions": "用中文回答,简洁",
  "max_output_tokens": 1500,
  "max_tool_calls": null,
  "metadata": null,
  "model": "glm-5.3-flash",
  "object": "response",
  "output": [
    {
      "id": "msg_xxxx",
      "content": [
        {
          "annotations": [],
          "text": "# 量子纠缠\n\n量子纠缠是指两个或多个粒子形成一种特殊的量子关联状态,无论相距多远,测量其中一个粒子的状态会瞬间确定另一个粒子的状态。……",
          "type": "output_text",
          "logprobs": null
        }
      ],
      "role": "assistant",
      "status": "completed",
      "type": "message",
      "phase": null
    }
  ],
  "output_messages": null,
  "parallel_tool_calls": true,
  "presence_penalty": 0.0,
  "previous_response_id": null,
  "prompt": null,
  "reasoning": null,
  "service_tier": "auto",
  "status": "completed",
  "temperature": 1,
  "text": null,
  "tool_choice": "none",
  "tools": [],
  "top_logprobs": null,
  "top_p": 0.95,
  "truncation": "disabled",
  "usage": {
    "input_tokens": 23,
    "input_tokens_details": { "cached_tokens": 0 },
    "output_tokens": 91,
    "output_tokens_details": { "reasoning_tokens": 0 },
    "total_tokens": 114
  },
  "user": null
}

注意事项

  • temperature、top_p、tool_choice 等是上游对你请求的回显或默认值(例如没传工具时 tool_choice 显示 none),不代表平台改写了你的请求。
  • 响应里的 model 是你请求的模型名,id 是平台编码过的 resp_ ID。
  • 下面的接口卡片由 OpenAPI 规范自动渲染(Request body 参数表、Response schema)。
POST
/responses

Authorization

BearerAuth
AuthorizationBearer <token>

Authorization: Bearer $MODELSITE_API_KEY

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/responses" \  -H "Content-Type: application/json" \  -d '{    "model": "string",    "input": "string"  }'

取回复:output[] 里 type 为 message 的项。上游原生支持 Responses 时是这种带回显字段的形态;取自线上真实响应(glm-5.3-flash,2026-10-19),取值为占位。

{  "background": false,  "created_at": 1760000000,  "ec_transfer_params": null,  "error": null,  "frequency_penalty": 0,  "id": "resp_xxxx",  "incomplete_details": null,  "input_messages": null,  "instructions": "用中文回答,简洁",  "max_output_tokens": 1500,  "max_tool_calls": null,  "metadata": null,  "model": "glm-5.3-flash",  "object": "response",  "output": [    {      "id": "msg_xxxx",      "content": [        {          "annotations": [],          "text": "# 量子纠缠\n\n量子纠缠是指两个或多个粒子形成一种特殊的量子关联状态,无论相距多远,测量其中一个粒子的状态会瞬间确定另一个粒子的状态。\n\n**通俗类比**:就像一双“魔法手套”分别寄到地球两端,你打开盒子看到左手套的瞬间,就知道另一端是右手套——但量子纠缠更神奇,手套在被打开前连“左右”都还没确定。",          "type": "output_text",          "logprobs": null        }      ],      "role": "assistant",      "status": "completed",      "type": "message",      "phase": null    }  ],  "output_messages": null,  "parallel_tool_calls": true,  "presence_penalty": 0,  "previous_response_id": null,  "prompt": null,  "reasoning": null,  "service_tier": "auto",  "status": "completed",  "temperature": 1,  "text": null,  "tool_choice": "none",  "tools": [],  "top_logprobs": null,  "top_p": 0.95,  "truncation": "disabled",  "usage": {    "input_tokens": 23,    "input_tokens_details": {      "cached_tokens": 0    },    "output_tokens": 91,    "output_tokens_details": {      "reasoning_tokens": 0    },    "total_tokens": 114  },  "user": null}

多轮对话

何时用:需要上下文的连续对话。平台不保存响应,每次请求把完整历史放进 input 数组;也可以用 developer 角色放指令。

证据:依官方文档(未实测)。带工具的多轮(function_call 回填)已实测,见函数调用。

请求

curl https://api.modelsite.ai/v1/responses \
  -H "Authorization: Bearer $MODELSITE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-5.3-flash",
    "input": [
      {"role": "developer", "content": "用中文回答,简洁"},
      {"role": "user", "content": "什么是量子纠缠?"},
      {"role": "assistant", "content": "两个粒子的状态相互关联,与距离无关。"},
      {"role": "user", "content": "它能用来超光速通信吗?"}
    ],
    "max_output_tokens": 1500
  }'

响应:与基础对话相同的结构。

注意事项

  • 转换路径下,input 数组只转换 message(含只有 role + content 的简写)、function_call、function_call_output、custom_tool_call、custom_tool_call_output;reasoning 项被跳过,item_reference、image_generation_call 等其他类型被丢弃。
  • 不要依赖 previous_response_id 续接,见场景总览。

流式输出

何时用:逐 token 展示、降低首字延迟。

证据:已实测(线上测试账号,2026-10-19)。事件序列是原生形态。

请求

curl -N https://api.modelsite.ai/v1/responses \
  -H "Authorization: Bearer $MODELSITE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-5.3-flash",
    "input": "只回复一个字:好",
    "stream": true,
    "reasoning": {"effort": "low"},
    "max_output_tokens": 600
  }'

响应

每个事件是 event: + data: 两行;拼接 response.output_text.delta 的 delta 得到文本;以 response.completed 结束,用量在其 response.usage 里。没有 [DONE]。每个事件带递增的 sequence_number。

event: response.created
data: {"response":{"id":"resp_xxxx","created_at":1760000000,"model":"glm-5.3-flash","object":"response","output":[],"status":"in_progress","usage":null, ...回显字段同基础响应...},"sequence_number":0,"type":"response.created"}

event: response.in_progress
data: {"response":{ ...同上... },"sequence_number":1,"type":"response.in_progress"}

event: response.output_item.added
data: {"item":{"id":"rs_xxxx","summary":[],"type":"reasoning","content":null,"encrypted_content":null,"status":"in_progress"},"output_index":0,"sequence_number":2,"type":"response.output_item.added"}

event: response.reasoning_part.added
data: {"content_index":0,"item_id":"rs_xxxx","output_index":0,"part":{"text":"","type":"reasoning_text"},"sequence_number":3,"type":"response.reasoning_part.added"}

event: response.reasoning_text.delta
data: {"content_index":0,"delta":"User wants exactly one character: \"好\".","item_id":"rs_xxxx","output_index":0,"sequence_number":4,"type":"response.reasoning_text.delta"}

event: response.reasoning_text.done
data: {"content_index":0,"item_id":"rs_xxxx","output_index":0,"sequence_number":8,"text":"User wants exactly one character: \"好\".","type":"response.reasoning_text.done"}

event: response.reasoning_part.done
data: {"content_index":0,"item_id":"rs_xxxx","output_index":0,"part":{"text":"User wants exactly one character: \"好\".","type":"reasoning_text"},"sequence_number":9,"type":"response.reasoning_part.done"}

event: response.output_item.done
data: {"item":{"id":"rs_xxxx","summary":[],"type":"reasoning","content":[{"text":"User wants exactly one character: \"好\".","type":"reasoning_text"}],"encrypted_content":null,"status":"completed"},"output_index":0,"sequence_number":10,"type":"response.output_item.done"}

event: response.output_item.added
data: {"item":{"id":"msg_xxxx","content":[],"role":"assistant","status":"in_progress","type":"message","phase":null},"output_index":1,"sequence_number":11,"type":"response.output_item.added"}

event: response.content_part.added
data: {"content_index":0,"item_id":"msg_xxxx","output_index":1,"part":{"annotations":[],"text":"","type":"output_text","logprobs":[]},"sequence_number":12,"type":"response.content_part.added"}

event: response.output_text.delta
data: {"content_index":0,"delta":"好","item_id":"msg_xxxx","logprobs":[],"output_index":1,"sequence_number":13,"type":"response.output_text.delta"}

event: response.output_text.done
data: {"content_index":0,"item_id":"msg_xxxx","logprobs":[],"output_index":1,"sequence_number":14,"text":"好","type":"response.output_text.done"}

event: response.content_part.done
data: {"content_index":0,"item_id":"msg_xxxx","output_index":1,"part":{"annotations":[],"text":"好","type":"output_text","logprobs":null},"sequence_number":15,"type":"response.content_part.done"}

event: response.output_item.done
data: {"item":{"id":"msg_xxxx","content":[{"annotations":[],"text":"好","type":"output_text","logprobs":null}],"role":"assistant","status":"completed","type":"message","phase":null,"summary":[]},"output_index":1,"sequence_number":16,"type":"response.output_item.done"}

event: response.completed
data: {"response":{"id":"resp_xxxx","status":"completed","model":"glm-5.3-flash","output":[ ...同 output_item.done 的两项... ],"usage":{"input_tokens":18,"input_tokens_details":{"cached_tokens":0,"input_tokens_per_turn":[],"cached_tokens_per_turn":[]},"output_tokens":12,"output_tokens_details":{"reasoning_tokens":9,"tool_output_tokens":0,"output_tokens_per_turn":[],"tool_output_tokens_per_turn":[]},"total_tokens":30}, ...},"sequence_number":17,"type":"response.completed"}

注意事项

  • 原生形态下,思考以 response.reasoning_text.* 事件出现,位于 output_index: 0,正文在 output_index: 1。转换路径下,思考以官方的 response.reasoning_summary_part.added、response.reasoning_summary_text.delta、response.reasoning_summary_text.done、response.reasoning_summary_part.done 事件出现(依代码和单元测试,未做线上实测)。两种形态的思考位置不同,按事件类型读取,不要写死下标。
  • 转换路径的 output_index 按出现顺序从 0 递增:有思考时思考是 0;只调用工具、没有文字时没有 message 项;每个项在下一个项开始前先发 output_item.done。
  • 流式请求在转换路径下自动开启 include_usage,用量在 response.completed 里。
  • 流已经开始输出后失败,错误会作为流内事件发出,见下方「错误」。

函数调用

何时用:让模型决定调用你定义的函数。流程:声明 tools → 模型返回 function_call 项 → 你执行 → 在下一次请求的 input 里放回这个 function_call 项和一个 function_call_output 项(用 call_id 对应)→ 模型给出最终回答。

证据:已实测(线上测试账号,2026-10-19):单个调用与回填结果(原生形态)。tool_choice 各取值、并行调用、流式 function_call_arguments 事件依官方文档(未实测)。

请求(第一轮)

curl https://api.modelsite.ai/v1/responses \
  -H "Authorization: Bearer $MODELSITE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-5.3-flash",
    "input": "杭州明天天气怎么样?",
    "tools": [{
      "type": "function",
      "name": "get_weather",
      "description": "Get the current weather for a city",
      "parameters": {
        "type": "object",
        "properties": {"city": {"type": "string"}},
        "required": ["city"]
      }
    }],
    "max_output_tokens": 1500
  }'

响应(第一轮)

工具调用是 output[] 里 type 为 function_call 的项;arguments 是 JSON 字符串。下面只列 output 和 usage,其余字段同基础对话(tools 里会回显你声明的工具,tool_choice 为 auto)。

{
  "id": "resp_xxxx",
  "object": "response",
  "status": "completed",
  "model": "glm-5.3-flash",
  "output": [
    {
      "id": "rs_xxxx",
      "summary": [],
      "type": "reasoning",
      "content": [
        { "text": "The user is asking about the weather in Hangzhou… (已省略)", "type": "reasoning_text" }
      ],
      "encrypted_content": null,
      "status": null
    },
    {
      "arguments": "{\"city\": \"杭州\"}",
      "call_id": "chatcmpl-tool-xxxxxxxx",
      "name": "get_weather",
      "type": "function_call",
      "id": "fc_xxxx",
      "caller": null,
      "namespace": null,
      "status": "completed"
    }
  ],
  "usage": {
    "input_tokens": 160,
    "output_tokens": 95,
    "total_tokens": 255,
    "input_tokens_details": { "cached_tokens": 0 },
    "output_tokens_details": { "reasoning_tokens": 83 }
  }
}

回填工具结果(第二轮)

curl https://api.modelsite.ai/v1/responses \
  -H "Authorization: Bearer $MODELSITE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-5.3-flash",
    "input": [
      {"role": "user", "content": "杭州明天天气怎么样?"},
      {"type": "function_call", "call_id": "chatcmpl-tool-xxxxxxxx", "name": "get_weather", "arguments": "{\"city\": \"杭州\"}"},
      {"type": "function_call_output", "call_id": "chatcmpl-tool-xxxxxxxx", "output": "多云 7~13°C"}
    ],
    "tools": [ ... 同第一轮 ... ],
    "reasoning": {"effort": "low"},
    "max_output_tokens": 1500
  }'

第二轮响应(已实测,output 只有一条 message):

{
  "id": "resp_xxxx",
  "object": "response",
  "status": "completed",
  "model": "glm-5.3-flash",
  "output": [
    {
      "id": "msg_xxxx",
      "content": [
        { "annotations": [], "text": "杭州明天天气:多云,气温 7~13°C。早晚偏凉,建议适当添衣保暖。", "type": "output_text", "logprobs": null }
      ],
      "role": "assistant",
      "status": "completed",
      "type": "message",
      "phase": null
    }
  ],
  "usage": {
    "input_tokens": 182,
    "input_tokens_details": { "cached_tokens": 0 },
    "output_tokens": 25,
    "output_tokens_details": { "reasoning_tokens": 0 },
    "total_tokens": 207
  }
}

注意事项

  • 转换路径下 custom 工具会转成只有一个字符串参数的函数,响应里再还原;tool_choice 的 allowed_tools 近似成 required(mode 为 required 时)或 auto,托管工具形式退化成 auto。
  • call_id 的格式取决于上游,原样回填即可。
  • 流式下工具调用的事件序列依官方文档:response.output_item.added(function_call)→ 多个 response.function_call_arguments.delta → response.function_call_arguments.done → response.output_item.done。

结构化输出(text.format)

何时用:要求回复严格符合你给定的 JSON Schema(Responses 里用 text.format,不是 response_format)。

证据:已实测(线上测试账号,2026-10-19,原生形态)。

请求

curl https://api.modelsite.ai/v1/responses \
  -H "Authorization: Bearer $MODELSITE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-5.3-flash",
    "input": "提取:张三,28岁,住在上海",
    "reasoning": {"effort": "low"},
    "max_output_tokens": 1500,
    "text": {
      "format": {
        "type": "json_schema",
        "name": "person",
        "strict": true,
        "schema": {
          "type": "object",
          "properties": {
            "name": {"type": "string"},
            "age": {"type": "integer"},
            "city": {"type": "string"}
          },
          "required": ["name", "age", "city"],
          "additionalProperties": false
        }
      }
    }
  }'

响应(只列 output,text.format 会在响应里回显)

"output": [
  {
    "id": "rs_xxxx",
    "summary": [],
    "type": "reasoning",
    "content": [ { "text": "Simple extraction task.", "type": "reasoning_text" } ]
  },
  {
    "id": "msg_xxxx",
    "content": [
      { "annotations": [], "text": "{\n  \"age\": 28,\n  \"city\": \"上海\",\n  \"name\": \"张三\"\n}", "type": "output_text", "logprobs": null }
    ],
    "role": "assistant",
    "status": "completed",
    "type": "message"
  }
]

注意事项

  • 本例输出符合 schema,字段顺序不保证。平台不在服务端校验输出,收到后仍建议自己校验;status 为 incomplete 时输出可能被截断。
  • 转换路径下,text.format 为 json_schema / json_object 时转成 response_format,verbosity 转成 verbosity,其他子字段丢弃。

推理(reasoning)

何时用:需要模型先推理再回答,或需要控制推理强度。

证据:已实测(线上测试账号,2026-10-19):reasoning.effort: "low" 的流式与非流式(原生形态)。

请求

curl https://api.modelsite.ai/v1/responses \
  -H "Authorization: Bearer $MODELSITE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-5.3-flash",
    "input": "杭州明天天气怎么样?",
    "reasoning": {"effort": "low"},
    "max_output_tokens": 1500
  }'

响应:思考过程是 output[] 里 type 为 reasoning 的项(排在 message 之前),非流式在 content[].text(type 为 reasoning_text);思考 token 数在 usage.output_tokens_details.reasoning_tokens;缓存命中在 usage.input_tokens_details.cached_tokens。真实的 reasoning 项见函数调用与结构化输出的响应,流式事件见流式输出。

注意事项

  • 不传 reasoning 时,原生形态下实测 glm-5.3-flash 没有返回 reasoning 项(reasoning_tokens 为 0);是否思考、强度取值由模型和上游决定,各模型取值见各厂商页。
  • 转换路径下 reasoning.effort 转成 reasoning_effort,max_tokens、enabled、exclude 按 Chat Completions 的思考规则归一化;summary、generate_summary 没有对应项,不起作用(响应里的 reasoning 只是回显你传的值)。转换路径的思考一律以 summary(summary_text)返回,流式与非流式一致。

图像输入

何时用:让视觉模型看图回答。需选支持图像输入的模型(如 qwen3-vl-plus)。

证据:base64 图片已实测(线上测试账号,2026-10-19,qwen3-vl-plus,转换形态);公网 URL 依官方文档(未实测)。

请求

curl https://api.modelsite.ai/v1/responses \
  -H "Authorization: Bearer $MODELSITE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3-vl-plus",
    "max_output_tokens": 300,
    "input": [{
      "role": "user",
      "content": [
        {"type": "input_text", "text": "这张图里有什么?一句话回答。"},
        {"type": "input_image", "image_url": "data:image/png;base64,iVBORw0KGgo..."}
      ]
    }]
  }'

响应(转换形态;下面只列主要字段,其余回显字段见上方「不支持或有差异的参数」)

{
  "id": "resp_xxxx",
  "object": "response",
  "created_at": 1760000000,
  "status": "completed",
  "max_output_tokens": 300,
  "model": "qwen3-vl-plus",
  "output": [
    {
      "type": "message",
      "id": "msg_xxxx",
      "status": "completed",
      "role": "assistant",
      "content": [
        { "type": "output_text", "text": "图中是一个红色的实心圆,背景为白色。" }
      ]
    }
  ],
  "usage": {
    "input_tokens": 82,
    "input_tokens_details": { "cached_tokens": 0 },
    "output_tokens": 14,
    "output_tokens_details": { "reasoning_tokens": 0 },
    "total_tokens": 96
  }
}

注意事项

  • 图像按输入 token 计费。各模型对图片尺寸、数量的限制见各厂商页。
  • 不支持 OpenAI 的 file_id(Files API)。

错误

401 密钥无效或缺失

{"error":{"type":"authentication_error","message":"invalid API key"}}

缺少 Authorization 头时 message 为 missing or invalid authorization header。

402 余额不足

{"error":{"type":"insufficient_quota","message":"insufficient balance"}}

429 触发限流

{"error":{"type":"rate_limit_error","message":"too many requests"}}

响应头带 Retry-After(秒),按它退避重试。

403 无权调用该模型

{"error":{"type":"model_access_error","message":"model 'glm-5.3-flash' is not allowed for this API key"}}

503 网关容量已满

{"error":{"type":"overloaded_error","message":"gateway at capacity, retry later"}}

同样带 Retry-After: 5。

400 模型不存在

{"error":{"type":"invalid_request_error","message":"unknown model: not-a-model"}}

model 填错或未上线时是 400(不是 404)。

400 参数错误

{"error":{"message":"<校验信息>","type":"invalid_request_error","code":"invalid_request_error"}}

路由层产生的错误多一个 code 字段(值与 type 相同)。

上游暂时不可用时可能返回 502(server_error)或 503(error.code 为 no_upstream_available),稍后重试。流式请求在已经开始输出后失败,HTTP 状态码已是 200,错误会作为流内事件发出。完整错误码与处理建议见 错误码。

其他方法

方法路径说明
GET/v1/responses列表接口,平台不保存响应,固定返回空列表
GET/v1/responses/:id取响应详情(仅对上游原生支持 Responses 的模型创建的响应有效)
DELETE/v1/responses/:id删除响应(同上)
POST/v1/responses/:id/cancel取消进行中的响应(同上)
POST/v1/responses/compact压缩响应上下文

以上方法均未实测。

大多数场景用 Chat Completions 即可;仅当现有代码强依赖 Responses API 的请求/响应格式时用本端点。注意:由平台转换的请求不支持 previous_response_id 续接和内置工具(file_search、code_interpreter、mcp 等),多轮对话请自己把完整历史放进 input。

不支持或有差异的参数

本端点有两条路径,参数行为不同。平台不会按「参数清单」丢弃参数,也不会钳制取值:除下面列出的、代码里写死的行为外,参数原样交给上游,生效、忽略还是报错(4xx)由上游决定。

  • 上游原生支持 Responses 的请求:请求体原样转发,官方字段都保留,包括平台没有建模的字段。上游返回 4xx 并指出某个顶层参数不被支持时,平台会去掉该参数后重试,最多 2 轮(input、model、instructions、stream、tools、tool_choice、previous_response_id 不会被去掉);仍失败时可能退回下面的转换路径。
  • 由平台转换的请求:请求被转成 Chat Completions,响应再转回 Responses 格式。下表是这条路径的行为。哪个模型走哪条路径由上游决定,同一个模型可能两条都有。
参数转换路径下的行为说明
instructions改写转成开头的 system 消息
input部分支持字符串,或由 message(含只有 role + content 的简写)、function_call、function_call_output、custom_tool_call、custom_tool_call_output 组成的数组。reasoning 项被跳过;item_reference、image_generation_call 等其他类型被丢弃
max_output_tokens改写转成 max_tokens
tools部分支持function 照常;custom 转成只有一个字符串参数的函数,响应里再还原;web_search / web_search_preview 转成 web_search_options(实测对已上线模型没有联网效果);file_search、computer_use、mcp、code_interpreter、image_generation 等其他内置工具被丢弃
tool_choice改写auto / none / required 原样;指定 function / custom 转成指定函数;allowed_tools 近似成 required(mode 为 required 时)或 auto;其他内置工具形式退化成 auto
reasoning部分支持effort 转成 reasoning_effort;max_tokens、enabled、exclude 按 Chat Completions 的思考规则归一化;summary、generate_summary 没有对应项,不起作用(响应只回显)
text部分支持format.type 为 json_schema / json_object 时转成 response_format,text 本身不再转发;verbosity 转成 verbosity;其他子字段丢弃
previous_response_id丢弃平台不保存响应,无法续接,多轮请自己带完整 input;响应对象只回显你传的值
truncation include max_tool_calls丢弃没有 Chat Completions 对应项
store service_tier user metadata parallel_tool_calls映射映射到同名 Chat 字段后转发;metadata 只保留字符串值
stream自动补用量stream: true 时自动开启 include_usage,用量在 response.completed 里
background conversation prompt top_logprobs stream_options context_management safety_identifier prompt_cache_key prompt_cache_retention moderation无 Responses 语义作为未知顶层字段转发给上游,不会产生 Responses 的行为(例如 background 不会让请求在后台执行)

两条路径共通:响应里的 model 是你请求的模型名,id 是平台编码过的 resp_ ID(转换路径的流式与非流式一致)。

转换路径的响应对象按官方形态回显请求参数:instructions、tools、tool_choice、temperature、top_p、max_output_tokens、parallel_tool_calls、metadata、reasoning、store、text、truncation、user、previous_response_id、max_tool_calls。没传的参数按官方默认值回显(tool_choice 为 auto、tools 为 []、parallel_tool_calls 为 true、store 为 true、truncation 为 disabled、metadata 为 {});temperature、top_p 没传时为 null。这些是请求回显,不表示上游真的采用了这些值(例如 store、truncation、previous_response_id 在转换路径被丢弃,见上表)。转换路径的响应不含上游自有字段(ec_transfer_params、input_messages、output_messages 等)。

平台扩展

下面是平台自己定义、OpenAI 官方没有的内容。

请求头:网关只放行 Authorization、Content-Type、Accept、Accept-Encoding、Origin、User-Agent、Anthropic-Beta、OpenAI-Beta,其余一律丢弃。X-Request-ID 你带的值会被沿用并回显,没带则平台生成。

响应头

响应头说明
X-Request-ID请求 ID,排查问题时提供给我们
Retry-After429 给出建议退避秒数;网关容量满返回 503 并带 Retry-After: 5
Content-Type: text/event-stream、Cache-Control: no-cache流式响应;流空闲时网关每 15 秒发一个 : heartbeat 注释帧保活,SSE 客户端会自动忽略

平台不返回 X-RateLimit-* 一类的限流额度头。

响应字段

字段说明
usage.cost、usage.cost_details非流式响应的费用字段。默认不返回,仅当你所在组织被设置为 total 或 detailed 时出现,调用方不能通过请求参数开启。金额是精确小数字符串;无法计价的请求不出现。本端点的分项名与 Chat Completions 不同:input_cost、output_cost、reasoning_cost、prompt_cache_read_cost 等,只含大于 0 的分项
output[].content[].reasoning_text(非流式)、response.reasoning_text.* / reasoning_summary_* 事件(流式)思考过程,位置因路径和模式而异,见各场景

自动行为

  • 余额在流式输出途中耗尽时,流会被切断,随后收到一个 data: {"error":{"type":"insufficient_quota","message":"balance exhausted"}} 帧和 data: [DONE]。
  • 上游失败时的自动重试、换上游规则与 Chat Completions 相同。
  • GET /v1/responses/:id、DELETE、cancel 只对原生路径创建的响应有效,见上方「其他方法」。

本页内容