Zum Hauptinhalt springen

Cloudflare AI Gateway

Cloudflare AI Gateway sitzt vor Provider-APIs und ermöglicht es Ihnen, Analysen, Caching und Kontrollen hinzuzufügen. Für Anthropic verwendet OpenClaw die Anthropic Messages API über Ihren Gateway-Endpunkt.
  • Provider: cloudflare-ai-gateway
  • Basis-URL: https://gateway.ai.cloudflare.com/v1/<account_id>/<gateway_id>/anthropic
  • Standardmodell: cloudflare-ai-gateway/claude-sonnet-4-5
  • API-Schlüssel: CLOUDFLARE_AI_GATEWAY_API_KEY (Ihr Provider-API-Schlüssel für Anfragen über das Gateway)
Für Anthropic-Modelle verwenden Sie Ihren Anthropic-API-Schlüssel.

Schnellstart

  1. Legen Sie den Provider-API-Schlüssel und die Gateway-Details fest:
openclaw onboard --auth-choice cloudflare-ai-gateway-api-key
  1. Legen Sie ein Standardmodell fest:
{
  agents: {
    defaults: {
      model: { primary: "cloudflare-ai-gateway/claude-sonnet-4-5" },
    },
  },
}

Nicht interaktives Beispiel

openclaw onboard --non-interactive \
  --mode local \
  --auth-choice cloudflare-ai-gateway-api-key \
  --cloudflare-ai-gateway-account-id "your-account-id" \
  --cloudflare-ai-gateway-gateway-id "your-gateway-id" \
  --cloudflare-ai-gateway-api-key "$CLOUDFLARE_AI_GATEWAY_API_KEY"

Authentifizierte Gateways

Wenn Sie die Gateway-Authentifizierung in Cloudflare aktiviert haben, fügen Sie den Header cf-aig-authorization hinzu (zusätzlich zu Ihrem Provider-API-Schlüssel).
{
  models: {
    providers: {
      "cloudflare-ai-gateway": {
        headers: {
          "cf-aig-authorization": "Bearer <cloudflare-ai-gateway-token>",
        },
      },
    },
  },
}

Hinweis zur Umgebung

Wenn das Gateway als Daemon läuft (launchd/systemd), stellen Sie sicher, dass CLOUDFLARE_AI_GATEWAY_API_KEY diesem Prozess zur Verfügung steht (zum Beispiel in ~/.openclaw/.env oder über env.shellEnv).