Budget exceeded errors
When a request runs into a budget that has run out, LiteLLM rejects it before it calls the provider. The error has type budget_exceeded, returns HTTP 422 by default, and its message names the scope that ran out with its current spend and cap. Nothing reaches the provider, so the refusal costs nothing.
litellm_settings.budget_exceeded_status_code changes the status, for example to 429 for clients built against older releases. A few budgets fail differently. Agent session budgets return a 429 rate limit error, tag budgets declared in config.yaml fail as a routing error, and a per-model budget with budget fallbacks reroutes the request instead of failing it.
When to use it
Read this page when you write client code against the proxy. A budget refusal will not succeed on retry until the budget resets or someone raises it, so a client should stop, surface the message, and point the user at whoever owns the budget, where a provider 5xx or rate limit is worth retrying. Dashboards and alerts can split budget refusals from other failures on error.type.
Change the status code only when existing clients depend on it, such as code written against releases that returned 429. To keep an over-budget key running at reduced speed instead of rejecting it, use throttling. To reroute a capped model instead, use budget fallbacks.
Supported scopes
Supported means the scope's refusal is a budget_exceeded error whose status follows budget_exceeded_status_code. The last column gives the start of the error message.
| Scope | Supported | How to set it |
|---|---|---|
| Whole proxy | Yes | Budget has been exceeded! Current cost: <spend>, Max budget: <cap> |
| Organization | Yes | Budget has been exceeded! Organization=<organization_id> |
| Team | Yes | Budget has been exceeded! Team=<team_id>, or ExceededBudget: Team=<team_id> over 1d budget. for a budget_limits window |
| Team member | Yes | Budget has been exceeded! User=<user_id> in Team=<team_id>, or Budget has been exceeded! TeamMember=<user_id>:<team_id> |
| Project | Yes | Budget has been exceeded! Project=<project_id> |
| Virtual key | Yes | Budget has been exceeded! Key=<key_alias> (sk-...abcd), or ExceededBudget: Key over 1d budget. for a budget_limits window |
| Internal user | Yes | ExceededBudget: User=<user_id> over budget., or over 1d budget. for a budget_limits window |
| Customer | Yes | ExceededBudget: End User=<customer_id> over budget. for legacy end users, and ExceededBudget: customer_org=<id> over budget. with customer_team or customer_member for Customer Management |
| Tag | Yes | Budget has been exceeded! Tag=<tag> for tags created with /tag/new. Tags in litellm_settings.tag_budget_config fail as a routing error instead, described below |
| Model access group | Yes | Budget has been exceeded! Model access group=<group> |
| AI tool | Yes | Budget exceeded for AI tool <tool> for team, or Budget exceeded for AI tool <tool>. for a team member's tool budget |
| Agent session | No | Always a 429 rate limit error with type throttling_error, described below |
Every Budget has been exceeded! message goes on with Current cost: <spend>, Max budget: <cap>, and every ExceededBudget: message gives the spend and the limit, except a Customer Management budget window's. Customer Management messages end with what the caller can do next, wait for the reset or request a temporary increase.
How to use it
Read the error
On /v1/chat/completions, /v1/responses, /v1/embeddings and the other OpenAI-shaped routes, the body has the usual top-level error object:
{
"error": {
"message": "Budget has been exceeded! Key=analytics-team (sk-...W8TA) Current cost: 0.06, Max budget: 0.05",
"type": "budget_exceeded",
"param": null,
"code": "422"
}
}
error.type is always budget_exceeded, and error.code repeats the HTTP status as a string. A budget_limits window names the window and formats the amounts as dollars:
{
"error": {
"message": "ExceededBudget: Team=team-research over 1mo budget. Spend=$1000.4200, Limit=$1000.00",
"type": "budget_exceeded",
"param": null,
"code": "422"
}
}
When several concurrent requests race for the last of a budget, the one that loses is refused while LiteLLM reserves its cost, and its 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. With fail-closed enforcement on, a request whose estimated cost does not fit the remaining budget is refused the same way, with Estimated request cost added to the message.
Anthropic Messages routes
/v1/messages and the other Anthropic Messages routes return Anthropic's error shape. error.type holds Anthropic's type for the status, invalid_request_error for a 422, and the LiteLLM type moves to error.litellm_error_type:
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "Budget has been exceeded! Key=zero-budget (sk-...PO3g) Current cost: 0.0, Max budget: 0.0",
"litellm_error_type": "budget_exceeded"
},
"request_id": "req-docs-check-1"
}
A tag budget that a guardrail adds to the request is checked later, inside the Messages handler, so that one refusal has error.type set to api_error and no error.litellm_error_type. See Errors on the Anthropic Messages routes.
Change the status code
The default status is 422, because the OpenAI and Anthropic SDKs retry a 429 on their own, and retrying cannot help once a budget has run out. Older releases returned 429. Set budget_exceeded_status_code under litellm_settings to return another status, such as 429 to keep the old behavior. Since v1.104.0
litellm_settings:
budget_exceeded_status_code: 429
The setting changes the status of every budget_exceeded error, including per-model budget refusals and refusals at reservation, and error.code follows it. error.type stays budget_exceeded. It does not change agent session budgets or tag budgets declared in config, which are 429s of their own.
Tell a budget error from a provider error
Read error.type on the OpenAI-shaped routes and error.litellm_error_type on the Anthropic Messages routes. budget_exceeded means LiteLLM refused the request itself and no provider was called. The status alone is not enough, since a provider can also return 422, and with budget_exceeded_status_code: 429 a budget refusal shares its status with every rate limit. Two more signs point to a budget refusal. Its message names no provider exception such as OpenAIException, and it carries no retry-after header, which LiteLLM's TPM and RPM limits send. See Is it the gateway or the provider?.
With the OpenAI Python SDK, the error object exposes the type directly:
import openai
client = openai.OpenAI(base_url="http://0.0.0.0:4000", api_key="sk-...")
try:
client.chat.completions.create(
model="gpt-6-luna",
messages=[{"role": "user", "content": "hello"}],
)
except openai.APIStatusError as e:
if e.type == "budget_exceeded":
print(f"Budget exhausted, not retrying: {e.message}")
else:
raise
/key/info returns the key's spend, max_budget and budget_reset_at, which tells the caller when a key budget will reset. For other scopes, use the matching info endpoint, such as /team/info or /user/info.
Watch spend before it runs out
Successful responses on the OpenAI-shaped routes carry x-litellm-key-max-budget when the key has a max_budget, x-litellm-key-spend with the key's spend including this response, and x-litellm-response-cost with this response's cost. A client can compare the first two to slow down or warn before the key is refused. With several workers, x-litellm-key-spend can trail the spend that other workers have just recorded, so treat /key/info as the authoritative value. A budget_exceeded refusal is raised while LiteLLM authenticates the request, so it does not carry these headers. See Response headers.
Budgets that fail differently
An agent session over its max_budget_per_session gets a 429 rate limit error from a pre-call check. It does not follow budget_exceeded_status_code and carries no retry-after header:
{
"error": {
"message": "Session budget exceeded for session sess-1234. Current spend: $5.0213, max_budget_per_session: $5.00.",
"type": "throttling_error",
"param": null,
"code": "429"
}
}
The session stays blocked until its spend counter expires, one hour after its first charge by default. See Agent iteration budgets.
A tag in litellm_settings.tag_budget_config is enforced by the router, which drops every deployment once the tag is over budget. The request fails with a 429 whose error.type is not budget_exceeded and whose message starts with the routing prefix and names the tag:
No deployments available - crossed budget: Exceeded budget for tag='batch-jobs', tag_spend=50.12, tag_budget_limit=50.0
A key with a per-model budget and budget fallbacks for the capped model reroutes the request to the first fallback still within budget, and the caller gets a normal response from that model. Without a fallback, or once every fallback is over budget too, the request fails with budget_exceeded and a message such as LiteLLM Virtual Key: <hashed key>, key_alias: <key_alias>, exceeded budget for model=<model>.
With fail-closed enforcement on, a request whose spend cannot be verified returns a 503 with Budget enforcement unavailable in its message. It signals a Redis or database outage rather than a spent budget, so retry it with backoff.
Related
See Error reference for every gateway error type and status, Throttle over-budget keys to slow a key down instead of rejecting it, and Budgets and spend limits for setting the budgets themselves.