API 文档

Responses

OpenAI 风格的 Responses 接口适合以更统一的输入结构发起文本生成请求,也便于后续承载多模态输入。

请求地址

POST

鉴权方式

使用 Bearer Token 认证,在请求头中传入 API Key:

  • AuthorizationBearer YOUR_API_KEY

请求示例

首版文档展示文本输入场景。业务侧可继续沿用统一的 API Key 和模型命名。

curl https://api.1xtoken.cn/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
  "model": "deepseek-v4-pro",
  "input": "Hello!"
}'

请求体示例

一个启用深度思考(thinking)的完整请求体:

{
"model": "deepseek-v4-pro",
"input": "证明根号 2 是无理数。",
"thinking": {
  "type": "enabled",
  "budget_tokens": 4096
},
"stream": false
}

请求字段

FieldTypeDescription
modelstring模型 ID。
inputstring | array<object>可选。输入内容,可以是字符串或消息数组。
instructionsstring可选。系统指令,用于指导模型整体行为。
max_output_tokensinteger可选。最大输出 Token 数。
temperaturenumber可选,默认 1。采样温度,值越高随机性越强,值越低结果越稳定。
top_pnumber可选,默认 1。核采样(Nucleus Sampling)参数,与 temperature 二选一调节即可。
streamboolean可选,默认 false。是否启用流式响应。
toolsarray<object>可选。可供模型调用的工具列表。
tool_choicestring | object可选。指定模型如何选择工具调用。
thinkingobject可选。深度思考(Thinking)配置,仅支持推理模型。见下方子字段。
thinking.type"enabled" | "disabled"是否启用深度思考。enabled 启用,disabled 禁用。
thinking.budget_tokensinteger可选。深度思考预算 Token 数,仅 thinking.type=enabled 时生效。
reasoningobject可选。推理模型相关配置(如推理强度),与 thinking 同义,建议优先使用 thinking。
previous_response_idstring可选。上一轮 Response 的 ID,用于继续对话或关联上下文。
truncation"auto" | "disabled"可选,默认 disabled。上下文截断策略。auto 自动截断超出上下文长度的内容,disabled 不自动截断,超出限制时返回错误。

thinking 字段说明

thinking 用于控制深度思考(扩展思考链),结构与 Anthropic Messages 接口保持一致:

"thinking": {
  "type": "enabled",        // enabled 启用深度思考,disabled 禁用
  "budget_tokens": 0        // 深度思考预算 Token 数,type=enabled 时生效
}

响应字段

FieldTypeDescription
idstring本次响应的唯一标识。
objectstring对象类型,固定为 response。
created_atinteger响应创建的 Unix 时间戳(秒)。
statusstring响应状态,例如 completed、incomplete。
modelstring生成该响应所用的模型 ID。
outputarray<object>响应输出项列表,按 reasoning → message → function_call 顺序排列。
output[].typestring输出项类型:reasoning(深度思考)、message(消息)、function_call(工具调用)。
output[] (reasoning).summaryarray<object>深度思考摘要,summary[].type 为 summary_text,summary[].text 为思考内容。
output[] (message).rolestring消息角色,固定为 assistant。
output[] (message).statusstring消息状态,completed 或 incomplete(拒绝时)。
output[] (message).contentarray<object>消息内容块,content[].type 为 output_text,content[].text 为正文。
output[] (function_call).call_idstring工具调用 ID。
output[] (function_call).namestring工具名称。
output[] (function_call).argumentsstring工具调用参数(JSON 字符串)。
output_textstring可选。message 项正文的便捷聚合,等价于拼接 output 中 message 内容块的文本。
usageobject可选。本次请求的 Token 用量统计,见下方子字段。
usage.input_tokensinteger输入 Token 数。
usage.output_tokensinteger输出 Token 数。
usage.total_tokensinteger输入与输出 Token 总数。
usage.input_tokens_details.cached_tokensinteger可选。命中缓存的输入 Token 数。
usage.output_tokens_details.reasoning_tokensinteger可选。深度思考消耗的 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
  }
}
}