AI Gateway - Get started with AI Gateway automatically
Key Points
- Single API call auto-creates gateway
- Use gateway ID 'default' with no setup
- Requires AI Gateway Read/Edit and Workers AI Read
Summary
You can start using Cloudflare AI Gateway with a single API call — no pre-provisioning required. Use the gateway ID default and the gateway will be created automatically on the first request. The endpoint provides unified access to multiple AI providers and adds Cloudflare features like logging, caching, and rate limiting.
Key Points
- Auto-create gateway on first request by using the gateway ID
default. - Endpoint format: https://gateway.ai.cloudflare.com/v1/$CLOUDFLARE_ACCOUNT_ID/default/compat/chat/completions
- Required API token permissions:
AI Gateway - Read,AI Gateway - Edit, andWorkers AI - Read. - Built-in platform features: logging, caching, rate limiting, and multi-provider routing through a single endpoint.
Quick start
Replace $CLOUDFLARE_ACCOUNT_ID and $CLOUDFLARE_API_TOKEN, then run:
curl -X POST "https://gateway.ai.cloudflare.com/v1/$CLOUDFLARE_ACCOUNT_ID/default/compat/chat/completions" \
--header "cf-aig-authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--header 'Content-Type: application/json' \
--data '{
"model": "workers-ai/@cf/meta/llama-3.3-70b-instruct-fp8-fast",
"messages": [{ "role": "user", "content": "What is Cloudflare?" }]
}'
Notes
- Ensure the API token includes the three permissions listed above.
- Use the
defaultID to avoid manual gateway setup. For customization and more details, see the Cloudflare AI Gateway documentation (Get started).