3.0 KiB
| title | summary | read_when | ||
|---|---|---|---|---|
| Cloudflare AI Gateway | Cloudflare AI Gateway setup (analytics, caching, rate limiting) |
|
Cloudflare AI Gateway
The Cloudflare AI Gateway provides visibility and control over your AI applications with features like analytics, logging, caching, rate limiting, request retries, and model fallback.
- Provider:
cloudflare-ai-gateway - Auth: Account ID + Gateway ID + API Key (optional for unauthenticated gateway)
- API: Anthropic Messages compatible (via provider-specific endpoints)
Quick start
- Set up your Cloudflare AI Gateway credentials:
openclaw onboard --auth-choice cloudflare-ai-gateway-api-key
You'll be prompted to enter:
- Cloudflare Account ID (found in your Cloudflare dashboard)
- Cloudflare AI Gateway ID (the name you give your gateway)
- Cloudflare AI Gateway API key (optional, only needed for authenticated gateways)
- Set a default model:
{
agents: {
defaults: {
model: { primary: "cloudflare-ai-gateway/anthropic/claude-sonnet-4-5" }
}
}
}
Non-interactive example
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 "your-api-key"
Setting up your Cloudflare AI Gateway
- Log into the Cloudflare dashboard
- Go to AI > AI Gateway
- Select Create Gateway
- Enter your Gateway name (this becomes your gateway ID)
- (Optional) Enable authentication for added security
Features
Analytics
View metrics such as the number of requests, tokens, and cost of running your application.
Caching
Serve requests directly from Cloudflare's cache for faster requests and cost savings.
Rate Limiting
Control how your application scales by limiting the number of requests.
Request Retry and Fallback
Improve resilience by defining request retry and model fallbacks in case of an error.
Supported Providers
Cloudflare AI Gateway works with:
- OpenAI
- Anthropic (Claude)
- Google AI Studio (Gemini)
- Azure OpenAI
- AWS Bedrock
- Workers AI
- And many more
Environment note
If the Gateway runs as a daemon (launchd/systemd), make sure credentials are available to that process (for example, in ~/.openclaw/.env or via env.shellEnv).
You can also set environment variables:
CLOUDFLARE_AI_GATEWAY_API_KEY- Your Cloudflare AI Gateway API key- Account ID and Gateway ID are stored in the auth profile metadata