litellm - ✅(Solved) Fix Support multiple concurrent budget windows for users [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#28235Fetched 2026-05-20 03:40:45
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Participants
Timeline (top)
cross-referenced ×1

Fix Action

Fixed

PR fix notes

PR #28236: feat(proxy): support user budget limits

Description (problem / solution / changelog)

Relevant issues

Closes #28235

Linear ticket

N/A

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/test_litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

CI (LiteLLM team)

CI status guideline:

  • 50-55 passing tests: main is stable with minor issues.
  • 45-49 passing tests: acceptable but needs attention
  • <= 40 passing tests: unstable; be careful with your merges and assess the risk.
  • Branch creation CI run
    Link:

  • CI run for the last commit
    Link:

  • Merge / cherry-pick CI run
    Links:

Screenshots / Proof of Fix

Targeted tests:

uv run pytest tests/test_litellm/proxy/auth/test_multi_budget_windows.py tests/test_litellm/proxy/test_budget_reservation.py tests/test_litellm/proxy/common_utils/test_reset_budget_job.py tests/test_litellm/proxy/management_endpoints/test_internal_user_endpoints.py tests/test_litellm/proxy/test_proxy_server.py -q

Result: 328 passed, 26 warnings.

Type

🆕 New Feature ✅ Test

Changes

  • Adds budget_limits to LiteLLM_UserTable so users can configure multiple concurrent budget windows, matching the existing key/team behavior.
  • Initializes user budget window reset_at values on user create/update.
  • Enforces user budget windows during auth with spend:user:{user_id}:window:{budget_duration} counters.
  • Increments, reserves, reseeds, and resets user budget window counters through the existing spend counter and budget reservation paths.
  • Adds focused tests for auth checks, budget reservation, spend counter updates, reset behavior, and user update serialization.

Changed files

  • litellm-proxy-extras/litellm_proxy_extras/migrations/20260519000000_add_user_budget_limits/migration.sql (added, +2/-0)
  • litellm-proxy-extras/litellm_proxy_extras/schema.prisma (modified, +1/-0)
  • litellm/proxy/_types.py (modified, +11/-0)
  • litellm/proxy/auth/auth_checks.py (modified, +77/-4)
  • litellm/proxy/common_utils/reset_budget_job.py (modified, +30/-2)
  • litellm/proxy/db/spend_counter_reseed.py (modified, +6/-0)
  • litellm/proxy/management_endpoints/internal_user_endpoints.py (modified, +77/-8)
  • litellm/proxy/management_endpoints/key_management_endpoints.py (modified, +4/-1)
  • litellm/proxy/proxy_server.py (modified, +85/-54)
  • litellm/proxy/schema.prisma (modified, +1/-0)
  • litellm/proxy/spend_tracking/budget_reservation.py (modified, +18/-0)
  • schema.prisma (modified, +1/-0)
  • tests/test_litellm/proxy/auth/test_multi_budget_windows.py (modified, +137/-3)
  • tests/test_litellm/proxy/common_utils/test_reset_budget_job.py (modified, +41/-4)
  • tests/test_litellm/proxy/management_endpoints/test_internal_user_endpoints.py (modified, +135/-0)
  • tests/test_litellm/proxy/test_budget_reservation.py (modified, +141/-0)
  • tests/test_litellm/proxy/test_proxy_server.py (modified, +94/-0)

Code Example

{
  "user_id": "user-123",
  "max_budget": 1000,
  "budget_duration": "30d",
  "budget_limits": [
    {"budget_duration": "1d", "max_budget": 150},
    {"budget_duration": "7d", "max_budget": 500}
  ]
}
RAW_BUFFERClick to expand / collapse

Feature request

LiteLLM currently supports budget_limits for virtual keys and teams, but users can only configure a single max_budget / budget_duration pair. This makes it hard to express multiple concurrent aggregate user budget windows, for example 1000 USD per 30d plus 150 USD per 1d.

Motivation

Key-level budget_limits do not aggregate across multiple keys that share the same LiteLLM user. Team-level budget_limits constrain the whole team, not an individual user. User-level windows would let admins cap an individual user's aggregate spend while keeping the existing key and team controls.

Proposed behavior

Add budget_limits to LiteLLM users with the same schema and behavior as key/team budget_limits:

  • Persist budget_limits on LiteLLM_UserTable.
  • Initialize reset_at for each user budget window on user create/update.
  • Enforce each user window during auth with counters shaped as spend:user:{user_id}:window:{budget_duration}.
  • Increment and reserve user window counters using the existing spend counter and budget reservation paths.
  • Reset expired user windows in the existing budget reset job.

Example user configuration:

{
  "user_id": "user-123",
  "max_budget": 1000,
  "budget_duration": "30d",
  "budget_limits": [
    {"budget_duration": "1d", "max_budget": 150},
    {"budget_duration": "7d", "max_budget": 500}
  ]
}

Related work

This extends the existing multiple concurrent budget windows feature for virtual keys and teams to users. Related PRs: #24883 and #25109.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING