Cloudflare AI Gateway
Cloudflare AI Gateway sitzt vor Provider-APIs und ermöglicht Analytics, Caching und Steuerung. Für Anthropic nutzt OpenClaw die Anthropic Messages API über deinen 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-Key:
CLOUDFLARE_AI_GATEWAY_API_KEY(dein Provider-API-Key für Anfragen über das Gateway)
Für Anthropic-Modelle verwendest du deinen Anthropic API-Key.
Schnellstart
- Provider-API-Key und Gateway-Details setzen:
openclaw onboard --auth-choice cloudflare-ai-gateway-api-key
- Standardmodell setzen:
{
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 du Gateway-Authentifizierung in Cloudflare aktiviert hast, füge den cf-aig-authorization-Header hinzu (zusätzlich zu deinem Provider-API-Key).
{
models: {
providers: {
"cloudflare-ai-gateway": {
headers: {
"cf-aig-authorization": "Bearer <cloudflare-ai-gateway-token>",
},
},
},
},
}
Umgebungshinweis
Wenn das Gateway als Daemon (launchd/systemd) läuft, stelle sicher, dass CLOUDFLARE_AI_GATEWAY_API_KEY für diesen Prozess verfügbar ist (zum Beispiel in ~/.openclaw/.env oder über env.shellEnv).