Samuel Arendt

Cloudflare AI Gateway adds per-user policies and deprecates spend limits

On December 4, 2026, Cloudflare released policies for AI Gateway, the service that sits between an application and AI model providers and records the cost, cache status, and logs of each call. A policy defines who can use which models and how much that person or team can spend. On the same date, spend limits, which were the way to cap spending in the gateway, were marked as deprecated.

What policies do

Each policy picks an identity and a set of models or providers, then allows, blocks, or caps spending on the requests that match. This makes it possible to give a team or an email domain a monthly budget, set a cap for each person within that budget, and stop a group from using certain models. The example in the announcement blocks every Claude Opus model for the contractors group.

The identity can come from two places. The first is Cloudflare Access: the gateway validates the token on each request and reads the email, identity provider groups, or service token name, values the client cannot forge. The second is the cf-aig-metadata header, which the application fills in with up to five keys. The documentation warns that the gateway cannot verify this header, so it should only be sent from a trusted backend.

Caps reset hourly, daily, weekly, or monthly, always on UTC boundaries. When a cap is reached, the response is HTTP 429 with "Spending limit exceeded". A blocked request, or one that matches no policy, gets HTTP 403.

Who needs to look now

The change affects teams that already use AI Gateway to call OpenAI, Anthropic, Workers AI, or other providers, especially those who set up spend limits. It also matters to companies that opened AI up to several teams and today share one key and one bill without knowing who spent what.

If you have spend limits, nothing breaks today. The spend limits page says existing rules keep working until you migrate, and no shutdown date has been published.

Migration pitfalls

The official path has four steps: create a policy that covers the traffic that should keep flowing, recreate each spend limit rule as a policy, check the result with Test policies in the dashboard, and only then delete the old rules. The order matters for a reason the documentation states plainly: as soon as any policy exists in the gateway, every request that matches none of them is rejected. Creating only the contractors policy, for example, blocks the rest of the company.

Other differences change how the application behaves:

  • spend limits could use a rolling window and, when exceeded, let a dynamic route fall back to a cheaper model; a policy uses calendar windows only and rejects the whole request;
  • while both are configured, a request has to pass both;
  • responses served from cache do not count toward the budget;
  • models without pricing known to the gateway are not counted, so a cap can let spend on those models through;
  • cost is recorded after the request completes, and concurrent calls can go slightly over the limit;
  • if reading a policy or the spend fails, traffic is allowed, except when the failure is in the identity provider group lookup, which returns HTTP 503;
  • a change can take up to 15 minutes to apply across the network.

An AI spending cap has the same side effect as limits on usage-based hosting: once it is reached, the feature stops responding to the end user. The article Spending limits on Vercel and Cloudflare can take your site offline discusses who should keep track of that usage. Before turning on a monthly cap for a customer-facing feature, decide what the application shows when it gets the 429 and who gets notified.

To test without touching live traffic, the API has a simulation endpoint (POST .../policies/simulate) that takes an identity, model, and provider and returns whether the request would be allowed, blocked, or capped, without calling the provider or recording spend.

What has not been announced

The announcement and documentation do not say which plans include policies, whether they cost extra, how many policies fit in each gateway, or when spend limits stop working. Responses also carry no header with the remaining budget, so the application only learns the cap is used up when it receives the 429.

If your company is weighing something similar or needs support on this topic, reach me on LinkedIn or WhatsApp.

References

#Architecture, #Operations, #Radar