Authentication
モデル認証: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 キー)
Anthropic を直接利用する場合は API キーを使ってください。
- Anthropic Console で API キーを作成します。
- Gateway ホスト(
openclaw gatewayを実行するマシン)で設定します。
export ANTHROPIC_API_KEY="..." openclaw models status
Gateway が systemd/launchd 配下で動作している場合、デーモンが読めるように ~/.openclaw/.env に入れるのが推奨です:
cat >> ~/.openclaw/.env <<'EOF' ANTHROPIC_API_KEY=... EOF
その後デーモン(または Gateway プロセス)を再起動し、再確認します:
openclaw models status openclaw doctor
環境変数を自分で管理したくない場合、オンボーディングウィザードでデーモン用の API キーを保存できます:openclaw onboard。
env 継承の詳細は ヘルプ(env.shellEnv、~/.openclaw/.env、systemd/launchd)を参照してください。
Anthropic:setup token(サブスク認可)
Anthropic は API キー が推奨です。Claude サブスクリプションを使う場合は setup-token フローも利用できます。Gateway ホストで実行します:
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.
…代わりに Anthropic API キーを使用してください。
手動トークン入力(任意プロバイダー;auth-profiles.json に書き込み、設定を更新):
openclaw models auth paste-token --provider anthropic openclaw models auth paste-token --provider openrouter
自動化向けチェック(期限切れ/欠落で 1、期限が近い場合は 2 で終了):
openclaw models status --check
オプションの運用スクリプト(systemd/Termux)はここにあります:/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> - 上書きがなければプロバイダーのデフォルト
/model status で候補と次に使われる認証プロファイルを確認できます。
セッション単位(チャットコマンド)
/model <alias-or-id>@<profileId> で現在セッションのプロバイダー認証情報を固定します(例:anthropic:default、anthropic:work)。
/model(または /model list)はコンパクトなピッカー、/model status は完全表示(候補 + 次の認証プロファイル、プロバイダーのエンドポイント詳細)です。
エージェント単位(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
--agent <id> で特定エージェントを指定できます。省略すると設定済みデフォルトエージェントを使います。
トラブルシューティング
「認証情報が見つからない」
If the Anthropic token profile is missing, run claude setup-token on the **gateway host**, then re-check:
- API キー利用なら、Gateway プロセスが
ANTHROPIC_API_KEYを読めることを確認。 - setup token 利用なら、
claude setup-tokenを再実行してからopenclaw models auth setup-token --provider anthropic。 - すでにトークン文字列がある場合は
openclaw models auth paste-token --provider anthropic。
その後再確認:
openclaw models status
トークンの期限切れ / 期限間近
openclaw models status を実行して、どのプロファイルが期限切れ(または間近)か確認します。プロファイルが欠落している場合は claude setup-token を再実行し、再度貼り付けてください。
Requirements
- Claude Max または Pro サブスクリプション(
claude setup-token用) - Claude Code CLI がインストール済み(
claudeコマンドが利用可能)