One plugin, many providers — Anthropic, OpenAI, Google, Groq, Cerebras, Mistral, xAI, and more through Cloudflare's AI Gateway. Model ids take the form `provider/model-name` (e.g. `anthropic/claude-opus-4-6`), and keys live in Cloudflare's Secrets Store instead of your Worker config. Every call is cached, logged, and metered through the same AI Gateway that powers the rest of Cloudflare's platform.
Install
1 · Config
Append to ENABLED_PLUGINS in wrangler.toml:
cf-ai-gateway
Append to ALLOWED_HOSTS:
gateway.ai.cloudflare.com
2 · Secrets
Run each from your Worker project:
-
wrangler secret put AI_GATEWAY_IDGateway name you created in the dashboard. -
wrangler secret put CLOUDFLARE_ACCOUNT_IDNeeded by the compat fallback path.
Copy-paste .dev.vars template
AI_GATEWAY_ID=Gateway name you created in the dashboard. CLOUDFLARE_ACCOUNT_ID=Needed by the compat fallback path.
3 · Steps
- dash → AI → AI Gateway → Create gateway
- Store each provider key under the gateway's Provider Keys tab
- wrangler secret put AI_GATEWAY_ID