Skip to main content

Whole proxy budget

litellm_settings.max_budget caps the combined spend of every request through the proxy, whichever key, team, user or customer sends it. The master key and proxy admin keys are not exempt. It sits above every other scope, and organization, team, team member, project, key and user budgets still apply under it. LiteLLM checks every budget a request falls under and rejects the request when any one of them is over its cap, so once proxy spend passes max_budget, every inference request fails until the budget resets or you raise it.

Budgets require a database

The proxy, organization, team, team member, key and user budgets are enforced against spend read from the database, so none of them cap anything on a DB-less deployment. litellm_settings.max_budget fails open there rather than erroring: the proxy's spend is only loaded when a database client exists, and with no total to compare against, the check is skipped and requests keep being served past the limit. A warning is logged once at startup when a budget is set with no database connected, but nothing blocks at request time. Key, team and user budgets are unavailable for the same reason, since virtual keys cannot be resolved without a database (No connected db.). Run with a database if a budget is part of how you bound spend.

How it works​

LiteLLM keeps the proxy's spend on a reserved internal user record with the ID litellm-proxy-budget. At startup, with a database connected, it creates or updates that record with your max_budget and budget_duration, and the cost of every request is added to it for as long as max_budget is above 0. The background reset job sets its spend back to 0 at the end of each budget_duration, on the same schedule as other budgets. See Budget reset times and timezones.

The check runs on every inference request, including provider pass-through routes. Management routes such as /key/generate and model list routes such as /v1/models are not checked, and requests that cost nothing, such as a call to a model priced at zero, skip it like every other budget.

When to use it​

Use it as a last-resort ceiling on what one deployment can spend in total, such as a sandbox or proof-of-concept proxy, or a safety net above the team budgets of a production proxy. Because one caller can use up the whole amount and block everyone else, pair it with team budgets or key budgets that split the spend between groups. To stop sending traffic to a provider or deployment that has used up its own allowance, rather than rejecting callers, use budget routing.

Set a budget​

Step 1. Set the budget in config.yaml

general_settings:
master_key: os.environ/LITELLM_MASTER_KEY
database_url: os.environ/DATABASE_URL

litellm_settings:
max_budget: 100 # USD across all proxy spend. 0, the default, means no cap
budget_duration: 30d # how often spend resets, such as "30s", "30m", "1h", "1d" or "1mo"

budget_duration is required whenever a database is connected. If max_budget is set without it, the proxy fails to start with budget_duration not set on Proxy. budget_duration is required to use max_budget.

Step 2. Start the proxy

litellm --config /path/to/config.yaml

Step 3. Send a test call

curl 'http://0.0.0.0:4000/chat/completions' \
-H "Authorization: Bearer $LITELLM_MASTER_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-6-luna",
"messages": [{"role": "user", "content": "what llm are you"}]
}'

Once the proxy's spend is over max_budget, requests fail with a budget_exceeded error. The status is 422 unless you set budget_exceeded_status_code, as described in Budget exceeded errors.

{
"error": {
"message": "Budget has been exceeded! Current cost: 100.0021, Max budget: 100.0",
"type": "budget_exceeded",
"param": null,
"code": "422"
}
}

Check spend​

Read the litellm-proxy-budget record with a proxy admin key. user_info in the response holds the current period's spend, max_budget, budget_duration and budget_reset_at.

curl 'http://0.0.0.0:4000/user/info?user_id=litellm-proxy-budget' \
-H "Authorization: Bearer $LITELLM_MASTER_KEY"

/global/spend is not the same number. It adds up the spend logs of the last 30 days, which does not follow the budget's reset window. With alerting configured, LiteLLM also sends Slack and webhook alerts as the proxy nears and crosses max_budget.

Change or remove a budget​

Change max_budget or budget_duration in config.yaml and restart the proxy. The spend already counted in the current period is kept, so a lower cap can block requests straight away. The current period still ends on its original budget_reset_at, and a new budget_duration applies from that reset on.

To remove the cap, delete max_budget or set it to 0, then restart. While the cap is off, LiteLLM stops adding spend to the litellm-proxy-budget record.

Default budget​

The proxy has no cap until you set max_budget, and 0, the default, also means no cap. This setting is the proxy's only budget, so there is no separate default for it. See Default budgets.

Budget features​

Which budget features work on whole proxy budgets. Each feature page lists every scope it supports.

FeatureSupportedDetails
Shared budgetsNoThe proxy budget is max_budget under litellm_settings.
Default budgetsNolitellm_settings.max_budget with budget_duration is the proxy's only budget, so there is nothing to default. See Whole proxy budget.
Per-model budgetsNoThere is no proxy-wide per-model cap. Budget routing caps a deployment for every caller.
Multiple budget windowsNolitellm_settings takes one max_budget and one budget_duration.
Budget reset times and timezonesYeslitellm_settings.budget_duration next to litellm_settings.max_budget.
Budget rollover, overage carry-overYesSpend above litellm_settings.max_budget carries over at the budget_duration reset.
Budget rollover, unused budget carry-overNo-
Soft budgets and budget alertsYesSet litellm_settings.max_budget. Slack and webhook alerts at 15% and 5% left and when it is crossed. No soft budget or email.
Team soft budget alertsNoThe proxy budget sends Slack and webhook alerts instead. See Soft budgets and budget alerts.
Budget exceeded errorsYesBudget has been exceeded! Current cost: <spend>, Max budget: <cap>
Throttle over-budget keysNoThe proxy-wide max_budget still rejects every request once it runs out.
Budget fallbacksNoRouter fallbacks in config.yaml handle provider errors, not budgets.
Temporary budget increaseNo-
Budget reservationNolitellm_settings.max_budget is checked against recorded spend only.
Fail-closed budget enforcementNoProxy-wide spend is read from its own database row on a separate path that the setting does not change.
Free models and budgetsYeslitellm_settings.max_budget is not checked.
Self-serve budget changesNo-

Limits​

Fail-closed budget enforcement does not cover the proxy budget, since its spend is read from its own database record on a separate path. /global/spend/reset sets key and team spend to 0 but leaves the proxy's spend alone, so the proxy budget only resets on its budget_duration. With custom auth, budget checks, this one included, run only when general_settings.custom_auth_run_common_checks is true.

Budgets covers every budget scope, Budget precedence lists which caps apply to each kind of request, and Spend tracking explains how LiteLLM prices each request.

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