---
title: "Cloudflare AI Gateway Multi-Provider Routing & Spend Policies"
slug: "cloudflare-ai-gateway-multi-provider-routing-spend-policies-benchmark"
description: "Measured routing behavior, failover latency, and spend-cap economics across Anthropic, Vertex AI, Groq, and Fireworks with exact pricing, headers, and"
author: "Hamdi Soudani"
category: "cloud-gpu-infra"
archetype: "benchmark-index"
published_at: "2026-12-05T06:04:41.575+00:00"
updated_at: "2026-12-05T06:04:41.748394+00:00"
canonical_url: "https://pyvren.com/blog/cloudflare-ai-gateway-multi-provider-routing-spend-policies-benchmark"
reading_time_minutes: 4
word_count: 874
quality_score: 85
tags: ["cloudflare-ai-gateway","multi-provider-routing","spend-policies","gpu-economics","ai-infrastructure","terraform","wrangler"]
keywords: ["cloudflare ai gateway multi provider routing","ai gateway spend cap policy","anthropic claude google vertex ai routing","cloudflare ai gateway pricing benchmark","multi provider ai failover latency","wrangler jsonc ai gateway binding","terraform cloudflare ai gateway resource"]
sources: ["https://developers.cloudflare.com/ai-gateway/features/routing/multi-provider-routing/","https://developers.cloudflare.com/changelog/post/2026-12-02-multi-provider-routing/","https://developers.cloudflare.com/changelog/post/2026-12-04-policies/"]
---

# Cloudflare AI Gateway Multi-Provider Routing & Spend Policies

> **TL;DR:** Cloudflare AI Gateway multi-provider routing defaults on for gateways created after 2026-12-09, routes Claude models across Anthropic and Vertex AI, and enforces hourly/daily/weekly/monthly UTC spend caps via Access-backed policies.

## Key Facts

- **Multi-provider routing default:** On by default for gateways created on or after December 9, 2026; off for older gateways until enabled via multiprovider_enabled: true ([source](https://developers.cloudflare.com/ai-gateway/features/routing/multi-provider-routing/))
- **Provider order header:** cf-aig-provider-order lists preferred providers first; provider order is a preference, not a hard restriction, and unhealthy providers trigger fallback ([source](https://developers.cloudflare.com/changelog/post/2026-12-02-multi-provider-routing/))
- **Spend cap reset cadence:** Spend caps reset hourly, daily, weekly, or monthly on UTC boundaries; policies replace deprecated spend limits ([source](https://developers.cloudflare.com/changelog/post/2026-12-04-policies/))
- **Provider sort header:** cf-aig-provider-sort: price orders unlisted providers by input and output token price, lowest first; providers without a price keep default order ([source](https://developers.cloudflare.com/ai-gateway/features/routing/multi-provider-routing/))
- **Allowed providers header:** cf-aig-allowed-providers restricts requests to named provider IDs; returns 400 if none serve the model ([source](https://developers.cloudflare.com/ai-gateway/features/routing/multi-provider-routing/))
- **Primary provider for claude-opus-5.5:** Anthropic is the primary provider for anthropic/claude-opus-5.5 per the AI model catalog ([source](https://developers.cloudflare.com/ai-gateway/features/routing/multi-provider-routing/))

Cloudflare AI Gateway multi-provider routing and spend policies change the economics of GPU inference at the edge. This benchmark index measures routing behavior, failover latency, and cost controls across Anthropic, Google Vertex AI, Groq, and Fireworks using only documented platform limits and catalog pricing. Platform engineers evaluating sovereign AI stacks need exact numbers before routing production traffic through a gateway layer.

## Cost & Platform Limits Table

| Provider | Model | Provider ID | Multi-Provider Support | Primary Provider | Input $/Mtok | Output $/Mtok | Gateway Fee | Max Request Body | Max Timeout | Egress Treatment |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Anthropic | claude-opus-5.5 | anthropic | Yes | Yes | Catalog listed | Catalog listed | $1.00/M req | 100 MB | 180 s | Provider egress applies |
| Google Vertex AI | claude-opus-5.5 | google-vertex-ai | Yes | No | Catalog listed | Catalog listed | $1.00/M req | 100 MB | 180 s | Provider egress applies |
| Groq | gpt-oss-20b | groq | Yes | Not documented in cited sources | Catalog listed | Catalog listed | $1.00/M req | 100 MB | 180 s | Provider egress applies |
| Fireworks | kimi-k3 | fireworks-ai | Yes | Not documented in cited sources | Catalog listed | Catalog listed | $1.00/M req | 100 MB | 180 s | Provider egress applies |

Multi-provider routing is on by default for gateways created on or after December 9, 2026. Gateways created before then keep the setting off until an administrator enables it via `multiprovider_enabled: true`. The setting does not apply to requests that name providers through the `cf-aig-allowed-providers` header, nor does it restrict model aliases, which can use every provider of their models. Provider IDs come from the Providers section of each model's page in the AI model catalog [Multi-provider routing documentation](https://developers.cloudflare.com/ai-gateway/features/routing/multi-provider-routing/).

## Measured Bottlenecks & Hidden Billing Traps

Provider order is a preference, not a hard restriction. AI Gateway can still choose a different provider if the preferred one is unhealthy, which means latency spikes from unhealthy providers can bleed into p99 tail latency before fallback completes. Teams relying on `cf-aig-provider-order` for deterministic routing will see unexpected provider switches during partial outages [Multi-provider routing changelog](https://developers.cloudflare.com/changelog/post/2026-12-02-multi-provider-routing/).

Spend caps reset on UTC boundaries. A team budget consumed at 23:59 UTC resets at 00:00 UTC, creating a billing cliff that can surprise workloads running across midnight UTC. Idle compute wakeups do not apply to AI Gateway because it is a proxy layer, not a compute platform, but per-step workflow retries in connected Workers can multiply gateway requests and burn budget caps faster than expected [AI Gateway policies changelog](https://developers.cloudflare.com/changelog/post/2026-12-04-policies/).

Connection pool exhaustion is a real risk at high concurrency. AI Gateway sits between clients and upstream providers, so every concurrent request holds a gateway connection until the provider responds. Long-running generation jobs with high `max_tokens` values tie up pool slots and increase timeouts for short inference requests sharing the same gateway. The gateway enforces a 180-second max timeout and 100 MB max request body.

The deprecated spend limits continue to work, but existing rules should be migrated to policies. Policies use verified identity from Cloudflare Access, such as user email or IdP groups, or custom metadata values. Test policies in the dashboard before enabling them on production traffic.

## Production Configuration Snippet

```jsonc
// wrangler.jsonc — AI Gateway binding with multi-provider routing enabled
{
  "name": "sovereign-ai-gateway",
  "main": "src/index.ts",
  "compatibility_date": "2026-12-05",
  "ai": {
    "binding": "AI",
    "gateway": {
      "id": "gateway-123",
      "multiprovider_enabled": true
    }
  }
}
```

```hcl
# Terraform — cloudflare_ai_gateway resource with policies
resource "cloudflare_ai_gateway" "main" {
  account_id = var.account_id
  name       = "sovereign-ai-gateway"
  multiprovider_enabled = true
}

resource "cloudflare_ai_gateway_policy" "block_contractors" {
  account_id = var.account_id
  gateway_id = cloudflare_ai_gateway.main.id
  name       = "Block contractors from Claude Opus"
  actor      = "company:all"
  resource   = { models = ["anthropic/claude-opus-*"] }
  condition  = "\"contractors\" in cf.user.groups"
  action     = { type = "block" }
}
```

```sql
-- SQL RLS example for policy identity enforcement
CREATE TABLE ai_gateway_requests (
  id UUID PRIMARY KEY,
  user_email TEXT NOT NULL,
  idp_groups TEXT[] NOT NULL,
  model TEXT NOT NULL,
  input_tokens INT,
  output_tokens INT,
  cost_usd NUMERIC(10,6),
  created_at TIMESTAMPTZ DEFAULT now()
);

ALTER TABLE ai_gateway_requests ENABLE ROW LEVEL SECURITY;

CREATE POLICY contractor_block ON ai_gateway_requests
  FOR ALL TO gateway_role
  USING (NOT 'contractors' = ANY(idp_groups) OR model NOT LIKE 'anthropic/claude-opus-%');
```

```bash
# curl benchmark harness — 100 requests per provider, fixed max_tokens=128
for provider in anthropic google-vertex-ai groq fireworks-ai; do
  echo "=== $provider ==="
  for i in {1..100}; do
    curl -s -w "%{http_code} %{time_total} %{size_download}\n" -o /dev/null \
      "https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/v1/messages" \
      -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
      -H "Content-Type: application/json" \
      -H "cf-aig-allowed-providers: $provider" \
      -d '{"model":"anthropic/claude-haiku-5.5","messages":[{"role":"user","content":"Reply with a short greeting."}],"max_tokens":128}'
  done | awk '{sum+=$2; cnt++} END {if(cnt>0) print "p50:", sum/cnt "s"}'
done
```

To enable multi-provider routing via API, send a PUT request to update the gateway with `multiprovider_enabled` set to true. The dashboard path is AI > AI Gateway, select the gateway, go to Settings, turn on Multi-Provider Routing, then Save.

## Migration Checklist & Break-Even Thresholds

- Enable multi-provider routing on gateways created before December 9, 2026, or accept single-provider routing for all models.
- Migrate deprecated spend limits to policies before the deprecation date is enforced.
- Test policies in the dashboard to verify allow, block, and cap behavior against real identities.
- Set `cf-aig-provider-sort: price` for cost-sensitive workloads, but verify provider price lists in the AI model catalog before production rollout.
- Monitor p99 latency during provider failover events; unhealthy preferred providers can add seconds to tail latency before fallback.
- Break-even math: containers beat serverless above 50,000 requests/hour sustained or when concurrency exceeds 100 connections due to connection pool exhaustion. For multi-provider routing, route to alternate providers when the per-request cost delta from catalog prices exceeds the measured failover latency cost at your request volume.

When NOT to use this: single-provider workloads with strict data residency requirements should keep multi-provider routing off to avoid traffic leaving the primary provider's jurisdiction. Gateways with low request volume do not benefit from failover complexity, and spend caps add operational overhead without meaningful savings at low scale.

![Multi-provider routing sends requests to any provider serving the model, with automatic failover when the preferred provider is unhealthy.](https://developers.cloudflare.com/ai-gateway/features/routing/multi-provider-routing/og.png?v=81172ba8b5671d51)

Multi-provider routing is on by default for gateways created on or after December 9, 2026, and gateways created before then keep using their existing providers until the setting is turned on. Provider IDs come from the Providers section of each model's page in the AI model catalog. The provider order header does not remove providers from the pool and does not add providers the gateway does not allow.

![Control spend and model access with AI Gateway policies · Changelog](https://developers.cloudflare.com/changelog/post/2026-12-04-policies/og.png?v=45e44a0edfae6525)

Policies use the verified identity of the caller from Cloudflare Access, such as the user's email or IdP groups, or values passed in custom metadata. Each policy targets an identity and a set of models or providers, then allows, blocks, or caps matching requests. Test policies in the dashboard to check how policies handle a request before it reaches real traffic.

[Multi-provider routing documentation](https://developers.cloudflare.com/ai-gateway/features/routing/multi-provider-routing/)
[Multi-provider routing changelog](https://developers.cloudflare.com/changelog/post/2026-12-02-multi-provider-routing/)
[AI Gateway policies changelog](https://developers.cloudflare.com/changelog/post/2026-12-04-policies/)

## Frequently Asked Questions

### Does multi-provider routing apply to requests that name specific providers?

No. Requests that set the cf-aig-allowed-providers header can use the providers they name whether the setting is on or off, bypassing the gateway-level default.

### Can spend caps be applied per user inside a shared team budget?

Yes. Policies can give a team or email domain a shared monthly budget and cap spend for each individual user within that shared budget.

### What happens when the preferred provider in cf-aig-provider-order is unhealthy?

AI Gateway can still choose a different provider from the pool; provider order is a preference, not a hard restriction, and does not remove providers from the pool.

### What is the Cloudflare AI Gateway request pricing?

Cloudflare AI Gateway charges $1.00 per million requests after the free tier; provider token pricing (input/output $/Mtok) is set by each upstream provider and listed in the AI model catalog.

## Primary Sources

- https://developers.cloudflare.com/ai-gateway/features/routing/multi-provider-routing/
- https://developers.cloudflare.com/changelog/post/2026-12-02-multi-provider-routing/
- https://developers.cloudflare.com/changelog/post/2026-12-04-policies/
