The LLM Gateway is in beta.
402 response that names the blocking policies:
Spend policies do not apply to calls billed to a Claude subscription, and those calls are left out of spend totals.
Policy dimensions
Spend policies are evaluated from broadest to most specific. All matching policies are checked, and if any one returns a block, the request is rejected. You can set a policy as a default (applying a blanket spend cap to all workspaces, users, or API keys) or as a granular policy (individual limits or limits on a group of entities).Conflict resolution
By default, the gateway assesses the broadest scope first. Narrower scopes can only tighten limits, never loosen them. For example, if an org-level policy caps spend at $10,000/month and a workspace-level policy caps at $15,000/month, the $10,000 org cap still applies.Defaults vs. granular policies
Spend policies have two aspects:- Sums across a dimension: the total cap for that scope. Example: “This workspace’s total spend cannot exceed $5,000/month.”
- Defaults for each member of a dimension: a base limit that applies to every API key or user within a scope unless overridden. Example: “Each API key in this workspace gets a $200/month default cap.” Individual API keys can receive additional policies that raise their specific limit, but no policy can loosen a cap set at a broader scope.
Time window period
The time window sets the period over which spend accumulates against the cap. At the end of each window, recorded spend resets to zero:Create a spend policy
- Go to LLM Gateway and select Cost Controls.
- Click Create spend limit.
- Select the scope (organization, workspace, user, or API key).
- (Optional) To separate a default limit by header, select Workspace, User, or API Key. Apply the limit to every subject of that type by default. Alternatively, select exactly one subject to pin the limit to it. Select Separate limits by custom header, and enter the header name, such as
Customer-Id. Send the fullX-Gateway-Customer-Idheader on requests. Each subject and header-value pair receives an independent limit. - Set the spend cap in USD and the time window period (monthly, weekly, daily, or hourly).
- Click Create spend limit.
View spend
In LLM Gateway > Cost Controls, the Usage column shows how much each policy has spent, in dollars and as a percentage of its cap. To analyze spend over time by user, API key, model, or request header, use the Usage tab. For more information, see Monitor LLM Gateway spend.See also
- Header-based policies: split a cap by a custom request header so each header value gets its own limit.
- Data policies: add data policies alongside cost controls.
Connect these docs to your agent of choice via MCP for real-time answers.

