推理控制

最后更新

支持推理(思考)的模型可以控制想多久、要不要返回思考内容。三种协议的原生参数都可以直接用,OpenAI Chat 另外支持一个跨模型的统一参数。

写法 协议 示例
统一参数 reasoning OpenAI Chat(兼容 OpenRouter) "reasoning": {"effort": "high"}、"reasoning": {"max_tokens": 4096}、"reasoning": {"exclude": true}
reasoning_effort OpenAI "reasoning_effort": "low"
thinking Anthropic "thinking": {"type": "enabled", "budget_tokens": 4096}
thinkingConfig Gemini "generationConfig": {"thinkingConfig": {"thinkingBudget": 4096}}
curl https://modelportal.ai/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "MODEL_ID", "reasoning": {"effort": "medium"}, "messages": [{"role": "user", "content": "证明根号 2 是无理数"}]}'

平台怎么处理

  • 统一参数由平台换成承接报价的上游参数:OpenAI 的 reasoning_effort、Anthropic 的 thinking.budget_tokens、Gemini 的 thinkingConfig。
  • thinking.budget_tokens 按预算换算档位:不超过 512 为 minimal,不超过 1024 为 low,不超过 8192 为 medium,不超过 24576 为 high,更大为 xhigh。
  • 上游不接受请求的档位时改用更高一档,高过最高档时取最高档;模型不能关闭思考时,要求关闭返回 400 unsupported_parameter。每个模型的档位对照表在模型详情页的「推理档位」一节,发生改写的调用在用量明细里会标出。
  • "exclude": true 时平台从响应里去掉 reasoning_content、reasoning、reasoning_details,但推理 tokens 照常计费。
  • 推理 tokens 计入输出 tokens,按输出单价计费,不重复收费。