Skip to main content

Budget reservation

Since v1.85.0

A budget check compares recorded spend with the cap, but a request's cost is only recorded once it finishes. Without anything else, a burst of concurrent requests could all pass a budget that only some of them fit. Budget reservation closes that gap. Before LiteLLM calls the provider, it estimates the most the request can cost and adds that estimate to the spend counter of every budget the request falls under. This hold is the reservation, and it lets the next request see the room this one may use. Once the response is priced, the hold is replaced with the actual cost.

Reservation is on by default and needs no setting. general_settings.disable_budget_reservation: true Since v1.90.0 turns it off for every budget at once.

How it works​

The estimate prices the request's input tokens plus its output cap. The output cap is the largest of max_tokens, max_completion_tokens, max_output_tokens and the provider's own fields such as generationConfig.maxOutputTokens, held to the model's output limit, or to 16,384 when the model lists none. A request that sets no cap is estimated at 16,384 output tokens, or the model's output limit when that is lower. Output is priced at the model's output rate and multiplied by n when the request asks for several outputs. When LiteLLM cannot count the input, it uses the model's input limit. Reservation runs before routing, so for a model group whose deployments have different prices, LiteLLM holds the cost of the most expensive one. Embeddings, rerank and moderation requests are estimated on input alone.

Every request ends by settling its hold. A successful request settles at its actual cost and a failed one at zero. A request that the client cancels after the provider call started settles at the cost of its input tokens, since the provider bills those either way. LiteLLM keeps the hold alive while a long request is still running.

When a budget has no room left because concurrent requests already reserved it, the request is refused with the regular budget_exceeded error, whose message names the scope by type and ID, such as Budget has been exceeded! Team=team-research Current cost: 10.2, Max budget: 10.0. When some room is left but less than the estimate, LiteLLM admits the request and cuts its hold down to what remains, so that last request can land a little over the cap. With fail-closed enforcement on, the same request is refused up front instead, with Estimated request cost added to the message.

When to use it​

Leave reservation on for any budget that has to hold under load, such as an agent that fans out parallel calls, a script with many workers sharing one key, or a team with a small budget and many members. It needs no setup.

Turn it off only as a short-term fix when holds that were never settled keep refusing requests after those requests have finished, and turn it back on once that is resolved. Without reservation a budget can be overshot by whatever is in flight when it runs out. To keep a budget a hard ceiling even while Redis is degraded, keep reservation on and add fail-closed budget enforcement. To cap throughput rather than spend, use rate limits.

Supported scopes​

Reservation is on for every supported scope by default, and general_settings.disable_budget_reservation: true turns it off for all of them.

ScopeSupportedHow to set it
Whole proxyNolitellm_settings.max_budget is checked against recorded spend only.
OrganizationYesHolds against the organization's max_budget.
TeamYesHolds against the team's max_budget and each of its budget_limits windows.
Team memberYesHolds against the member's budget in the team, from max_budget_in_team or the team's team_member_budget.
ProjectYesHolds against the project's max_budget.
Virtual keyYesHolds against the key's max_budget, or its shared budget row's, and each of its budget_limits windows.
Internal userYesHolds against the personal max_budget and each budget_limits window, on requests the personal budget covers.
CustomerYesHolds against legacy end-user budgets and Customer Management budget_limits windows. A Customer Management max_budget is checked against recorded spend only.
TagYesTags created with /tag/new. Tags in litellm_settings.tag_budget_config are enforced by the router without a hold.
Model access groupYesHolds against the group's max_budget.
AI toolNoChecked against the AI tool budget row only, so concurrent requests can overshoot.
Agent sessionNoSession spend is checked against its own counter before each call.

How to use it​

Keep the estimate close to real cost​

Set max_tokens, or the route's equivalent, on requests from callers that run close to a cap. A request without one is held at up to 16,384 output tokens, which on an expensive model can be more than the room left in a small budget. With fail-closed enforcement that request is refused even when its real cost would have fit.

Disable budget reservation​

Disable reservation only as a temporary mitigation if holds that were never settled cause unexpected budget_exceeded responses after the affected requests have completed:

config.yaml
general_settings:
disable_budget_reservation: true
warning

Disabling reservation can allow concurrent requests to exceed a configured budget because each request is evaluated only against spend already recorded.

Requests are still rejected once a budget is already spent. LiteLLM logs once at startup that budget enforcement is read-time only while the setting is on.

If a budget must remain a hard ceiling when Redis is unavailable or contains stale data, keep reservation enabled and also configure fail_closed_budget_enforcement.

Batch requests​

Budget reservation cannot estimate the full cost of a batch job. A POST /batches request contains an input_file_id rather than the prompts in the file, so LiteLLM cannot price the complete workload at submission. The submission reservation is released after the submission response, and LiteLLM records the final cost when the batch completes.

Use batch rate limiting to control batch throughput, and monitor completed batch costs for budget reporting.

Limits​

Routes that the model's pricing cannot estimate, such as image generation priced per image and some audio routes, get no hold and are checked against recorded spend only. Per-model budgets get no hold either, and requests to free models take none because they skip budget checks altogether.

Holds live in the same spend counters that every worker shares through Redis. Without Redis each worker keeps its own counters, so requests on different workers do not see each other's holds. When a hold cannot be written, for example while Redis is down, LiteLLM skips it and checks the request against recorded spend, unless fail-closed enforcement is on, which returns a 503 instead.

A key with throttle_on_budget_exceeded: true drops the hold on its own budget when the hold would take it over the cap, so it keeps serving at the throttled rate. See Throttle over-budget keys.

See Fail-closed budget enforcement to make holds strict, Budget exceeded errors for what a refused request receives, and Budgets and spend limits for every scope a request is checked against.

LiteLLM Enterprise
SSO/SAML, audit logs, spend tracking, multi-team management, and guardrails, built for production.
Learn more →