Soft budgets and budget alerts
A soft budget is a USD amount that only warns. Set soft_budget on a virtual key, team or project, and LiteLLM sends an alert once that scope's spend reaches it, while requests keep working until the scope's max_budget runs out. Budget alerts also cover the max_budget itself, both as it runs low and when it is used up.
Alerts reach people in two ways. Slack, Microsoft Teams and webhook destinations listed in general_settings.alerting get an alert when a soft budget is crossed, when 15% and then 5% of a max_budget is left, and when it is crossed. Email alerts go out at percentages of max_budget that you choose, each with its own recipients, through metadata.max_budget_alert_emails on a key or team, metadata.team_member_max_budget_alert_emails on a team, and litellm_settings.default_key_max_budget_alert_emails for every key. Not every scope sends every kind of alert, and the scope table lists what each one sends. On this page, Slack also stands for Microsoft Teams, which receives the same budget alerts.
How it works
LiteLLM records spend after each response and checks budgets when the next request arrives. An alert therefore goes out with the first request after spend reaches a threshold, and that request is still served unless spend has reached max_budget, in which case it fails with budget_exceeded. Once sent, the same alert is held back for 24 hours by default, as Alert de-duplication explains.
When to use it
Set a soft budget below a hard cap to warn a key owner or team lead before traffic stops, for example soft_budget: 800 on a team with a $1,000 monthly max_budget. Use percentage email thresholds when finance or on-call should hear at several points, such as 50%, 75% and 90% of a key's or team's budget, with different people at each level. Use Slack or webhook budget alerts to feed one channel, or your own billing system, with every key, user and proxy budget that runs low or runs out. Use team member thresholds to warn each person about their own allowance inside a team.
A soft budget never slows or stops traffic. To cap spend, set a max_budget as described in Budgets and spend limits. To keep an over-budget key serving at reduced throughput, use throttling. For budgets on your own product's customers, use the Customer Management budget webhooks, and for periodic spend summaries that do not depend on a budget, use the spend_reports alert type in Alerting.
Supported scopes
| Scope | Supported | How to set it |
|---|---|---|
| Whole proxy | Yes | Set litellm_settings.max_budget. Slack and webhook alerts at 15% and 5% left and when it is crossed. No soft budget or email. |
| Organization | Yes | Set max_budget on /organization/new or /organization/update. Slack and webhook alert only when a request is rejected over it. A soft_budget on an organization is stored but sends nothing. |
| Team | Yes | metadata.max_budget_alert_emails on /team/new or /team/update for emails at percentages of max_budget, or the legacy soft_budget with metadata.soft_budget_alerting_emails described in Team soft budget alerts. Slack and webhook alert when a request is rejected over max_budget. |
| Team member | Yes | metadata.team_member_max_budget_alert_emails on the team for emails at percentages of each member's budget. Once spend reaches the lowest percentage, Slack and webhook alerts at 15% and 5% left and when crossed. No soft budget. |
| Project | Yes | soft_budget on /project/new or /project/update sends a Slack and webhook alert and emails the owner of the key that sent the request. Slack and webhook alert when a request is rejected over max_budget. Projects need Enterprise. |
| Virtual key | Yes | soft_budget on /key/generate or /key/update alerts Slack and webhooks and emails the key owner. max_budget sends Slack and webhook alerts at 15% and 5% left and when crossed, and emails the owner at 80% or at the percentages in metadata.max_budget_alert_emails. |
| Internal user | Yes | Set max_budget on /user/new or /user/update. Slack and webhook alerts at 15% and 5% left and when crossed, on requests that the personal budget applies to. No soft budget or email. |
| Customer | Yes | Customer Management only. Its soft_budget and max_budget send soft_budget_crossed and budget_crossed to the customer_budget_webhook callback. A soft_budget on /customer/new for legacy end users sends nothing. |
| Tag | No | /tag/new stores a soft_budget but nothing checks it, and an exhausted tag budget sends no alert. |
| Model access group | No | The group's soft_budget is stored but nothing checks it, and an exhausted group budget sends no alert. |
| AI tool | Yes | Slack and webhook alerts at 80% and at the limit of a budget set with PUT /team/{team_id}/ai_tool_budgets. See AI tool budgets. No soft budget. |
| Agent session | No | A session that reaches max_budget_per_session gets a 429 and no alert is sent. |
How to use it
Turn on alert destinations
List the destinations under general_settings.alerting. Slack reads its URL from SLACK_WEBHOOK_URL, webhooks post to WEBHOOK_URL, and email needs an email integration (Resend, SendGrid or SMTP) configured through its environment variables.
general_settings:
alerting: ["slack", "webhook", "email"]
alerting_args:
budget_alert_ttl: 86400
The budget_alerts alert type is on by default. If you set general_settings.alert_types, include budget_alerts in the list, or Slack and webhooks get no budget alerts. To send budget alerts to their own Slack channel, map budget_alerts in alert_to_webhook_url. See Alerting for Slack, Map Slack channels to alert type, Webhooks for budget alerts and Email notifications.
Set a soft budget
Pass soft_budget with the scope's other budget fields. On a key, the alert goes to Slack and webhooks, and to the key owner's email when email is in general_settings.alerting. In the Admin UI, the key's edit view has a Soft Budget (USD) field.
curl -X POST 'http://0.0.0.0:4000/key/generate' \
-H "Authorization: Bearer $LITELLM_MASTER_KEY" \
-H 'Content-Type: application/json' \
-d '{"key_alias": "prod-app", "max_budget": 100, "budget_duration": "30d", "soft_budget": 80}'
A project's soft budget alerts Slack and webhooks, and emails the owner of whichever key sent the request. When a team or project request sets both, soft_budget must be lower than max_budget.
curl -X POST 'http://0.0.0.0:4000/project/update' \
-H "Authorization: Bearer $LITELLM_MASTER_KEY" \
-H 'Content-Type: application/json' \
-d '{"project_id": "support-bot", "max_budget": 500, "soft_budget": 400}'
A team's soft budget sends nothing unless the team also lists recipients in metadata.soft_budget_alerting_emails. Those addresses are then emailed even when email is not in general_settings.alerting, and any Slack or webhook destination listed there gets the alert too. This fixed-dollar alert is the legacy option for teams. Team soft budget alerts walks through it, and percentage thresholds below replace it for teams with a max_budget.
Email alerts at percentages of max_budget
Email budget alerts requires a LiteLLM Enterprise license. Start a free 30-day trial or book a demo. See what Enterprise includes.
Email alerts need email in general_settings.alerting and an email integration. Each one maps a whole-number percentage of the scope's budget to the recipients notified once spend crosses it.
On a key, set metadata.max_budget_alert_emails on /key/generate or /key/update Since v1.83.10, or fill in Budget Alert Thresholds in the key's form Since v1.111.0. The key owner's email is always added to each threshold's recipients. A key without the map emails only its owner, once spend reaches 80% of max_budget, so a key whose owner has no email sends nothing. EMAIL_BUDGET_ALERT_MAX_SPEND_ALERT_PERCENTAGE changes that default, for example to 0.9. A 100% threshold still sends on the request that is rejected, because the alert check runs first.
curl -X POST 'http://0.0.0.0:4000/key/update' \
-H "Authorization: Bearer $LITELLM_MASTER_KEY" \
-H 'Content-Type: application/json' \
-d '{
"key": "sk-...",
"metadata": {
"max_budget_alert_emails": {
"50": ["owner@example.com"],
"90": ["owner@example.com", "finance@example.com"],
"100": ["oncall@example.com"]
}
}
}'
litellm_settings.default_key_max_budget_alert_emails gives every key a baseline map. A key's own entries merge into it one threshold at a time, so a key keeps the baseline recipients for a percentage and adds its own.
litellm_settings:
default_key_max_budget_alert_emails:
"80": ["platform-team@example.com"]
On a team, metadata.max_budget_alert_emails alerts on the team's combined spend across all its keys Since v1.112.0, and metadata.team_member_max_budget_alert_emails alerts on each member's spend inside the team against their member budget Since v1.105.0. Team alerts go only to the listed recipients. The team needs a positive max_budget, and each percentage must be a whole number from 1 to 100 with at least one recipient, or the update is rejected. Member alerts always include the member's own email, so an empty list notifies only the member, and invalid member entries are ignored. The metadata you send replaces the team's metadata, so include any keys you want to keep.
curl -X POST 'http://0.0.0.0:4000/team/update' \
-H "Authorization: Bearer $LITELLM_MASTER_KEY" \
-H 'Content-Type: application/json' \
-d '{
"team_id": "research",
"max_budget": 1000,
"team_member_budget": 100,
"metadata": {
"max_budget_alert_emails": {
"75": ["finance@example.com"],
"90": ["finance@example.com", "research-lead@example.com"]
},
"team_member_max_budget_alert_emails": {
"80": [],
"100": ["research-lead@example.com"]
}
}
}'
In the Admin UI, open Teams and select the team. Team Budget Alerts under Settings > Edit Settings holds the team percentages, and Budget Alert Thresholds under Member Defaults > Edit Defaults holds the member percentages. See Email notifications for the full rules and email templates.
Slack and webhook alerts
Slack and webhook budget alerts need no per-scope setup beyond the budget itself. Each alert carries an event of soft_budget_crossed, threshold_crossed (15% or 5% of max_budget left) or budget_crossed, and an event_group naming the scope, such as key, team, team_member, user, project, organization or proxy. A key with a soft budget also sends projected_limit_exceeded when its spend so far projects past the soft budget before its budget window ends, or before the end of the month for a key without budget_duration. Webhooks receive the alert as JSON, and API spec for webhook event lists every field.
Alert de-duplication
Each email alert sends at most once per EMAIL_BUDGET_ALERT_TTL seconds, 24 hours by default, for the same key, team or team member and the same percentage. Slack and webhook alerts send at most once per general_settings.alerting_args.budget_alert_ttl seconds, also 24 hours by default, for the same scope and the same event. A budget reset does not clear these windows, so an alert can repeat a day later while spend stays above its threshold. AI tool alerts and Customer Management budget webhooks work differently and send each event once per budget period.
export EMAIL_BUDGET_ALERT_TTL=43200
With several workers or pods, configure Redis as described in What needs Redis so they share one de-duplication window. Without it, each process keeps its own window and can send the same alert again.
Limits
The 15% and 5% Slack alerts share the threshold_crossed event, so only the first of them sends within one budget_alert_ttl window. A key soft_budget of 0 counts as no soft budget, so use a small positive value such as 0.01 to test. Project soft budget alerts are de-duplicated per calling key rather than per project, so a project used by several keys sends one alert for each key, each emailed to that key's owner.
Organizations, tags, model access groups and legacy customers accept a soft_budget field but never alert on it. When general_settings.alerting lists email together with slack, ms_teams or webhook, each Slack budget alert is also emailed over SMTP to the user named in the alert, and a team alert to every member of the team, using only the SMTP_* settings.
Related
See Budgets and spend limits for setting the budgets these alerts watch, Alerting for Slack, Microsoft Teams and webhook setup, Email notifications for email integrations and templates, and Team soft budget alerts for the legacy team walkthrough.