Skip to content

统一 Thinking / Reasoning

无论 Model Group 背后路由到哪个 Provider 或模型,都使用同一套 thinking/reasoning 约定。不管这个 Model Group 路由到 OpenAI、Anthropic、Google 还是其他任何 Provider,都发送同样的 reasoning 对象即可——你不需要知道底层 backend 原生参数叫什么、长什么样。

请求:reasoning 参数

在任意 chat completion 请求中发送顶层 reasoning 对象:

json
{
  "model": "reasoning",
  "reasoning": {
    "effort": "medium",
    "max_tokens": 8000
  },
  "messages": [{ "role": "user", "content": "..." }]
}

字段说明

字段类型说明
enabledbooleanfalse 关闭 thinking,等效于 effort: "none"
effortstring"none" | "low" | "medium" | "high" | "xhigh"
max_tokensnumber模型可用于推理的最大 token 数(thinking budget)
excludebooleantrue 时,要求模型不在响应中包含 thinking 内容

所有字段均可选。reasoning: {} 空对象即以该 Model Group 的默认配置启用 thinking。

关闭 thinking

json
{ "reasoning": { "enabled": false } }

或:

json
{ "reasoning": { "effort": "none" } }

响应:统一输出格式

无论实际由哪个 backend 处理请求,推理文本总是返回在同一个位置:

choices[n].message.reasoning   (非流式)
choices[n].delta.reasoning     (流式)

两者均为纯 string。当模型没有产生 thinking 输出时,该字段省略(不设为 null"")。

非流式

json
{
  "choices": [{
    "message": {
      "role": "assistant",
      "content": "答案是 42。",
      "reasoning": "让我一步步分析..."
    },
    "finish_reason": "stop"
  }]
}

流式

data: {"choices":[{"delta":{"reasoning":"让我一步"},"index":0}]}
data: {"choices":[{"delta":{"reasoning":"步分析"},"index":0}]}
data: {"choices":[{"delta":{"content":"答案是 42。"},"index":0}]}
data: {"choices":[{"delta":{},"finish_reason":"stop","index":0}]}

reasoning delta 和 content delta 在不同 chunk 中发送,每个 chunk 最多包含 delta.reasoningdelta.content 之一。


Model Group 的默认策略与强制策略

每个 Model Group 都有自己的 thinking 策略,由管理它的人一次性配置好,这样调用方不需要在每次请求里都传 reasoning(甚至不需要知道有这个参数)就能得到一致的行为。

策略包含三部分:

字段类型说明
mode"default" | "force"见下文
enabledboolean策略生效时 thinking 是否开启
budget_tokensnumber开启时的 thinking budget,默认 1024

mode: "default"——只有当调用方完全没有传 reasoning 时,Model Group 的策略才会生效;只要调用方传了 reasoning,就按调用方传的执行。没有配置过策略的 Model Group 默认就是这个模式:thinking 默认开启,budget 为 1024 token,除非调用方另行指定。

mode: "force"——Model Group 的策略始终生效,会覆盖调用方传入的任何值。用它可以保证某个专门用于复杂分析的 Model Group 始终开启 thinking,或者某个追求速度和成本的 Model Group 始终关闭 thinking,不受单次调用方请求的影响。

由于这个策略是在请求到达任何 backend 之前、按 Model Group 解析好的,调用方只需要对接同一套 reasoning 约定,完全不需要知道——也不需要和其他调用方协调——哪些 Model Group 配置了强制策略、哪些没有。

ModelPlane 面向多模型、多 Provider 和 Coding Plan 场景的使用文档。