Cloudflare AI Gateway

See how Cloudflare AI Gateway unifies AI infrastructure with caching, rate limiting, and observability across any model provider โ€” all at the edge.

โšก

Edge Caching

Cache AI responses at 345+ cities globally. Reduce latency and costs by serving repeated queries from the edge.

๐Ÿ›ก๏ธ

Rate Limiting

Control costs with per-user and global rate limits. Prevent abuse and manage API quotas effortlessly.

๐Ÿ“Š

Real-time Analytics

Monitor token usage, latency, error rates, and cache hit ratios from a unified dashboard.

๐Ÿ”Œ

Multi-Provider

Route to Workers AI, OpenAI, Anthropic, or any provider. Switch models without changing your application.

AI Gateway Connected
Model: llama-3.1-8b-instruct
๐Ÿค–

Hello! I'm running through Cloudflare AI Gateway. Ask me anything about Cloudflare, cybersecurity, or how AI Gateway can help your business.

AI Gateway โ€ข Just now
Press Enter to send โ€ข Responses powered by Cloudflare Workers AI

๐Ÿงญ Gateway Analytics

LIVE
Status Active
Cache Status โ€”
Latency โ€”
Input Tokens โ€”
Output Tokens โ€”
Request ID โ€”
๐Ÿ–ฅ๏ธ Client
โ†’
โšก Edge
โ†’
๐Ÿค– AI

Each request flows through Cloudflare's global network, enabling caching, analytics, and security policies before reaching the AI model.

How It Works

Worker Route through AI Gateway
// Cloudflare Worker โ†’ AI Gateway
const response = await fetch(
  `https://gateway.ai.cloudflare.com/v1/
    ${ACCOUNT_ID}/${GATEWAY}/workers-ai/
    @cf/meta/llama-3.1-8b-instruct`,
  {
    method: 'POST',
    headers: { 
      'Authorization': `Bearer ${TOKEN}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      messages: [{ role: 'user', content: prompt }]
    })
  }
);

// Response includes:
// cf-aig-cache-status: HIT | MISS
// cf-aig-request-id: unique-id
// Analytics available in dashboard
Dashboard AI Gateway Analytics
Cache Hit Rate: 78%
Avg Latency: 145ms
Success Rate: 99.9%
Tokens/sec: 1,240

Ready to unify your AI infrastructure?

Deploy AI Gateway in minutes and gain visibility, control, and cost optimization across all your AI providers.

๐Ÿ“– Documentation