diff --git a/litellm/proxy/auth/team_grants.py b/litellm/proxy/auth/team_grants.py index 450a3ce456e..9db99d08762 100644 --- a/litellm/proxy/auth/team_grants.py +++ b/litellm/proxy/auth/team_grants.py @@ -7,6 +7,7 @@ callers kept losing grants (aliases, permissions, limits) one field at a time. B """ from collections.abc import Mapping, Sequence +from datetime import datetime, timezone from types import MappingProxyType from typing import Annotated, Final @@ -72,6 +73,7 @@ class TeamGrants(TypedDict, total=False): team_member_spend: ReadOnly[float | None] team_member_tpm_limit: ReadOnly[int | None] team_member_rpm_limit: ReadOnly[int | None] + team_member_max_budget: ReadOnly[float | None] def _json_columns(team_object: LiteLLM_TeamTable) -> _TeamJsonColumns: @@ -124,4 +126,9 @@ def team_grants( team_member_rpm_limit=( team_membership.safe_get_team_member_rpm_limit() if team_membership is not None else None ), + team_member_max_budget=( + team_membership.litellm_budget_table.effective_max_budget(now=datetime.now(timezone.utc)) + if team_membership is not None and team_membership.litellm_budget_table is not None + else None + ), ) diff --git a/tests/unit/proxy/auth/test_team_grants.py b/tests/unit/proxy/auth/test_team_grants.py index f74531beaf0..fe44303b971 100644 --- a/tests/unit/proxy/auth/test_team_grants.py +++ b/tests/unit/proxy/auth/test_team_grants.py @@ -50,7 +50,7 @@ def _membership() -> LiteLLM_TeamMembership: user_id=USER_ID, team_id=TEAM_ID, spend=3.25, - litellm_budget_table=LiteLLM_BudgetTable(tpm_limit=500, rpm_limit=5), + litellm_budget_table=LiteLLM_BudgetTable(tpm_limit=500, rpm_limit=5, max_budget=20.0), ) @@ -85,6 +85,7 @@ def test_team_grants_cover_every_team_field_the_key_path_gets(): assert token.team_member_spend == 3.25 assert token.team_member_tpm_limit == 500 assert token.team_member_rpm_limit == 5 + assert token.team_member_max_budget == 20.0 def test_team_grants_without_team_leave_token_defaults(): diff --git a/ui/litellm-dashboard/src/lib/http/schema.d.ts b/ui/litellm-dashboard/src/lib/http/schema.d.ts index 6f6eae1f98e..9deef6f64f2 100644 --- a/ui/litellm-dashboard/src/lib/http/schema.d.ts +++ b/ui/litellm-dashboard/src/lib/http/schema.d.ts @@ -49118,6 +49118,8 @@ export interface components { /** Team Max Budget */ team_max_budget?: number | null; team_member?: components["schemas"]["Member"] | null; + /** Team Member Max Budget */ + team_member_max_budget?: number | null; /** Team Member Rpm Limit */ team_member_rpm_limit?: number | null; /** Team Member Spend */