OpenAI兼容-Responses
兼容性说明与限制
本接口对齐 OpenAI Responses API 规范,便于开发者快速适配集成;仅文档说明参数会正常处理,未定义参数会被过滤并可能返回请求异常,具体差异化约束见下文。
- 不兼容参数:暂不支持
background、previous_response_id、store、context_management等字段,请求中携带此类参数会被忽略或触发报错。
授权
- Security Scheme Type: http
- HTTP Authorization Scheme: Bearer API_key,用于验证账户信息,可在按量计费&资源包>API Key 管理中查看。
请求头
请求体的媒介类型,请设置为 application/json,确保请求数据的格式为 JSON
可用选项: application/json
请求体application/json
modelstring必填
模型编码,可选值:
Unisound 系列:u2-flash、u2、u2-med、u2-radimed
DeepSeek 系列:deepseek-v4-flash-0731、deepseek-v4-pro、deepseek-v4.1-flash
豆包(Doubao)系列:doubao-seed-2.1-pro、doubao-seed-2.1-turbo
腾讯混元(Hy)系列:hy4-preview、hy3
小米 MiMo 系列:mimo-v2.6-pro、mimo-v2.6-flash
Kimi 系列:kimi-k2.5、kimi-k2.6、kimi-k3
GLM 系列:glm-5.3、glm-5.2、glm-5.1、glm-5
MiniMax 系列:MiniMax-M3、MiniMax-M2.5
Qwen(通义千问)系列:qwen3.8-flash、qwen3.7-plus、qwen3.7-max、qwen3.8-max、qwen3.6-plus、qwen3.6-flash、qwen3.6-35b-a3b
inputstring | array必填
模型输入,支持以下格式:
string:纯文本,如"你好"。array:输入项数组,按对话顺序排列。
EasyInputMessageobject选填
通过 role 区分消息类型,通过 content 传递消息内容。
rolestring必填
消息角色,可选值:
user:用户消息。assistant:助手消息。system:系统消息。
contentstring | array必填
消息内容。若输入为纯文本,则为 string 类型;若输入为结构化内容数组,则为 array 类型。
role为system时,array 元素类型为input_text。role为user时,array 元素类型为input_text或input_image。role为assistant时,array 元素类型为output_text。
typestring必填
内容类型。可选值:
input_text:文本输入。input_image:图片输入(仅user角色)。output_text:助手回复(仅assistant角色)。
textstring选填
文本内容。当 type 为 input_text 或 output_text 时必填。
image_urlstring选填
图片的 URL 或 Base64 Data URL。当 type 为 input_image 时必填。Base64 请传入完整 Data URI,例如:data:image/png;base64,...。
detailstring选填
图片细节级别,可选值:auto / low / high。
typestring选填
可选,固定为 message。
ResponseOutputMessageobject选填
模型的输出消息对象。可直接将上一轮响应 output 中的 message 项传回 input,用于多轮对话。与 EasyInputMessage 的区别在于携带完整输出结构(含 id、status 和结构化 content)。
typestring必填
固定为 message。
idstring必填
输出消息的唯一标识,来自上一轮响应。
rolestring必填
固定为 assistant。
statusstring必填
消息状态,可选值:in_progress、completed、incomplete。
contentarray必填
内容数组,元素为 output_text 类型对象。
typestring必填
固定为 output_text。
textstring必填
回复文本。
Function Callobject选填
模型决定调用外部工具时生成的结构化指令。
typestring必填
固定为 function_call。
call_idstring必填
工具调用标识符,需与模型返回的 call_id 一致。
namestring必填
工具函数名称。
argumentsstring必填
工具调用参数,JSON 字符串格式。
idstring选填
Function Call 的唯一标识,来自上一轮响应。
statusstring选填
状态,可选值:in_progress、completed、incomplete。
Function Call Outputobject选填
工具调用的输出结果。在消息列表中必须紧跟对应的 function_call 消息,否则会报错。
typestring必填
固定为 function_call_output。
call_idstring必填
工具调用标识符,需与模型返回的 call_id 一致。
outputstring必填
工具函数的执行结果。
idstring选填
Function Call Output 的唯一标识。
statusstring选填
状态,可选值:in_progress、completed、incomplete。
Reasoningobject选填
模型的思考内容。可直接将上一轮响应 output 中的 reasoning 项传回 input,用于在多轮对话中传递思考内容。
typestring必填
固定为 reasoning。
idstring必填
思考内容的唯一标识,来自上一轮响应。
summaryarray必填
思考摘要内容。
typestring必填
固定为 summary_text。
textstring必填
摘要文本。
statusstring选填
状态,可选值:in_progress、completed、incomplete。
instructionsstring选填
作为系统指令插入到上下文的起始位置。
streamboolean选填默认值: false
是否以流式输出方式回复。
false:模型生成全部内容后一次性返回;true:边生成边输出,每生成一部分内容即返回一个数据块(chunk)。需实时逐个读取这些块以拼接完整回复。
推荐设置为true,可提升阅读体验并降低超时风险。
storeboolean选填
不支持。响应中恒为 store: false。
max_output_tokensinteger选填
最大输出 Token(含推理 Token)。
temperaturefloat选填
采样温度,控制模型生成文本的多样性。temperature越高,生成的文本更多样,反之,生成的文本更确定。
取值范围:[0,2)。
temperature默认值:1.0。
top_pfloat选填
核采样概率阈值,控制生成多样性。与 temperature 建议二选一。
取值 (0, 1.0]。
默认值由模型决定。
toolsarray选填
包含一个或多个工具对象的数组,供模型在 Function Calling 中调用。每个工具对象直接包含 type、name、description、parameters(平铺,不嵌套 function)。
设置 tools 且模型判断需要调用工具时,响应在 output 中返回 type 为 function_call 的项(含 call_id、name、arguments);执行后可将结果以 function_call_output 传回 input。
typestring必填
工具类型,当前仅支持设为 function。
namestring必填
工具名称。仅允许字母、数字、下划线(_)和短划线(-),最长 64 个 Token。
descriptionstring必填
工具描述信息,帮助模型判断何时以及如何调用该工具。
parametersobject选填默认值: {}
工具的参数描述,需要是一个合法的 JSON Schema。
parameters 参数为空,表示该工具没有入参(如时间查询工具)。为提高工具调用的准确性,建议传入 parameters。tool_choicestring | object选填默认值: auto
工具选择策略。若需对某类问题强制指定工具调用方式,可设置此参数。
auto:模型自主决定是否调用工具;none:禁止调用任何工具;required:强制调用工具(适合tools列表仅有一个工具时);{"type": "function", "name": "<工具名>"}:强制调用指定工具。
reasoning.effort 非 none)不支持强制调用某个工具。parallel_tool_callsboolean选填
是否并行工具调用。
reasoningobject选填
控制模型的思考强度。
effortstring选填
控制模型的推理力度,不同模型支持的可选值和默认值不同。
| 模型 | 默认值 | 支持的档位 | 其余档位的映射 |
|---|---|---|---|
qwen3.8-max、qwen3.8-flash | xhigh | none、low、medium、xhigh | minimal 映射为 low;high、max 映射为 xhigh |
deepseek-v4-flash-0731 | high | none、low、high、max | minimal 映射为 low;medium 映射为 high;xhigh 映射为 max |
deepseek-v4.1-flash | high | none、low、high、max | minimal 映射为 low;medium 映射为 high;xhigh 映射为 high;ultra 映射为 max |
doubao-seed-2.1-pro、doubao-seed-2.1-turbo | high | none、minimal、low、medium、high、xhigh、max | none 映射为 minimal;minimal 映射为关闭思考;xhigh、max 映射为 high |
hy4-preview | high | none、high | — |
hy3 | high | none、low、high | — |
mimo-v2.6-pro、mimo-v2.6-flash | — | none 及其它档位 | none:关闭思考;其它档位均开启思考且行为一致,现阶段不区分推理强度 |
glm-5.3 | max | low、high、max | minimal 映射为 low;medium 映射为 high;xhigh 映射为 max |
glm-5.2、deepseek-v4-pro | high | none、high、max | minimal、low、medium 映射为 high;xhigh 映射为 max |
u2-med、u2-radimed | high | none、minimal、low、medium、high、xhigh | max 映射为 xhigh |
u2、u2-flash | high | none、minimal、low、medium、high、xhigh | max 映射为 xhigh |
glm-5.3 推荐使用 max 档位。
设置上述可选值及映射值以外的值将会报错。
reasoning.effort 是 OpenAI 标准参数。通过 Python SDK 调用时,直接传入 reasoning={"effort": "high"},无需放入 extra_body。textobject选填
返回内容的格式控制。
formatobject选填
输出格式配置。
typestring必填
text.format.type 返回内容的格式,可选值:
text:输出文字回复;json_object:输出标准格式的 JSON 字符串。
json_object,instructions 或 input 中的 system / user 文本必须包含 "JSON" 关键词(不区分大小写),否则 API 会报错。reasoning.effort 非 none)时请勿将 text.format.type 设为 json_object,否则会报错。Qwen 系列:qwen3.7-plus、qwen3.7-max、qwen3.8-max、qwen3.8-flash
Qwen 系列(非思考模式):qwen3.6-plus、qwen3.6-flash、qwen3.6-35b-a3b
DeepSeek 系列:deepseek-v4-flash-0731、deepseek-v4-pro、deepseek-v4.1-flash
豆包(Doubao)系列:doubao-seed-2.1-pro、doubao-seed-2.1-turbo
腾讯混元(Hy)系列:hy4-preview、hy3
小米 MiMo 系列:mimo-v2.6-pro、mimo-v2.6-flash
Kimi 系列:kimi-k2.5、kimi-k2.6、kimi-k3
GLM 系列:glm-5.1
GLM 系列(非思考模式):glm-5
top_logprobsinteger选填默认值: 0
指定在每一步生成时,返回模型最大概率的候选 Token 个数。
取值范围:[0,5]。
响应结构(非流式,HTTP 200)
idstring
顶层对象 object 固定为 "response"。
本次响应的唯一标识符。
objectstring
对象类型,固定为 response。
created_atinteger
本次请求的 Unix 时间戳(秒)。
statusstring
响应生成状态。枚举值:
completed:生成完成。failed:生成失败。in_progress:生成中。queued:请求排队中。incomplete:生成不完整。
modelstring
用于生成响应的模型 ID。
outputarray
模型生成的输出项数组。数组中的元素类型和顺序取决于模型响应;常见为 message(最终回复)。也可包含 reasoning、function_call 等项,具体以实际返回为准。
读取正文:遍历 output,对 type === "message" 的项,拼接 content 中 type === "output_text" 的 text(或使用 SDK 的 output_text)。
assistant 文本object
消息类型输出项,包含模型最终生成的回复内容。
typestring
输出项类型,固定为 message。
idstring
输出项的唯一标识符。
rolestring
消息角色,固定为 assistant。
statusstring
输出项状态,常见为 completed(完成)、in_progress(生成中)。
contentarray
消息内容数组。仅当 type 为 message 时存在。
typestring
内容类型,固定为 output_text。
textstring
模型生成的文本内容。
usageobject | null
本次请求的 Token 消耗信息。
input_tokensinteger
输入 Token 数(含缓存命中部分),口径同 Chat 的 prompt_tokens。
input_tokens_detailsobject
输入 Token 的细粒度分类。
cached_tokensinteger
命中缓存的输入 Token 数,是 input_tokens 的子集(已计入 input_tokens,展示时勿从总量中重复扣减)。
output_tokensinteger
模型输出 Token 数(可含推理 Token)。
output_tokens_detailsobject
输出 Token 的细粒度分类。
reasoning_tokensinteger
思考过程 Token 数,是 output_tokens 的子集(已计入 output_tokens,按推理 Token 计费口径以实际账单为准)。
total_tokensinteger
消耗的总 Token 数,一般为 input_tokens + output_tokens。
input_tokens=1000、cached_tokens=600、output_tokens=200(其中 reasoning_tokens=50)→ total_tokens=1200(展示时不要把 input_tokens 显示为 400,也不要把 output_tokens 显示为 150)。errorobject | null
当模型生成响应失败时返回的错误对象;成功时为 null。
incomplete_detailsobject | null
status 为 incomplete 时的原因说明。
storeboolean
是否持久化本次响应。平台侧不支持 store,响应中恒为 false。
错误响应(HTTP 4xx/5xx 或 body 内 error)
error.messagestring
OpenAI 风格:
错误描述。
error.typestring
如 invalid_request_error。
error.codestring
业务错误码(可选)。
error.paramstring
关联参数名(可选)。
流式说明(`stream=true`)
- 响应为 SSE,按行解析
event:/data:。 - 文本增量常见事件:`response.output_text.delta`,`data` 中含 `delta` 字段。
- 结束常见事件:`response.completed` / `response.incomplete` / `response.failed`,终态 `data` 中带完整 `response` 与 `usage`(字段口径与非流式一致)。
- 事件类型完整列表见 OpenAI Responses 流式事件。
event: response.output_text.delta
data: {"type":"response.output_text.delta","item_id":"msg_example","delta":"你好"}错误示例(缺少 model)
{
"error": {
"message": "model is required",
"type": "invalid_request_error",
"param": "model",
"code": "invalid_parameter"
}
}