Claude Opus 4.7 迁移说明
HyperAI Relay 的默认模型已经切到 claude-opus-4-7。我们继续保持透明代理:请求体不做“兼容清洗”,上游 Anthropic 返回什么错误,我们就按原样转给你。这样最不容易在新特性发布时把问题藏起来。
推荐请求形态
from anthropic import Anthropic
client = Anthropic(
base_url="https://api.hyper-ailab.com",
api_key="sk-relay-v1-...",
)
msg = client.messages.create(
model="claude-opus-4-7",
max_tokens=8192,
thinking={"type": "adaptive"},
output_config={"effort": "high"},
messages=[{"role": "user", "content": "Review this patch and list the real risks."}],
)
关键变化
- 模型 ID:默认使用
claude-opus-4-7。官方说明 Opus 4.7 支持 1M context、128k max output、adaptive thinking,并保持 Opus 4.6 的工具和平台能力集合。 - Thinking:Opus 4.7 只支持 adaptive thinking。不要再传
thinking: {"type": "enabled", "budget_tokens": ...}。 - Effort:需要 thinking 时显式传
thinking: {"type": "adaptive"}和output_config.effort。建议从high开始,复杂 agent/coding 任务再上调。 - Sampling:不要传非默认
temperature、top_p、top_k。Opus 4.7 对这些采样参数更严格,上游会返回 400。 - Interleaved thinking:使用 adaptive thinking 时自动启用,不需要再额外传旧 beta header。
- Tokenizer / 计数:不要用旧模型的本地 token 估算做硬判断。实际计费以 Anthropic 响应里的
usage为准,HyperAI Relay 也是按该字段入账。
我们不会做什么
我们不会把旧请求自动改写成新请求。例如:
{
"model": "claude-opus-4-7",
"thinking": {"type": "enabled", "budget_tokens": 32000}
}
这个请求会继续发到 Anthropic,然后返回官方 400。理由很简单:中转层如果偷偷改请求,会让你以为自己的客户端已经兼容 4.7,但真实生产行为其实被我们掩盖了。
迁移检查表
- 把默认 model 从旧 Opus 切到
claude-opus-4-7 - 删除
budget_tokens - 需要思考时改成
thinking: {"type": "adaptive"} - 需要控制深度时加
output_config: {"effort": "high"} - 删除非默认 sampling 参数
- 用一次真实请求确认客户端能正确处理
usage和上游 400 错误