Responses
OpenAI 风格的 Responses 接口适合以更统一的输入结构发起文本生成请求,也便于后续承载多模态输入。
请求地址
POST
鉴权方式
使用 Bearer Token 认证,在请求头中传入 API Key:
Authorization:Bearer YOUR_API_KEY
会话 ID(可选)
为提升上游提示词缓存命中率,建议在每个请求中通过以下任一请求头传入真实且稳定的用户会话 ID;同时传入多个时,按下列顺序取第一个非空值:
X-Client-User-Id:YOUR_REAL_USER_SESSION_IDX-Claude-Code-Session-Id:YOUR_REAL_USER_SESSION_IDSession-Id:YOUR_REAL_USER_SESSION_ID
请求示例
首版文档展示文本输入场景。业务侧可继续沿用统一的 API Key 和模型命名。
curl https://api.0xtoken.cn/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "X-Claude-Code-Session-Id: YOUR_REAL_USER_SESSION_ID" \
-d '{
"model": "deepseek-v4-pro",
"input": "Hello!"
}'请求体示例
一个启用深度思考(thinking)的完整请求体:
{
"model": "deepseek-v4-pro",
"input": "证明根号 2 是无理数。",
"thinking": {
"type": "enabled",
"budget_tokens": 4096
},
"stream": false
}请求字段
| Field | Type | Description |
|---|---|---|
| model | string | 模型 ID。 |
| input | string | array<object> | 可选。输入内容,可以是字符串或消息数组。 |
| instructions | string | 可选。系统指令,用于指导模型整体行为。 |
| max_output_tokens | integer | 可选。最大输出 Token 数。 |
| temperature | number | 可选,默认 1。采样温度,值越高随机性越强,值越低结果越稳定。 |
| top_p | number | 可选,默认 1。核采样(Nucleus Sampling)参数,与 temperature 二选一调节即可。 |
| stream | boolean | 可选,默认 false。是否启用流式响应。 |
| tools | array<object> | 可选。可供模型调用的工具列表。 |
| tool_choice | string | object | 可选。指定模型如何选择工具调用。 |
| thinking | object | 可选。深度思考(Thinking)配置,仅支持推理模型。见下方子字段。 |
| thinking.type | "enabled" | "disabled" | 是否启用深度思考。enabled 启用,disabled 禁用。 |
| thinking.budget_tokens | integer | 可选。深度思考预算 Token 数,仅 thinking.type=enabled 时生效。 |
| reasoning | object | 可选。推理模型相关配置(如推理强度),与 thinking 同义,建议优先使用 thinking。 |
| reasoning.effort | "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | 可选。思考强度档位。none 表示不思考,其余档位表示思考强度。与 thinking.type 同义,冲突时以 thinking.type=disabled 为准。 |
| previous_response_id | string | 可选。上一轮 Response 的 ID,用于继续对话或关联上下文。 |
| truncation | "auto" | "disabled" | 可选,默认 disabled。上下文截断策略。auto 自动截断超出上下文长度的内容,disabled 不自动截断,超出限制时返回错误。 |
thinking 字段说明
thinking 用于控制深度思考(扩展思考链),结构与 Anthropic Messages 接口保持一致:
"thinking": {
"type": "enabled", // enabled 启用深度思考,disabled 禁用
"budget_tokens": 0 // 深度思考预算 Token 数,type=enabled 时生效
}
是否思考的判定规则
平台按以下规则判定一次请求是否启用深度思考:
thinking.type = "disabled"或reasoning.effort = "none":不思考- 其余情况(未设置、
thinking.type = "enabled"、reasoning.effort为minimal/low/medium/high/xhigh/max等):默认思考
当 thinking.type 与 reasoning.effort 同时出现且语义冲突时,以显式的 thinking.type = "disabled" 为准(关闭思考),reasoning.effort 的隐含启用不再覆盖显式关闭。
默认 max_tokens
当请求未显式传入 max_output_tokens 时,平台会根据 reasoning.effort(与 thinking 同义)的推理深度自动填充默认的输出 Token 上限。显式传入则以用户值为准,不再覆盖。
| reasoning.effort | 默认 max_output_tokens | 倍率 |
|---|---|---|
| none | 5120 | — |
| minimal | 8192 | 0.25x |
| low | 16384 | 0.5x |
| medium(或未设置) | 32768 | 1x |
| high | 65536 | 2x |
| xhigh / max | 65536 | 2x |
注:该默认值仅影响"输出 Token 上限",深度思考的实际消耗另由
thinking.budget_tokens控制。
响应字段
| Field | Type | Description |
|---|---|---|
| id | string | 本次响应的唯一标识。 |
| object | string | 对象类型,固定为 response。 |
| created_at | integer | 响应创建的 Unix 时间戳(秒)。 |
| status | string | 响应状态,例如 completed、incomplete。 |
| model | string | 生成该响应所用的模型 ID。 |
| output | array<object> | 响应输出项列表,按 reasoning → message → function_call 顺序排列。 |
| output[].type | string | 输出项类型:reasoning(深度思考)、message(消息)、function_call(工具调用)。 |
| output[] (reasoning).summary | array<object> | 深度思考摘要,summary[].type 为 summary_text,summary[].text 为思考内容。 |
| output[] (message).role | string | 消息角色,固定为 assistant。 |
| output[] (message).status | string | 消息状态,completed 或 incomplete(拒绝时)。 |
| output[] (message).content | array<object> | 消息内容块,content[].type 为 output_text,content[].text 为正文。 |
| output[] (function_call).call_id | string | 工具调用 ID。 |
| output[] (function_call).name | string | 工具名称。 |
| output[] (function_call).arguments | string | 工具调用参数(JSON 字符串)。 |
| output_text | string | 可选。message 项正文的便捷聚合,等价于拼接 output 中 message 内容块的文本。 |
| usage | object | 可选。本次请求的 Token 用量统计,见下方子字段。 |
| usage.input_tokens | integer | 输入 Token 数。 |
| usage.output_tokens | integer | 输出 Token 数。 |
| usage.total_tokens | integer | 输入与输出 Token 总数。 |
| usage.input_tokens_details.cached_tokens | integer | 可选。命中缓存的输入 Token 数。 |
| usage.output_tokens_details.reasoning_tokens | integer | 可选。深度思考消耗的 Token 数。 |
响应示例
启用深度思考后的非流式响应,output 中先返回 reasoning 项(思考摘要),再返回 message 项(正文),reasoning_tokens 为思考消耗:
{
"id": "resp_1xtoken",
"object": "response",
"created_at": 1753305600,
"status": "completed",
"model": "deepseek-v4-pro",
"output": [
{
"id": "rs_1xtoken",
"type": "reasoning",
"summary": [
{ "type": "summary_text", "text": "要证明根号 2 是无理数,使用反证法……" }
]
},
{
"id": "msg_1xtoken",
"type": "message",
"role": "assistant",
"status": "completed",
"content": [
{ "type": "output_text", "text": "假设根号 2 是有理数,则可表示为最简分数 p/q……矛盾,故根号 2 为无理数。", "annotations": [] }
]
}
],
"output_text": "假设根号 2 是有理数,则可表示为最简分数 p/q……矛盾,故根号 2 为无理数。",
"usage": {
"input_tokens": 12,
"output_tokens": 180,
"total_tokens": 192,
"input_tokens_details": {
"cached_tokens": 6
},
"output_tokens_details": {
"reasoning_tokens": 120
}
}
}