驗證
OpenClaw 支援模型提供者的 OAuth 與 API 金鑰。對於 Anthropic 帳戶,我們建議使用 API 金鑰。若要存取 Claude 訂閱, 請使用由claude setup-token 建立的長效權杖。 For Anthropic
accounts, we recommend using an API key. For Anthropic
accounts, we recommend using an API key. For Claude subscription access,
use the long‑lived token created by claude setup-token.
完整的 OAuth 流程與儲存配置,請參閱 /concepts/oauth。
建議的 Anthropic 設定(API 金鑰)
若您直接使用 Anthropic,請使用 API 金鑰。- 在 Anthropic Console 建立一個 API 金鑰。
- 將它放在 Gateway 閘道器主機(執行
openclaw gateway的機器)上。
- 若 Gateway 在 systemd/launchd 下執行,建議將金鑰放在
~/.openclaw/.env,以便常駐程式可讀取:
openclaw onboard.
關於環境變數繼承(env.shellEnv、~/.openclaw/.env、systemd/launchd)的詳細資訊,請參閱 Help。
Anthropic:setup-token(訂閱身分驗證)
For Anthropic, the recommended path is an API key. 對於 Anthropic,建議使用 API key。如果您正在使用 Claude subscription, the setup-token flow is also supported. Run it on the gateway host:auth-profiles.json 並更新設定):
1 結束,將到期時以 2 結束):
claude setup-token 需要互動式 TTY。
檢查模型身分驗證狀態
控制使用哪一個憑證
依工作階段(聊天指令)
使用/model <alias-or-id>@<profileId> 為目前工作階段固定特定提供者的憑證(範例設定檔 ID:anthropic:default、anthropic:work)。
使用 /model(或 /model list)取得精簡選擇器;使用 /model status 取得完整檢視(候選項目 + 下一個身分驗證設定檔,並在已設定時顯示提供者端點細節)。
依代理程式(CLI 覆寫)
為代理程式設定明確的身分驗證設定檔排序覆寫(儲存在該代理程式的auth-profiles.json):
--agent <id> 指定特定代理程式;省略則使用已設定的預設代理程式。
Troubleshooting
「找不到任何憑證」
若缺少 Anthropic 權杖設定檔,請在 Gateway 閘道器主機 上執行claude setup-token,然後再次檢查:
Token expiring/expired
Runopenclaw 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指令)