模型提供商认证(API Key/OAuth/Claude CLI 复用)。

注意:本页是模型提供商认证参考。Gateway 连接认证(token/password/trusted-proxy)见 concepts/gateway-runbook。

推荐设置(API Key)

# 设置 API Key
export ANTHROPIC_API_KEY="..."
openclaw models status
 
# 守护进程使用(systemd/launchd)
cat >> ~/.openclaw/.env <<'EOF'
ANTHROPIC_API_KEY=...
EOF

Anthropic 认证选项

  1. API Key(推荐,生产环境):最可预测的服务器设置
  2. Claude CLI 复用:复用本地 Claude CLI 登录(claude-cli 提供商)
  3. Setup Token:支持的 token-auth 路径

OAuth 流程

# 交互式 OAuth 登录
openclaw configure --section auth

OAuth 令牌存储在 ~/.openclaw/agents/<agentId>/agent/auth-profiles.json。

Auth Profile 轮换(故障转移)

{
  agents: {
    defaults: {
      auth: {
        profiles: ["profile1", "profile2"],
        failover: { enabled: true, cooldownMs: 60000 },
      },
    },
  },
}

模型状态检查

openclaw models status
openclaw models status --probe  # 实时探测
openclaw models list

相关

  • model-failover — Auth profile 轮换
  • oauth — OAuth 认证流程
  • concepts/gateway-secrets — SecretRef 密钥管理