Anthropic(Claude)
Anthropic 构建 Claude 模型家族,并提供 API 访问。在 OpenClaw 中你可以使用 API key 或 setup-token 认证。方案 A:Anthropic API key
适用: 标准 API 访问与按量计费。 在 Anthropic Console 中创建 API key。CLI 设置
配置片段
提示词缓存(Anthropic API)
除非你设置,OpenClaw 不会 覆盖 Anthropic 默认的缓存 TTL。 这 仅适用于 API;订阅认证不支持 TTL 设置。 要为每个模型设置 TTL,请在模型params 中使用 cacheControlTtl:
extended-cache-ttl-2025-04-11 beta 标记;
如你覆盖 provider headers,请保留它(见 /gateway/configuration)。
方案 B:Claude setup-token
适用: 使用你的 Claude 订阅。获取 setup-token
Setup-token 由 Claude Code CLI 创建,而不是 Anthropic Console。可在 任何机器 上执行:CLI 设置
配置片段
说明
- 使用
claude setup-token生成并粘贴,或在 gateway 主机上运行openclaw models auth setup-token。 - 若 Claude 订阅出现 “OAuth token refresh failed …”,请用 setup-token 重新认证。参见 /gateway/troubleshooting#oauth-token-refresh-failed-anthropic-claude-subscription。
- 认证细节与复用规则见 /concepts/oauth。
故障排查
401 错误 / token 突然失效- Claude 订阅认证可能过期或被撤销。重新执行
claude setup-token并粘贴到 gateway 主机。 - 如果 Claude CLI 登录在另一台机器上,请在 gateway 主机上执行
openclaw models auth paste-token --provider anthropic。
- 认证是 按代理 绑定的。新代理不会继承主代理的 key。
- 为该代理重新 onboarding,或在 gateway 主机上粘贴 setup-token / API key,然后用
openclaw models status验证。
anthropic:default
- 运行
openclaw models status查看活跃的认证 profile。 - 重新 onboarding,或为该 profile 粘贴 setup-token / API key。
- 运行
openclaw models status --json查看auth.unusableProfiles。 - 添加另一个 Anthropic profile 或等待 cooldown。