litellm/tests/integration/management
jesus-berri c39fe92696
feat(proxy): per-key and per-team model ITPM/OTPM limits in the v3 rate limiter (#54311)
* feat(proxy): per-key and per-team model ITPM/OTPM limits in the v3 rate limiter

Keys and teams can set model_itpm_limit and model_otpm_limit in their metadata. The v3 limiter counts input and output tokens for them separately, reserves the output at admission and credits the unused part back after the call, the same way project limits already work.

Resolves LIT-11138

* test(proxy): cover key model OTPM limits on the fallback path

* test(rate-limit): a fallback over the key model OTPM is skipped for the next one

* fix(proxy): ignore malformed key and team model IO limits and keep charging them on project-covered batches

* fix(proxy): keep key and team model IO limits on the native batch path and validate them per entry

* fix(proxy): do not read project metadata for batch IO limits a covering project limit replaces

* refactor(proxy): restore native PROJECT_OTPM_DESCRIPTOR_KEY export and share IO limit metadata helpers

* fix(proxy): inherit team model ITPM/OTPM only without a key limit and read key/team limits like int()

A key that sets its own model_itpm_limit or model_otpm_limit for a model is no longer also held to its team's limit for that model and direction, which matches how model_tpm_limit and model_rpm_limit are inherited. The batch output floor follows the same rule.

Key and team limits now accept what the project limits accept, so numeric text and floats are read with int() and booleans are still ignored.

* test(proxy): cover key and team IO limit inheritance on batch ITPM, numeric batch limits and socket paths

* fix(proxy): name output token limits OTPM in batch rate limit errors

* style(rust): apply rustfmt to the project IO scope list in the limiter builder

* fix(proxy): name input token limits ITPM in batch rate limit errors

* fix(proxy): check guaranteed-throughput key ITPM/OTPM limits against the team's limits

* perf(proxy): parse team keys' ITPM/OTPM allocations once per limit type

* fix(proxy): keep Final bindings out of the ITPM/OTPM allocation loop

* test(proxy): cover key and team IO limits on batches and the team allocation check in integration

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-28 11:03:47 -08:00
..
__init__.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
_batch_file_caps.py feat(proxy): cap batch file records, daily batch uploads, and per-file downloads (#43632) 2026-10-06 03:06:36 +00:00
cost_center_service.py test: migrate SDK and proxy-booting legacy CircleCI tests to their tiers (#45758) 2026-10-11 00:17:21 -07:00
team_metadata_validation_proxy_config.yaml test: migrate SDK and proxy-booting legacy CircleCI tests to their tiers (#45758) 2026-10-11 00:17:21 -07:00
test_access_group_team_sync.py test(access-groups): store the two groups in scan order instead of asserting the order Postgres chose (#54532) 2026-11-25 22:10:37 +00:00
test_added_backup_deployment_serves_peer_fallbacks.py fix(proxy): apply new model rows on every worker as soon as they are written (#49034) 2026-10-30 03:19:25 -07:00
test_agent_management.py test(integration): repair agent reads and bulk deletion setup (#49719) 2026-11-02 13:44:45 -08:00
test_audit_log_listing.py fix(proxy): read audit update rows stored before #50929 in GET /audit (#53305) 2026-11-21 04:58:51 +00:00
test_auto_router_databricks_classifier_writes.py test(integration): match Databricks classifier budget telemetry (#49382) 2026-10-30 20:13:51 -07:00
test_batch_file_usage_caps.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
test_batch_file_usage_caps_chaos.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
test_batch_limit_metadata_admin_only.py feat(proxy): cap batch file records, daily batch uploads, and per-file downloads (#43632) 2026-10-06 03:06:36 +00:00
test_batch_output_file_listing.py test(integration): stop GET /__observations from draining the upstream log (#47256) 2026-10-18 09:58:05 +00:00
test_budget_list_sorting.py feat(ui): sort budgets by reset duration (#48107) 2026-10-23 16:21:53 -07:00
test_budget_model_limits.py feat(budgets): add per-model tpm and rpm limit maps to budgets and customers (#50797) 2026-11-09 22:15:18 -08:00
test_budget_reset_windows.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
test_budget_updates.py test: update stale integration and e2e expectations for intended changes (#53940) 2026-11-23 14:27:20 -08:00
test_claude_code_plugin_installation_preference.py test(skills): assert patch publication and serialize preference writes (#50252) 2026-11-05 20:16:15 +00:00
test_credential_display_name.py fix(credentials): preserve stored info when patching credentials (#49919) 2026-11-03 16:15:09 -08:00
test_credential_federation_values.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
test_credential_migration_endpoint.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_credential_writes_survive_reload.py fix(proxy): hold DB_RECONCILE_LOCK around credential create, update and delete (#50551) 2026-11-07 16:02:44 -08:00
test_customer_budget_reset.py fix(proxy): /customer/new budgets reset on the same schedule as other budgets (#51689) 2026-11-13 19:22:14 +00:00
test_customer_member_budget_concurrency.py fix(customer-management)!: preserve permanent budgets across temporary increases (#52787) 2026-11-19 10:55:11 -08:00
test_customer_model_limits.py feat(rate-limit): name the limit that rejected a request in a rate_limited_by header on the 429 (#51228) 2026-11-11 14:39:53 -08:00
test_customer_override_expiry.py fix(proxy): drop a customer override expiry sent without an override (#51667) 2026-11-13 11:24:05 -08:00
test_customer_team_delete_budgets.py fix(proxy): delete a customer team's override budget when the team has no overall budget (#51703) 2026-11-13 13:05:19 -08:00
test_customer_unknown_fields.py feat(customers): reject unknown fields on /customer/new and /customer/update instead of dropping them (#50965) 2026-11-10 18:08:21 +00:00
test_f7_coverage_closeout.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_f7_key_coverage_push.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_fallback_management_public_names.py fix(fallback): preserve concurrent writes and serve saved configuration (#51245) 2026-11-11 15:26:23 -08:00
test_guardrail_usage_config_guardrail.py fix(guardrails): serve usage detail for a guardrail removed from config (#53315) 2026-11-23 11:54:37 -08:00
test_health_routing.py test(integration): keep the database down during readiness checks (#54931) 2026-11-28 01:03:20 +00:00
test_key_aliases.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_key_block_unblock.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_key_budget_limits.py feat(proxy): per-key and per-team model ITPM/OTPM limits in the v3 rate limiter (#54311) 2026-11-28 11:03:47 -08:00
test_key_bulk_update.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_key_default_allowed_routes.py feat(proxy): give AI API service accounts safe default routes only (#54027) 2026-11-24 11:43:32 -05:00
test_key_delete.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_key_delete_revocation.py fix(proxy): evict a deleted key from every worker's auth cache (#47609) 2026-10-30 10:20:00 -07:00
test_key_generate.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_key_generation_permissions.py test: migrate SDK and proxy-booting legacy CircleCI tests to their tiers (#45758) 2026-10-11 00:17:21 -07:00
test_key_health.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_key_info.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_key_info_v2.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_key_list.py feat(ui): sort virtual keys by expiry, activity, spend and limits (#48074) 2026-10-23 15:45:17 -07:00
test_key_regenerate.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_key_reset_spend.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_key_route_contracts.py test: move 76 live top-level tests to offline unit and integration coverage (#45352) 2026-10-08 10:33:35 -07:00
test_key_service_account_generate.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_key_team_change.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_key_update.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_key_updates.py fix(tests): resolve the integration support package without run.py's PYTHONPATH 2026-09-15 21:10:08 -07:00
test_listing_and_health_contracts.py fix(budgets): reset 12months and other long unit spellings on their short form's schedule (#51672) 2026-11-13 11:08:55 -08:00
test_managed_file_create_ownership.py fix(proxy): org admin spend log scope and gemini file id parsing (#52943) 2026-11-19 22:08:27 +00:00
test_managed_vector_store_unified_id.py test(integration): cover vector_stores endpoint contracts (#44739) 2026-10-14 03:59:08 +00:00
test_master_key_rotation.py fix(proxy): rotate all database secrets with the master key (#52998) 2026-11-20 10:02:59 -08:00
test_model_credential_name_updates.py fix(proxy): validate model credential name only when it changes (#42701) 2026-09-23 07:34:32 -07:00
test_model_deployment_lifecycle.py test: migrate SDK and proxy-booting legacy CircleCI tests to their tiers (#45758) 2026-10-11 00:17:21 -07:00
test_model_health_check.py test(extraction): audit #47473 (#48898) 2026-10-28 17:12:07 -07:00
test_model_hub_custom_metadata.py feat(model hub): show admin-defined custom tags and metadata from model_info (#46064) 2026-10-20 17:45:06 -07:00
test_model_hub_wildcard_health.py feat(proxy): health check AI Hub models published through a wildcard (#52875) 2026-11-20 11:03:02 -08:00
test_model_rename_propagation.py test(integration): cover model_management endpoint contracts (#44684) 2026-10-14 03:36:47 +00:00
test_organization_budget_clear.py test(integration): regression tests for August cost tracking and budgeting bugs (#42622) 2026-09-23 04:13:03 +00:00
test_organization_lifecycle.py test(integration): stop GET /__observations from draining the upstream log (#47256) 2026-10-18 09:58:05 +00:00
test_partial_update_sequences.py test: expect 422 for budget refusals in unification, e2e and integration suites 2026-09-20 06:33:57 +00:00
test_pass_through_model_hub.py test(model-hub): compare matching pass-through rows (#53193) 2026-11-20 21:29:46 +00:00
test_policy_attachment_runtime.py test(management): isolate global policy attachment state (#52318) 2026-11-17 23:48:52 +00:00
test_policy_template_refused_temperature.py fix(policy): drop refused temperatures on policy template enrichment calls (#53311) 2026-11-21 14:01:06 -08:00
test_project_lifecycle.py fix(integration): size rig pools for the rust connection share and stop the router importing the proxy (#52532) 2026-11-18 18:41:36 +00:00
test_prompt_management.py test(integration): cover prompts_tags_caching endpoint contracts (#44686) 2026-10-14 04:10:31 +00:00
test_ptu_share_guards.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
test_scim_admin_group.py fix(proxy)!: stop answering with the literal string "None" as error type and param on the proxy-server, auth, spend, and key health routes (#39540) 2026-10-29 18:20:52 -07:00
test_scim_group_bulk_roster.py fix(scim): clear every group or member on a PATCH remove with no value or filter (#51784) 2026-11-24 03:21:28 +00:00
test_scim_group_delete.py fix(scim): answer every /scim/v2 error with the RFC 7644 SCIM Error schema (#51322) 2026-11-17 19:10:33 +00:00
test_scim_group_member_not_yet_provisioned.py test(integration): cover customer reported cache key, cache_control, bedrock request id, responses schema, scim and tag budget contracts (#42785) 2026-09-23 13:19:38 -07:00
test_scim_group_pathless_patch.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
test_scim_user_lifecycle.py fix(scim): clear every group or member on a PATCH remove with no value or filter (#51784) 2026-11-24 03:21:28 +00:00
test_scim_user_team_race.py fix(scim): stop SCIM user writes from overwriting teams a concurrent group push added (#50785) 2026-11-24 07:48:16 -08:00
test_search_tool_crud.py test(integration): expect the Exa search envelope's provider_metadata after #47423 (#47572) 2026-10-20 15:29:30 +00:00
test_skill_download_history.py feat(skills): export download history as streamed CSV (#52569) 2026-11-21 21:14:46 +00:00
test_smoke.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_sso_sign_in.py fix(proxy): accept special-use email domains in generic SSO (#54026) 2026-11-24 19:16:23 -05:00
test_tag_budget_update.py fix(proxy): stop /tag/update 500 when the body carries the tag's budget_id (#50324) 2026-11-06 08:55:44 -08:00
test_team_available.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_team_block.py test(proxy): wait for a team block to reach the peer proxy before expecting a new team key to be refused (#53532) 2026-11-22 06:01:38 +00:00
test_team_block_unblock.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_team_blocking_multi_instance.py fix(proxy): broadcast team cache invalidation on team writes (#46113) 2026-10-13 16:25:22 -04:00
test_team_budget_duration_defaults.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
test_team_budget_limits.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_team_bulk_member_add.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_team_bulk_member_delete.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_team_daily_activity.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_team_delete.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_team_delete_chaos.py test(integration): give chaos and timing tests a harness API and gate raw signals (#46031) 2026-10-12 05:27:33 -07:00
test_team_delete_inputs.py fix(proxy): delete large teams without per-member transaction fan-out (#42998) 2026-09-30 13:49:18 -07:00
test_team_delete_large_membership.py test(management): account for the ledger writer reserve (#53293) 2026-11-21 03:49:05 +00:00
test_team_delete_member_add_race.py refactor(auth_cache): type auth cache keys and keep the cache always native (#51130) 2026-11-21 17:20:30 +09:00
test_team_delete_member_cache_eviction.py fix(scim): write a group's roster in one locked transaction instead of one member at a time (#45197) 2026-10-15 10:57:00 -07:00
test_team_delete_prometheus.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
test_team_filter_ui.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_team_info.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_team_key_bulk_update.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_team_list.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_team_list_sorting.py feat(ui): sort every teams table data column (#48109) 2026-10-23 16:21:36 -07:00
test_team_list_v2.py feat(teams): show caller member spend and budget on Your Teams (#45674) 2026-10-24 17:09:55 -07:00
test_team_member_add.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_team_member_budget_cache.py test(integration): regression tests for August cost tracking and budgeting bugs (#42622) 2026-09-23 04:13:03 +00:00
test_team_member_delete.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_team_member_info_validation.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_team_member_lifecycle.py test(integration): stop GET /__observations from draining the upstream log (#47256) 2026-10-18 09:58:05 +00:00
test_team_member_me.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_team_member_reset_budget.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_team_member_reset_spend.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_team_member_routes.py test: move 76 live top-level tests to offline unit and integration coverage (#45352) 2026-10-08 10:33:35 -07:00
test_team_member_update.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_team_members_list.py test(management): isolate the seeded roster per test (#52652) 2026-11-18 21:45:50 +00:00
test_team_members_list_faults.py feat(proxy): page team members and stop loading full rosters for /team/info callers (#51885) 2026-11-17 16:30:52 -08:00
test_team_metadata_schema.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_team_metadata_validation.py test(integration): give chaos and timing tests a harness API and gate raw signals (#46031) 2026-10-12 05:27:33 -07:00
test_team_model.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_team_new.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_team_permissions.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_team_permissions_bulk_update.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_team_spend_by_user.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_team_update.py feat(proxy): let proxy admins open team metadata to team admins, keeping proxy settings with proxy admins (#46506) 2026-10-14 23:51:44 +00:00
test_team_update_multi_instance.py fix(proxy): broadcast team cache invalidation on team writes (#46113) 2026-10-13 16:25:22 -04:00
test_tool_policy_user.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
test_user_delete_revokes_keys.py fix(proxy)!: label shared-handler errors the way the route catch-alls do (#39555) 2026-10-30 06:58:05 -07:00
test_user_list_sorting.py feat(ui): sort every users table data column (#48105) 2026-10-23 16:12:51 -07:00
test_user_rate_limit_updates.py fix(proxy): evict cached user on every proxy for tpm/rpm updates and edit limits in the users UI (#44130) 2026-10-07 16:02:32 -07:00
test_user_routes.py test: move 76 live top-level tests to offline unit and integration coverage (#45352) 2026-10-08 10:33:35 -07:00
test_user_updates_wedged_coordination_redis.py fix(rust_bridge): send warnings from unscoped native threads to the proxy log (#53539) 2026-11-23 17:53:52 +09:00
test_users_bulk_delete.py test: migrate tests/proxy_behavior into integration and unit tiers (#45939) 2026-10-11 08:28:42 -07:00
test_vector_store_config_ownership.py test(integration): stop GET /__observations from draining the upstream log (#47256) 2026-10-18 09:58:05 +00:00
test_vector_store_file_list_managed_ids.py fix(managed_files): keep the upload the managed id encodes when two target models share a deployment (#49420) 2026-11-03 00:58:41 +00:00