The End of the Two-Product Era

For the past couple of years, Cloudflare shipped two products that looked different under the hood but solved the same fundamental problem for developers: getting you connected to a model with a real control plane on top.

  • AI Gateway was the proxy layer — you point it at OpenAI, Anthropic, or any provider, and you get observability, logging, access control, and caching for free.
  • Workers AI was the hosting layer — Cloudflare runs the GPUs, you hit an inference endpoint.

If you've been juggling both, you already felt the friction: which binding do I use? Which endpoint? Why do I need to configure a gateway and a model binding?

That friction is now gone. Cloudflare is converging these into a single unified control plane. Let's break down what actually changed and what's coming.

Source: Cloudflare Blog — Unifying Workers AI and AI Gateway

Cloud infrastructure dashboard showing unified AI control plane for Workers AI and AI Gateway Dev Environment Setup

What Actually Shipped

1. One binding, one REST endpoint

The env.AI binding now routes through AI Gateway by default. If you never set up a gateway, a default gateway is auto-created on your first authenticated request.

// Before: direct Workers AI call, no observability
export default {
  async fetch(request, env) {
    const response = await env.AI.run('@cf/zai-org/glm-5.2', {
      messages: [{ role: 'user', content: 'What is the capital of France?' }],
    });
    return new Response(JSON.stringify(response));
  },
};

// After: same call, but now with full observability via default gateway
export default {
  async fetch(request, env) {
    const response = await env.AI.run(
      '@cf/zai-org/glm-5.2',
      { messages: [{ role: 'user', content: 'What is the capital of France?' }] },
      { gateway: { id: 'default' } } // auto-creates on first use
    );
    return new Response(JSON.stringify(response), {
      headers: { 'Content-Type': 'application/json' },
    });
  },
};

Same pattern via REST:

curl "https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run/@cf/zai-org/glm-5.2" \
  -H "Authorization: Bearer {api_token}" \
  -H "Content-Type: application/json" \
  -H "cf-aig-gateway-id: default" \
  -d '{"messages":[{"role":"user","content":"What is the capital of France?"}]}'

2. Observability is now the default, not an opt-in

Every request through the default gateway logs full request/response payloads, token counts per model, and cost attribution — no dashboard setup required. If you outgrow the default, swap id: 'default' for a named gateway and you're done. One parameter change.

3. Unified billing across Workers AI + external providers

This is the sleeper feature. Previously, AI Gateway credits only worked on external providers (OpenAI, Anthropic). Now your AI Gateway wallet funds Workers AI too. Load credits once, spend them across any supported provider. Bonus: Workers AI rate limits are elevated if you route through AI Gateway unified billing.

4. Model-first routing (coming soon)

This is the real architectural shift. Instead of provider-first routing ("which provider do I call?"), you get model-first routing ("which model do I need?").

AspectProvider-first (today)Model-first (coming)
You specifyProvider + modelModel only
FailoverManual retries in your appHandled by gateway
Load balancingDIYTransparent
ZDR compliancePer-provider configGateway-enforced

Example request:

curl -X POST "https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/v1/chat/completions" \
  -H "Authorization: Bearer {api_token}" \
  -H "cf-aig-gateway-id: my-gateway" \
  -H "Content-Type: application/json" \
  -d '{"model":"kimi-k2.7-code","messages":[{"role":"user","content":"Review this function"}]}'

You ask for kimi-k2.7-code. The gateway decides whether that comes from Workers AI, Moonshot, or another vetted host — and fails over transparently if one is rate-limited.

5. Smart routing (later)

A classifier on Workers AI reads your prompt, classifies the task (coding / research / summarization / QA), scores complexity, and picks the best model from a curated pool. Zero config if you don't want it; explicit model pins if you do.

Developer terminal using Cloudflare AI binding to route model requests through default gateway System Abstract Visual

Limitations and Things to Watch

A few honest caveats before you migrate everything:

  • Model-first routing is not GA yet. Cloudflare says "pilot in the coming months." Don't design your architecture around it as a hard dependency — design it as an optimization layer.
  • Default gateway = default logging. Full request/response payloads are logged. If you're handling PII or regulated data, you need to explicitly configure retention, redaction, or a named gateway with stricter policies. This is a real compliance consideration, not a footnote.
  • Unified billing is convenient, but it's still prepaid. You're loading a wallet. If your workload spikes and the wallet empties, your requests fail — same as any prepaid model. Set budget alerts.
  • "Vetted providers" is a black box. Cloudflare says it works with vetted providers for model-first routing, but the vetting criteria aren't published. If you have strict vendor requirements (SOC2, data residency), verify before relying on automatic failover.
  • Rate limit elevation is a carrot, not a guarantee. The elevated limits for unified billing users are real, but they're promotional. Don't assume they'll persist forever.

Next Steps

If you're on Workers AI today: flip on the default gateway. It's a one-line change and you get logging, token tracking, and cost attribution immediately. Zero downside.

If you're on AI Gateway with external providers: add a Workers AI model to your routing. Unified billing means you can now consolidate spend. Start with a cheap embedding model or a summarizer to test the waters.

If you're building multi-provider resilience: prototype model-first routing now, but keep a fallback path. The pattern (specify model, not provider) is the right mental model, but the implementation isn't stable yet.

Network diagram of model-first routing with automatic provider failover across AI providers IT Technology Image

The Bigger Picture

Cloudflare is quietly building the control plane layer for the entire AI stack — not just inference, but routing, billing, observability, and failover. That's a much bigger bet than "we host GPUs." It's the same play AWS made with API Gateway, but for model calls.

For developers, the practical takeaway is simple: stop hand-rolling retry logic and provider abstraction layers. That's now infrastructure. Your job is to pick the right model for the task and let the control plane do the rest.

Related Reading

This content was drafted using AI tools based on reliable sources, and has been reviewed by our editorial team before publication. It is not intended to replace professional advice.