litellm/tests/test_litellm/proxy/utils/prisma_and_spend
yassin 260ff5f491 feat(team): team-level model_max_budget with key-level overrides
A team can now carry a per-model budget map that every key on the team
inherits. A key's own model_max_budget entry for the same model takes
precedence, so it is gated on and billed to the key alone.

Backend: NewTeamRequest/UpdateTeamRequest accept model_max_budget (validated
like the key-level field, enterprise gated); the value is hydrated onto
UserAPIKeyAuth via the token view, TeamGrants and the carried budget state;
_check_team_model_budget enforces it in the centralized common checks; the
limiter meters spend under team_model_spend:<team>:<model>:<duration> and
skips the team counter when the key overrides; /team/update lets only a
proxy admin raise, re-window or drop a cap; /team/info exposes usage.
The Anthropic context-management compaction summary subrequest runs the
same team gate. Both fallback token-view SQL definitions project the column.

UI: team create and edit forms reuse the key-level ModelMaxBudgetEditor,
premium gated, sending {} to clear and omitting unchanged fields.

A key entry overrides the team cap only when it spend-gates the model
(non-negative max_budget); a row that only carries tpm/rpm limits or a
negative cap leaves the team cap in force.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-16 00:40:58 +00:00
..
__init__.py test(proxy/utils): pin PrismaClient and spend-update behavior (#29488) 2026-06-02 17:45:28 -07:00
_harness_smoke_test.py test(proxy/utils): pin PrismaClient and spend-update behavior (#29488) 2026-06-02 17:45:28 -07:00
conftest.py fix(proxy): run SMTP send_email off the event loop with a connection timeout (#38473) 2026-08-29 16:05:57 -07:00
test_cache_user_row.py test(proxy/utils): pin PrismaClient and spend-update behavior (#29488) 2026-06-02 17:45:28 -07:00
test_config_param_cache.py test(proxy/utils): pin PrismaClient and spend-update behavior (#29488) 2026-06-02 17:45:28 -07:00
test_password_helpers.py test(proxy/utils): pin PrismaClient and spend-update behavior (#29488) 2026-06-02 17:45:28 -07:00
test_prisma_client_engine_watcher.py fix(proxy): recover Prisma DB reconnect loop when client is disconnected 2026-07-07 09:50:27 +03:00
test_prisma_client_get_data.py feat(team): team-level model_max_budget with key-level overrides 2026-09-16 00:40:58 +00:00
test_prisma_client_health.py fix(proxy): dedup latest health checks in SQL and gate the DB save per window 2026-09-03 11:33:44 +02:00
test_prisma_client_lifecycle.py feat(proxy): authenticate to Azure Postgres with Microsoft Entra ID tokens 2026-08-20 11:50:16 -07:00
test_prisma_client_reconnect.py fix(proxy): recreate the Prisma client when the writer session turns read-only (#40610) 2026-09-10 13:53:42 -07:00
test_prisma_client_writes.py fix(proxy): never log raw virtual keys in key insertion debug output (#33268) 2026-07-14 16:32:26 -07:00
test_proxy_update_spend.py fix(proxy): retry deadlocks and requeue spend logs on any DB write error (#39883) 2026-09-05 11:41:56 -07:00
test_send_email.py fix(proxy): run SMTP send_email off the event loop with a connection timeout (#38473) 2026-08-29 16:05:57 -07:00
test_spend_functions.py test(proxy): pin that a flush requested before the monitor starts costs the row nothing 2026-09-03 04:55:57 -07:00