认证
OpenClaw 支持模型 providers 的 OAuth 与 API keys。对 Anthropic 账号,推荐使用 API key。若使用 Claude 订阅,请使用claude setup-token 生成的长效 token。
完整 OAuth 流程与存储布局见 /concepts/oauth。
推荐的 Anthropic 配置(API key)
若直接使用 Anthropic,请使用 API key。- 在 Anthropic Console 创建 API key。
- 将其放在gateway 主机上(运行
openclaw gateway的机器)。
- 若 Gateway 由 systemd/launchd 运行,建议将 key 放入
~/.openclaw/.env以便 daemon 读取:
openclaw onboard。
有关 env 继承细节参见 Help(env.shellEnv、~/.openclaw/.env、systemd/launchd)。
Anthropic:setup-token(订阅认证)
对 Anthropic,推荐路径是 API key。若使用 Claude 订阅,亦支持 setup-token。请在gateway 主机上运行:auth-profiles.json 并更新配置):
1,即将过期退出码 2):
claude setup-token 需要交互式 TTY。
检查模型认证状态
控制使用哪份凭据
按会话(聊天命令)
使用/model <alias-or-id>@<profileId> 固定当前会话的 provider 凭据(示例 profile ids:anthropic:default、anthropic:work)。
使用 /model(或 /model list)查看紧凑选择器;/model status 查看完整视图(候选 + 下一 auth profile,以及配置时的 provider endpoint 细节)。
按 agent(CLI 覆盖)
为某个 agent 设置显式 auth profile 顺序覆盖(存入该 agent 的auth-profiles.json):
--agent <id> 指定目标 agent;省略则使用默认 agent。
排查
”No credentials found”
若缺少 Anthropic token profile,请在gateway 主机运行claude setup-token,再复查:
Token 即将过期/已过期
运行openclaw models status 查看哪个 profile 即将过期。若 profile 缺失,重新运行 claude setup-token 并再次粘贴。
要求
- Claude Max 或 Pro 订阅(用于
claude setup-token) - 安装 Claude Code CLI(可用
claude命令)