【Claude】API Error: 400 thinking options type cannot be disabled when reasoning_effort is set
目录
2.2、resoning_effort参数(Deepseek / OpenAI格式)
一、报错场景
在Win11系统VSCode接入Claude Code for VS Code 2.1.170插件配置第三方API为deepseek-v4-pro后,使用发现报错:
API Error: 400 thinking options type cannot be disabled when reasoning_effort is set
二、原因分析
这个报错的核心是两个 API 参数的语义冲突:thinking 和 reasoning_effort。
2.1、thinking参数(Anthropic原生)
Claude Code 按 Anthropic API 规范发送请求,其中 thinking 是 Claude 扩展思考功能的控制参数:
{
"thinking": {
"type": "enabled",
"budget_tokens": 16000
}
}
或者:
或者:
{
"thinking": {
"type": "disabled"
}
}
2.2、resoning_effort参数(Deepseek / OpenAI格式)
DeepSeek 模型(如 deepseek-v4-pro)不支持 Anthropic 原生的 thinking 参数,而是使用 reasoning_effort(推理力度)来控制模型的思考深度。当模型本身是推理模型时,reasoning_effort 默认处于启用状态。
2.3、冲突如何产生
CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS 是 Claude Code 的一个开关,禁用所有实验性 Beta 功能。Anthropic 提供这个开关主要是给企业用户用的,目的是在生产环境中避免不受控的实验性行为。
当设置CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS = 1后,Claude Code会:①禁用扩展思考(extended thinking)——在 API 请求中发送 thinking: {type: "disabled"},告诉模型不要做深度推理;②禁用其他实验性特性——如某些新的工具、workflow、prompt 策略等尚未正式发布的 Beta 功能。
当你设置了 CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 这个环境变量时,Claude Code 会主动在请求中加入:
{
"thinking": {
"type": "disabled"
}
}
但你的 API 后端是 DeepSeek(ANTHROPIC_BASE_URL: "https://api.deepseek.com/anthropic"),使用模型 deepseek-v4-pro。DeepSeek 的 API 在收到这个请求时:
① 内部将模型默认的 reasoning_effort 设为启用状态(因为 v4-pro 是推理模型);
② 同时收到了 thinking.type = disabled;
③ 校验逻辑判定:推理力度已经开启,不能同时禁用思考 → 返回 400 错误
故而:Claude Code 按 Anthropic 的规矩说"别思考",但 DeepSeek 的推理模型天生就要思考,双方逻辑互斥,就报了 400。
2.4、流程示意图
Claude Code DeepSeek API
| |
| thinking: { type: "disabled" } |
| -----------------------------------> |
| |
| deepseek-v4-pro 默认 reasoning_effort 开启
| thinking.type=disabled 与之冲突 |
| |
| 400: thinking cannot be disabled |
| <----------------------------------- |
| when reasoning_effort is set |
三、解决方案
3.1、方案一:移除环境变量(推荐)
删除 CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS 环境变量。
Windows:
1. 打开"系统属性" → "环境变量"
2. 在用户变量和系统变量中分别查找 CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS
3. 删除该变量
4. 重启 VSCode
或用命令行:
[System.Environment]::SetEnvironmentVariable("CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS", $null, "User")
[System.Environment]::SetEnvironmentVariable("CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS", $null, "Machine")
macOS / Linux:
unset CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS
# 并从 ~/.zshrc / ~/.bashrc 中移除对应的 export 语句
3.2、方案二:切换到非推理模型
如果你确实需要保留 CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1,可以将模型切换为不带推理能力的模型,例如将 deepseek-v4-pro 改为 deepseek-v4-flash。
①可以在C:\Users\Admin\.claude\settings.json中修改对应参数:
{
"env": {
"ANTHROPIC_MODEL": "deepseek-v4-flash",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "deepseek-v4-flash",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "deepseek-v4-flash"
}
}
②可以重新配置CCSwitch,将所有模型都选为deepseek-v4-flash。
非推理模型没有 reasoning_effort 参数,不会产生冲突。
3.3、方案三:将thinking设置为enabled
如果你能控制请求中 thinking 参数的值,将其设为 enabled 而非 disabled,则可以与 reasoning_effort 共存:
{
"thinking": {
"type": "enabled",
"budget_tokens": 16000
}
}
但这需要修改 Claude Code 的源码或通过 hook 注入。
四、适用场景
这个错误常见于以下配置:
| 场景 | 说明 |
| DeepSeek API + deepseek-v4-pro | 推理模型默认启用 reasoning_effort |
| DeepSeek API + deepseek-reasoner | 推理模型默认启用 reasoning_effort |
| 其他推理模型代理方案 | 任何 Claude Code 路由到非 Anthropic 推理模型时均可能出现 |
更多推荐


所有评论(0)