Anthropic (Claude)

Anthropic は Claude モデルファミリーを構築し、API を介してアクセスを提供しています。OpenClaw では、API キーまたは setup-token で認証できます。

オプション A: Anthropic API キー

最適な用途: 標準的な API アクセスと使用量ベースの課金。 Anthropic Console で API キーを作成してください。

CLI セットアップ

openclaw onboard
# 選択: Anthropic API key

# または非対話的に
openclaw onboard --anthropic-api-key "$ANTHROPIC_API_KEY"

設定スニペット

{
  env: { ANTHROPIC_API_KEY: "sk-ant-..." },
  agents: { defaults: { model: { primary: "anthropic/claude-opus-4-5" } } }
}

プロンプトキャッシング(Anthropic API)

OpenClaw は、設定しない限り Anthropic のデフォルトキャッシュ TTL(Time To Live:生存期間)を上書きしません。 これは API のみです。サブスクリプション認証は TTL 設定を考慮しません。

モデルごとに TTL を設定するには、モデルの paramscacheControlTtl を使用します:

{
  agents: {
    defaults: {
      models: {
        "anthropic/claude-opus-4-5": {
          params: { cacheControlTtl: "5m" } // または "1h"
        }
      }
    }
  }
}

OpenClaw は Anthropic API リクエストに extended-cache-ttl-2025-04-11 ベータフラグを含めます。プロバイダヘッダーを上書きする場合は、これを保持してください(/gateway/configuration を参照)。

オプション B: Claude setup-token

最適な用途: Claude サブスクリプションの使用。

setup-token の取得方法

setup-token は Anthropic Console ではなく、Claude Code CLI によって作成されます。これは任意のマシンで実行できます:

claude setup-token

トークンを OpenClaw に貼り付けます(ウィザード:Anthropic token (paste setup-token))。または、ゲートウェイホストで実行します:

openclaw models auth setup-token --provider anthropic

別のマシンでトークンを生成した場合は、貼り付けます:

openclaw models auth paste-token --provider anthropic

CLI セットアップ

# オンボーディング中に setup-token を貼り付ける
openclaw onboard --auth-choice setup-token

設定スニペット

{
  agents: { defaults: { model: { primary: "anthropic/claude-opus-4-5" } } }
}

注意事項

  • claude setup-token で setup-token を生成して貼り付けるか、ゲートウェイホストで openclaw models auth setup-token を実行してください。
  • Claude サブスクリプションで "OAuth token refresh failed …" が表示される場合は、setup-token で再認証してください。/gateway/troubleshooting#oauth-token-refresh-failed-anthropic-claude-subscription を参照してください。
  • 認証の詳細と再利用ルールは /concepts/oauth にあります。

トラブルシューティング

401 エラー / トークンが突然無効になる

  • Claude サブスクリプション認証は期限切れまたは取り消される可能性があります。claude setup-token を再実行し、ゲートウェイホストに貼り付けてください。
  • Claude CLI ログインが別のマシンにある場合は、ゲートウェイホストで openclaw models auth paste-token --provider anthropic を使用してください。

No API key found for provider "anthropic"

  • 認証はエージェントごとです。新しいエージェントはメインエージェントのキーを継承しません。
  • そのエージェントのオンボーディングを再実行するか、ゲートウェイホストで setup-token / API キーを貼り付け、openclaw models status で確認してください。

No credentials found for profile anthropic:default

  • openclaw models status を実行して、どの認証プロファイルがアクティブかを確認してください。
  • オンボーディングを再実行するか、そのプロファイルの setup-token / API キーを貼り付けてください。

No available auth profile (all in cooldown/unavailable)

  • openclaw models status --jsonauth.unusableProfiles を確認してください。
  • 別の Anthropic プロファイルを追加するか、クールダウンを待ってください。

詳細: /gateway/troubleshooting および /help/faq