Claude 5.5 / Fable 5.2 报 temperature 400 与 thinking.budget_tokens 迁移指南

Anthropic 原生 /v1/messages 在 claude-opus-5-5、claude-sonnet-5-5 与 claude-fable-5-2 上拒绝非默认 temperature/top_p/top_k 与旧版 thinking.budget_tokens;删掉采样覆盖并改用 adaptive thinking + output_config.effort 即可修复。

核心参数 说明
覆盖在售模型 ID claude-opus-5-5、claude-sonnet-5-5、claude-fable-5-2
接入端点 POST /v1/messages(首选)、POST /v1/chat/completions(兼容)
SDK Base URL https://deepclub.net(Anthropic SDK / Claude Code,不带 /v1)
计费与隐私 按百万 Token(含缓存读写),实时价格见 定价页;全站实行 ZDR 零留存

1. 为什么从旧版 Claude 升级到 5.5 / Fable 5.2 会立刻报 400?

Anthropic 在 claude-opus-5-5、claude-sonnet-5-5 与 claude-fable-5-2 上全面切换到 Adaptive Thinking(自适应思考),并在原生 POST /v1/messages 中强制执行两条新规则:

  1. 禁止传入自定义采样参数:temperature、top_p、top_k 一旦覆盖默认值即返回 400 Bad Request。
  2. 废弃旧版 thinking: {"type": "enabled", "budget_tokens": ...}:必须改为 thinking: {"type": "adaptive"},配合 output_config: {"effort": "low" | "medium" | "high" | "max"} 控制思考预算。

2. 旧代码 vs 新代码逐行迁移(Python)

import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ["DEEPCLUB_API_KEY"],
    base_url="https://deepclub.net",  # 官方 SDK 不带 /v1
)

# 新版正确写法:不传 temperature/top_p,改用 adaptive + output_config.effort
msg = client.messages.create(
    model="claude-opus-5-5",
    max_tokens=4096,
    cache_control={"type": "ephemeral"},
    thinking={"type": "adaptive", "display": "summarized"},
    output_config={"effort": "medium"},
    messages=[{"role": "user", "content": "Review this SQL migration for lock hazards."}],
)
print("".join(block.text for block in msg.content if block.type == "text"))

3. 各客户端关闭隐式 temperature 覆盖的方法

常见问题

为什么返回结果里 msg.content[0].text 会报错 AttributeError?

开启 Adaptive Thinking 后,content[0] 往往是 type="thinking" 区块而非文本区块。务必遍历所有 block 并筛选 block.type == "text"。

在 Cline / Roo Code 走 OpenAI Compatible 调 Claude 5.5 会报温度 400 吗?

深云在 /v1/chat/completions 兼容入口会自动过滤不兼容的采样参数,但原生 /v1/messages 保持协议原汁原味,因此客户端须关闭温度覆盖。

哪个 Claude 5 模型仍兼容旧版 budget_tokens 与 temperature?

claude-fable-5-1 保留了对旧版参数的兼容,但新项目建议直接按新版 adaptive 写法迁移到 opus-5-5、sonnet-5-5 或 fable-5-2。

延伸指南与排障入口

常见问题

为什么返回结果里 msg.content[0].text 会报错 AttributeError?
开启 Adaptive Thinking 后,content[0] 往往是 type="thinking" 区块而非文本区块。务必遍历所有 block 并筛选 block.type == "text"。
在 Cline / Roo Code 走 OpenAI Compatible 调 Claude 5.5 会报温度 400 吗?
深云在 /v1/chat/completions 兼容入口会自动过滤不兼容的采样参数,但原生 /v1/messages 保持协议原汁原味,因此客户端须关闭温度覆盖。
哪个 Claude 5 模型仍兼容旧版 budget_tokens 与 temperature?
claude-fable-5-1 保留了对旧版参数的兼容,但新项目建议直接按新版 adaptive 写法迁移到 opus-5-5、sonnet-5-5 或 fable-5-2。

更新于