认证
模型认证:OAuth、API 密钥、setup token
OpenClaw supports OAuth and API keys for model providers. For Anthropic accounts, we recommend using an **API key**. For Claude subscription access, use the long-lived token created by claude setup-token.
Anthropic 关于是 API 密钥 推荐执行。Claude 的订阅利用在是、claude setup-token 在创建已执行長期令牌使用执行。
OAuth 的全体流程和保存布局是 /concepts/oauth 请参阅。
推荐 Anthropic 设置(API 密钥)
If you're using Anthropic directly, use an API key.
- Anthropic Console 在 API 密钥创建执行。
- Gateway 主机(
openclaw gateway运行执行机器)在设置执行。
export ANTHROPIC_API_KEY="..." openclaw models status
If the Gateway runs under systemd/launchd, prefer putting the key in ~/.openclaw/.env so the daemon can read it:
cat >> ~/.openclaw/.env <<'EOF' ANTHROPIC_API_KEY=... EOF
然后重启守护进程(或重启您的 Gateway 进程)并重新检查:
openclaw models status openclaw doctor
If you'd rather not manage env vars yourself, the onboarding wizard can store API keys for daemon use: openclaw onboard.
env 継承的详情是 帮助(env.shellEnv、~/.openclaw/.env、systemd/launchd)请参阅。
Anthropic: setup-token (subscription auth)
For Anthropic, the recommended path is an **API key**. If you're using a Claude subscription, the setup-token flow is also supported. Run it on the **gateway host**:
claude setup-token
然后将其粘贴到 OpenClaw:
openclaw models auth setup-token --provider anthropic
如果令牌是在另一台机器上创建的,请手动粘贴:
openclaw models auth paste-token --provider anthropic
如果您看到类似以下的 Anthropic 错误:
This credential is only authorized for use with Claude Code and cannot be used for other API requests.
…use an Anthropic API key instead.
手动令牌输入(任意提供商;auth-profiles.json 在写机入见、设置更新):
openclaw models auth paste-token --provider anthropic openclaw models auth paste-token --provider openrouter
Automation-friendly check (exit 1 when expired/missing, 2 when expiring):
openclaw models status --check
Optional ops scripts (systemd/Termux) are documented here: [/automation/auth-monitoring](/automation/auth-monitoring)
Tutorial.alert.info
claude setup-token 在是対話的 TTY 需要。模型认证状态确认
openclaw models status openclaw doctor
使用执行认证信息控制执行
凭据选择取决于上下文。有效的优先级顺序为:
- 会话固定:
/model <alias-or-id>@<profileId> - 代理上写机:
openclaw models auth order ... --agent <id> - 如果没有覆盖,则使用提供商默认值
Use /model status to see candidates and which auth profile will be used next.
会话単位(聊天命令)
/model <alias-or-id>@<profileId> 在现在会话的提供商认证信息固定执行(示示例:anthropic:default、anthropic:work)。
Use /model (or /model list) for a compact picker; use /model status for the full view (candidates + next auth profile, plus provider endpoint details when configured).
代理単位(CLI 上写机)
为代理设置明确的身份验证配置文件顺序覆盖(存储在该代理的 auth-profiles.json 中):
openclaw models auth order get --provider anthropic openclaw models auth order set --provider anthropic anthropic:default openclaw models auth order clear --provider anthropic
Use --agent <id> to target a specific agent; omit it to use the configured default agent.
故障排除
"No credentials found"
If the Anthropic token profile is missing, run claude setup-token on the **gateway host**, then re-check:
- If using API key, confirm the Gateway process can read
ANTHROPIC_API_KEY. - If using setup-token, rerun
claude setup-tokenand paste fromopenclaw models auth setup-token --provider anthropic. - 如果您已经有令牌字符串,请使用
openclaw models auth paste-token --provider anthropic。
那个後再确认:
openclaw models status
Token expiring/expired
Run openclaw models status to confirm which profile is expiring. If the profile is missing, rerun claude setup-token and paste the token again.
要件
- Claude Max 或 Pro 订阅(
claude setup-token用) - Claude Code CLI 但安装済见(
claude命令但利用可能)