litellm/litellm/models
Kerry Lu 64d84e557e
feat(budgets): add per-model tpm and rpm limit maps to budgets and customers (#50797)
* feat(budgets): add per-model tpm and rpm limit maps to budgets and customers

Budgets gain model_tpm_limit and model_rpm_limit (model name to whole number, 0 or more).
/budget/new, /budget/update, /budget/info and /customer/new carry them, and the auth
path loads a customer's maps onto UserAPIKeyAuth as end_user_model_tpm_limit and
end_user_model_rpm_limit so the limiter can enforce them in a follow-up.

* fix(budgets): keep org, team and project per-model limits in metadata; lock_timeout and type gate fixes

Organizations, teams and projects store model_tpm_limit / model_rpm_limit in their own metadata,
which the limiter reads, so the shared budget allowlist leaves those two fields to customers.
Migration starts with SET LOCAL lock_timeout. Mapping annotations and rebind-ok reasons satisfy
the type discipline gate. Customer info tests expect the two new budget keys.

* fix(organizations): keep stripping budget_id and flattening nested per-model maps on update

The update path pops every budget field from the organization row again, so a caller's budget_id
never changes the attached budget, and a nested litellm_budget_table still flattens the two maps
into org metadata. Drops the explanatory comment on CUSTOMER_ONLY_BUDGET_FIELDS.

* fix(types): keep basedpyright and ruff strict counts flat for the new budget fields

Reads the per-model maps off the end-user params with membership checks instead of .get on an
untyped dict, writes the inline customer budget through the client's typed jsonify_object, and
builds budget rows in handle_budget_for_entity with model_validate so the two Mapping fields never
receive object-typed kwargs.

* chore: drop unrelated reformatting from project endpoints

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-09 22:15:18 -08:00
..
__init__.py feat(budgets): add per-model tpm and rpm limit maps to budgets and customers (#50797) 2026-11-09 22:15:18 -08:00
access_group.py feat(access-groups): grant Claude Code skills through access groups (#46294) 2026-10-14 23:18:50 +00:00
autorouter_session.py fix(autorouter): compare historical and new savings consistently (#43348) 2026-09-29 12:40:19 -07:00
base.py perf(types): defer pydantic schema builds via shared LiteLLMBaseModel (#44720) 2026-10-05 22:10:08 -07:00
budget.py feat(budgets): add per-model tpm and rpm limit maps to budgets and customers (#50797) 2026-11-09 22:15:18 -08:00
config.py refactor(lint): apply every safe ruff autofix and zero 28 strict-rule budgets 2026-08-01 15:43:29 -07:00
credentials.py feat(github_copilot): support a GHE.com host on per-user Copilot credentials (#47610) 2026-10-20 14:16:35 -07:00
deployment_warning.py refactor(proxy): inject deployment warning ignores through repositories (#48592) 2026-10-30 22:57:55 +00:00
end_user.py fix(proxy): allow model instances in LiteLLM_EndUserTable validation (#41677) 2026-10-15 10:57:26 -07:00
gateway_activity.py refactor(proxy): inject gateway activity through a typed repository (#49116) 2026-10-30 16:25:11 -07:00
managed_files.py refactor(types): replace Any with proven types in 50 files (#47818) 2026-10-21 11:58:31 +00:00
mcp_server.py feat(mcp): rate limit all MCP operations and add server-level rpm (#44600) 2026-10-07 16:30:52 -07:00
model.py fix(proxy): serialize model block responses 2026-08-29 21:22:17 -07:00
object_permission.py feat(proxy): granular key/team access control for Claude Code marketplace plugins (#40518) 2026-09-10 14:26:09 -07:00
organization.py refactor(lint): apply every safe ruff autofix and zero 28 strict-rule budgets 2026-08-01 15:43:29 -07:00
organization_membership.py refactor(typing): clear 1181 basedpyright Any errors across 431 files (#47789) 2026-10-24 11:31:09 -07:00
plugin_upload.py feat(skills): add sortable Skills Hub catalog and publication audit (#50195) 2026-11-06 00:57:33 +00:00
project.py refactor(lint): apply every safe ruff autofix and zero 28 strict-rule budgets 2026-08-01 15:43:29 -07:00
skill_submission.py feat(skills): add optional manual security scans (#50194) 2026-11-05 01:57:39 -08:00
skills.py refactor(skills): move NewSkillRequest to litellm.models.skills (#45768) 2026-10-10 20:33:16 +00:00
spend_logs.py feat(spend-logs): add lifecycle timestamps 2026-08-18 14:16:08 -07:00
subscription_account.py feat(usage): show subscription-covered providers and account fees separately (#44772) 2026-10-30 03:58:36 -07:00
tag.py refactor(lint): apply every safe ruff autofix and zero 28 strict-rule budgets 2026-08-01 15:43:29 -07:00
team.py feat(proxy): add tpd_limit (tokens per day) for batch submissions 2026-09-13 10:06:07 +00:00
team_membership.py refactor(lint): apply every safe ruff autofix and zero 28 strict-rule budgets 2026-08-01 15:43:29 -07:00
user.py perf(types): defer pydantic schema builds via shared LiteLLMBaseModel (#44720) 2026-10-05 22:10:08 -07:00
user_banner.py refactor(proxy): inject database repositories through per-repository dependencies (#48507) 2026-10-30 22:57:54 +00:00
verification_token.py Merge pull request #41403 from BerriAI/litellm_key_total_spend 2026-09-16 14:49:02 -07:00