Configure Anthropic OAuth tokens (sk-ant-oat01-*) to work with OpenClaw as API keys via environment variable injection. Use when: (1) user has OAuth tokens that fail direct API calls with authentication_error, (2) switching from proxy to Anthropic official API, (3) configuring Claude Pro/Team subscription tokens for API use. NOT for: standard API keys (sk-ant-api03-*), working proxy services, or non-Anthropic providers.
通过 OpenClaw 的 env.vars 注入,将 Anthropic OAuth 令牌(sk-ant-oat01-*)配置为可用的 API 密钥。
通过环境变量注入令牌,在提供商配置中使用 ${VAR} 引用:
bash
openclaw config patch {
env: {
vars: {
ANTHROPICAPIKEY: sk-ant-oat01-YOUR_TOKEN
}
},
models: {
providers: {
anthropic-official: {
baseUrl: https://api.anthropic.com,
apiKey: ${ANTHROPICAPIKEY},
api: anthropic-messages,
models: [
{id: claude-sonnet-4-20250514, name: Claude Sonnet 4},
{id: claude-opus-4-6, name: Claude Opus 4.6}
]
}
}
},
agents: {
defaults: {
model: {
primary: anthropic-official/claude-sonnet-4-20250514
}
}
}
}
然后重启:openclaw gateway restart
应用于单个代理(其他代理保持使用代理):
bash
openclaw config patch {
agents: {
list: [{
id: YOURAGENTID,
name: Agent Name,
workspace: /path/to/workspace,
model: {primary: anthropic-official/claude-opus-4-6}
}]
}
}
运行 session_status 或 openclaw status。查找:
| 症状 | 原因 | 修复 |
|---|---|---|
| 仍显示 custom-proxy/* | defaults.model.primary 错误 | 设置为 anthropic-official/MODEL_ID |
| 切换令牌后回退 |
关键:不要快速切换令牌。OpenClaw 会跟踪认证失败并应用冷却期。如果卡在回退状态,使用带模型参数的 session_status 强制重置:
/model anthropic-official/claude-opus-4-6
使用官方 API 的同时保留代理作为回退:
json
{
env: {vars: {ANTHROPICAPIKEY: sk-ant-oat01-xxx}},
models: {
providers: {
custom-proxy: {
baseUrl: https://your-proxy.com/,
apiKey: proxy-key,
api: anthropic-messages,
models: [{id: claude-sonnet-4-5, name: Claude Sonnet 4.5}]
},
anthropic-official: {
baseUrl: https://api.anthropic.com,
apiKey: ${ANTHROPICAPIKEY},
api: anthropic-messages,
models: [
{id: claude-sonnet-4-20250514, name: Claude Sonnet 4},
{id: claude-opus-4-6, name: Claude Opus 4.6}
]
}
}
}
}
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 oauth-disguise-1776075860 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 oauth-disguise-1776075860 技能
skillhub install oauth-disguise-1776075860
文件大小: 2.05 KB | 发布时间: 2026-4-15 13:39