diff --git a/litellm/proxy/_types.py b/litellm/proxy/_types.py index 1f951605c5..7be1eb03f6 100644 --- a/litellm/proxy/_types.py +++ b/litellm/proxy/_types.py @@ -612,6 +612,8 @@ class UpdateTeamRequest(LiteLLMBase): max_budget: Optional[float] = None models: Optional[list] = None blocked: Optional[bool] = None + budget_duration: Optional[str] = None + budget_reset_at: Optional[datetime] = None class DeleteTeamRequest(LiteLLMBase): diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 4bac6ff3c4..136d379555 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -8035,7 +8035,7 @@ async def new_team( ## ADD TO TEAM TABLE # Check budget_duration and budget_reset_at - if data.budget_duration: + if data.budget_duration is not None: duration_s = _duration_in_seconds(duration=data.budget_duration) reset_at = datetime.now(timezone.utc) + timedelta(seconds=duration_s) @@ -8125,6 +8125,15 @@ async def update_team( detail={"error": f"Team not found, passed team_id={data.team_id}"}, ) + # Check budget_duration and budget_reset_at + if data.budget_duration is not None: + duration_s = _duration_in_seconds(duration=data.budget_duration) + reset_at = datetime.now(timezone.utc) + timedelta(seconds=duration_s) + + # set the budget duration and budget_reset_at in DB + data.budget_duration = duration_s + data.budget_reset_at = reset_at + updated_kv = data.json(exclude_none=True) team_row = await prisma_client.update_data( update_key_values=updated_kv,