Skip to content
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions src/content/changelog/ai-gateway/2026-12-02-policies.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
title: Control spend and model access with AI Gateway policies
description: Set budgets and block or allow models on AI Gateway based on the verified identity of the caller, including IdP groups, email domains, and custom metadata.
date: 2026-12-02
---

You can now control who can use which models and providers on your gateway, and how much each user or team can spend, with AI Gateway [policies](/ai-gateway/features/policies/). Policies use the verified identity of the caller from [Cloudflare Access](/ai-gateway/configuration/cloudflare-access/), such as the user's email or identity provider (IdP) groups, or values you pass in [custom metadata](/ai-gateway/observability/custom-metadata/).

With policies, you can:

- Give a team or an email domain a shared monthly budget.
- Cap spend for each individual user, including inside a shared team budget.
- Block an IdP group from expensive models, or allow it to use only specific models.

Each policy targets an identity and a set of models or providers, then allows, blocks, or caps matching requests. Spend caps reset hourly, daily, weekly, or monthly on UTC boundaries. Use **Test policies** in the dashboard, or the simulate endpoint in the API, to check how your policies handle a request before it reaches real traffic.

The following policy blocks members of the `contractors` IdP group from all Claude Opus models:

```json
{
"name": "Block contractors from Claude Opus",
"actor": "company:all",
"resource": { "model": "anthropic/claude-opus-*" },
"condition": "\"contractors\" in cf.user.groups",
"action": { "type": "block" }
}
```

Policies replace [spend limits](/ai-gateway/features/spend-limits/), which are now deprecated. Existing spend limit rules continue to work. To move them to policies, refer to [Migrate from spend limits](/ai-gateway/features/policies/#migrate-from-spend-limits).

For more details, refer to the [Policies documentation](/ai-gateway/features/policies/).
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ When a request to a custom domain includes a valid Cloudflare Access JWT, AI Gat

AI Gateway also adds the verified Access user ID to request metadata as [`cf.user_id`](/ai-gateway/observability/custom-metadata/#reserved-metadata). This value is the Access JWT `sub` claim, not the user's email address. You can then filter logs, analytics, and spend by the authenticated user.

The user ID, email, IdP groups, and custom claims from Access are also available to [policies](/ai-gateway/features/policies/), so you can set budgets and model access rules for each user or group.

Before AI Gateway forwards the request to the upstream provider, it removes Cloudflare-only credentials such as the Access JWT and AI Gateway authorization headers.

Once a custom domain is protected by Access, every request to that domain must pass an Access policy. Requests that only include an AI Gateway token, without a valid Access token, are blocked by Access before they reach the gateway. Update existing integrations to authenticate through Access, or keep sending gateway-token traffic to the default `gateway.ai.cloudflare.com` endpoint, which is not protected by Access.
Expand Down
27 changes: 14 additions & 13 deletions src/content/docs/ai-gateway/features/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,17 @@ Serve identical requests directly from Cloudflare's global cache, reducing laten

</Feature>

<Feature header="Spend Limits" href="/ai-gateway/features/spend-limits/">
<Feature header="Spend and Model Access Policies" href="/ai-gateway/features/policies/" badge="Beta">

Set cost-based budgets that track cumulative dollar spend across requests. Scope limits by model, provider, or custom metadata dimensions like user, team, or application.
Control how much each user or group can spend, and which models and providers they can call. Policies use the verified identity of the caller from Cloudflare Access or [custom metadata](/ai-gateway/observability/custom-metadata/). Policies replace [spend limits](/ai-gateway/features/spend-limits/).

**Key benefits:**

- Per-provider or per-model budgets
- Per-user or per-team budgets using [custom metadata](/ai-gateway/observability/custom-metadata/)
- Configurable time windows (daily, weekly, monthly)
- Automatic request blocking when budget is exceeded
- Shared budgets for teams or email domains
- Individual spend caps for each user
- Hourly, daily, weekly, or monthly budgets
- Block or allowlist models by IdP group, user, email domain, or custom metadata
- Test policies before they affect live traffic

</Feature>

Expand Down Expand Up @@ -199,13 +200,13 @@ Override default pricing with your negotiated rates or custom cost models. Apply

## Feature Comparison by Use Case

| Use Case | Recommended Features |
| -------------------------- | --------------------------------------------------------------- |
| **Cost Optimization** | Caching, Auto Router, Spend Limits, Rate Limiting, Custom Costs |
| **High Availability** | Fallbacks using Dynamic Routing |
| **Security & Compliance** | Guardrails, DLP, Authentication, BYOK, Logging |
| **Performance Monitoring** | Analytics, Logging, Custom Metadata |
| **A/B Testing** | Dynamic Routing, Custom Metadata, Analytics |
| Use Case | Recommended Features |
| -------------------------- | ----------------------------------------------------------- |
| **Cost Optimization** | Caching, Auto Router, Policies, Rate Limiting, Custom Costs |
| **High Availability** | Fallbacks using Dynamic Routing |
| **Security & Compliance** | Guardrails, DLP, Authentication, BYOK, Logging |
| **Performance Monitoring** | Analytics, Logging, Custom Metadata |
| **A/B Testing** | Dynamic Routing, Custom Metadata, Analytics |

## Getting Started with Features

Expand Down
Loading