LLM Budget plugin
The LLM Budget plugin adds up what LLM requests cost, in US dollars, and compares the total with a limit for the current UTC week or month. With enforcement on, it refuses a request with 429 Too Many Requests once the limit is reached. With enforcement off, it only tracks spending.
Fabric prices each request from a rate card for the provider and model, using the tokens in the response. The count runs after the response is sent, so it adds no delay. The Budget page in the console sets up the organization and namespace budgets for you. Create an instance yourself only for other scopes. For how budgets work, see Control spend with budgets.
Where it runs
A request can match more than one LLM Budget instance, such as an organization budget and a namespace budget. Each instance counts the request, and the gateway refuses it when any enforced budget is at its limit.
The plugin needs an active LLM Observability instance, because it reads the token counts that plugin records. Without one, an enforced budget refuses every request with 503.
Set up the plugin
For an organization or namespace budget, use the Budget page instead of the steps here. For the steps, see Set a budget. Use the steps on this page to attach a budget to another scope, such as one route.
Prerequisites
Before you begin, make sure you have the following:
- An active LLM Observability instance. For the steps, see LLM Observability.
- A control plane deployment. The plugin isn’t available on a standalone gateway.
- Permission to create plugin instances.
- For a budget per gateway key, Key Auth on the route, so each request carries a gateway key. For the steps, see Authenticate requests with Key Auth.
Steps
- In the console sidebar, select Plugins, and then open the All tab.
- Find LLM Budget, and then select Use. The New plugin instance form opens.
- In Apply to, select the scope. If you select a scope other than Global, select the target in the field below it.
- In Instance name, enter a name, for example
team-monthly-budget. - Under Configuration, in Spending limit (USD), enter the limit, as a positive amount with up to 6 decimal places, for example
100.00. - For Budget period, select Weekly or Monthly. A weekly budget resets at 00:00 UTC on Monday. A monthly budget resets at 00:00 UTC on the first of the month.
- To keep counting without refusing requests, clear Stop requests at the limit. The setting is selected by default.
- (Optional) To give each gateway key its own limit of this amount, select Separate budget per gateway key.
- (Optional) Expand Match conditions (optional) to limit when the instance runs. The conditions are Path prefix, Methods, Consumer, and Consumer group. All conditions must match.
- Confirm that Enabled is selected. Fabric saves a disabled instance but doesn’t run it.
- Select Create instance. The form doesn’t save until you enter a spending limit.
Verify it works
To check that the budget counts spending, do the following:
-
Send a request through an LLM route that the budget covers.
-
Open the Budget page, and check that the amount spent goes up. The page can lag a little, because counting runs after the response.
-
To check enforcement, set Spending limit (USD) to a small amount, send requests until the budget is used, and then send one more. The gateway returns
429with this body, and doesn’t send the request to the provider:
Fix common problems
Configuration
An instance has these fields. The console shows the first four. The rest are set by the Budget page, and the console form keeps them when you edit an instance.
The spending limit in millionths of a US dollar, from 1 to 9,007,199,254,740,991. The console and the Budget page enforce that range. A plugin instance created another way only needs a positive value. For example, 100000000 is $100. The console labels this Spending limit (USD) and converts the amount for you.
week or month, on the UTC calendar. A week starts on Monday. The console labels this Budget period, with the options Weekly and Monthly.
total keeps one balance for everything that the instance covers. per_key keeps a separate balance for each gateway key, and refuses requests with no key when enforcement is on. The console labels this Separate budget per gateway key.
When true, the gateway refuses requests once the limit is reached. When false, the budget only tracks spending, and it never refuses a request because the limit is used up or because counting is unavailable. The console labels this Stop requests at the limit.
Splits a per_key budget into one balance for each namespace or each route, with {"source": "namespace"} or {"source": "route"}. The Budget page sets this for the organization and namespace budgets.
Up to 100 exceptions to the limit, for per_key budgets. Each item has limit_usd_micros and one selector: credential_id without a partition, namespace_id for a namespace partition, or route_name for a route partition. The Budget page manages these as allowances.
Spending to carry over when a total budget is created partway through a period. The control plane sets it at creation, and it can’t change afterward.
Responses
The request that takes spending over the limit still completes, so spending can end slightly above the limit. Without enforcement, a missing LLM Observability instance, missing counters, or a missing price only skips counting. The gateway logs each case and serves the request.
The gateway also returns 503 with budget configuration invalid when an instance’s saved configuration doesn’t parse, whether enforcement is on or off. The console checks the configuration when you save it, so this is rare.

