OpenClawSkills
GitHub
Gateway / 运用 • TutorialHeader.readTime

认证

模型认证: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 请参阅。

Tutorial.step

推荐 Anthropic 设置(API 密钥)

If you're using Anthropic directly, use an API key.

  1. Anthropic Console 在 API 密钥创建执行。
  2. Gateway 主机(openclaw gateway 运行执行机器)在设置执行。
Bash
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:

Bash
cat >> ~/.openclaw/.env <<'EOF'
ANTHROPIC_API_KEY=...
EOF

然后重启守护进程(或重启您的 Gateway 进程)并重新检查:

Bash
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)请参阅。

Tutorial.step

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**:

Bash
claude setup-token

然后将其粘贴到 OpenClaw:

Bash
openclaw models auth setup-token --provider anthropic

如果令牌是在另一台机器上创建的,请手动粘贴:

Bash
openclaw models auth paste-token --provider anthropic

如果您看到类似以下的 Anthropic 错误:

Terminal
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 在写机入见、设置更新):

Bash
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):

Bash
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 需要。
Tutorial.step

模型认证状态确认

Bash
openclaw models status
openclaw doctor
Tutorial.step

使用执行认证信息控制执行

凭据选择取决于上下文。有效的优先级顺序为:

  • 会话固定:/model &lt;alias-or-id&gt;@&lt;profileId&gt;
  • 代理上写机:openclaw models auth order ... --agent &lt;id&gt;
  • 如果没有覆盖,则使用提供商默认值

Use /model status to see candidates and which auth profile will be used next.

Tutorial.step

会话単位(聊天命令)

/model &lt;alias-or-id&gt;@&lt;profileId&gt; 在现在会话的提供商认证信息固定执行(示示例: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).

Tutorial.step

代理単位(CLI 上写机)

为代理设置明确的身份验证配置文件顺序覆盖(存储在该代理的 auth-profiles.json 中):

Bash
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 &lt;id&gt; to target a specific agent; omit it to use the configured default agent.

Tutorial.step

故障排除

"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-token and paste from openclaw models auth setup-token --provider anthropic.
  • 如果您已经有令牌字符串,请使用 openclaw models auth paste-token --provider anthropic。

那个後再确认:

Bash
openclaw models status
Tutorial.step

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.

Tutorial.step

要件

  • Claude Max 或 Pro 订阅(claude setup-token 用)
  • Claude Code CLI 但安装済见(claude 命令但利用可能)