From 331e3f22508ca52c62ff52b16ef8f7f330259a17 Mon Sep 17 00:00:00 2001 From: Ryan Crabbe Date: Wed, 22 Apr 2026 15:00:13 -0700 Subject: [PATCH 1/7] Surface per-member total spend in Teams > Members tab Adds a "Total Spend (USD)" column backed by the new membership.total_spend field. Cumulative across budget cycles; tracking began 2026-04-21. --- .../src/components/team/TeamInfo.tsx | 1 + .../src/components/team/TeamMemberTab.tsx | 13 ++++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ui/litellm-dashboard/src/components/team/TeamInfo.tsx b/ui/litellm-dashboard/src/components/team/TeamInfo.tsx index 909b079e6a..4bc7ff3ea8 100644 --- a/ui/litellm-dashboard/src/components/team/TeamInfo.tsx +++ b/ui/litellm-dashboard/src/components/team/TeamInfo.tsx @@ -60,6 +60,7 @@ export interface TeamMembership { team_id: string; budget_id: string; spend: number; + total_spend: number | null; litellm_budget_table: { budget_id: string; soft_budget: number | null; diff --git a/ui/litellm-dashboard/src/components/team/TeamMemberTab.tsx b/ui/litellm-dashboard/src/components/team/TeamMemberTab.tsx index e880aa49f6..7c9e47d9e1 100644 --- a/ui/litellm-dashboard/src/components/team/TeamMemberTab.tsx +++ b/ui/litellm-dashboard/src/components/team/TeamMemberTab.tsx @@ -45,11 +45,10 @@ export default function TeamMemberTab({ return "0"; }; - // Helper function to get spend for a user - const getUserSpend = (userId: string | null): number | null => { + const getUserTotalSpend = (userId: string | null): number => { if (!userId) return 0; const membership = teamData.team_memberships.find((tm) => tm.user_id === userId); - return membership?.spend || 0; + return membership?.total_spend ?? 0; }; const getUserBudget = (userId: string | null): string | null => { @@ -124,15 +123,15 @@ export default function TeamMemberTab({ { title: ( - Team Member Spend (USD) - + Total Spend (USD) + ), - key: "spend", + key: "total_spend", render: (_: unknown, record: Member) => ( - ${formatNumberWithCommas(getUserSpend(record.user_id), 4)} + ${formatNumberWithCommas(getUserTotalSpend(record.user_id), 4)} ), }, { From 5e5a94ac8d436fe191497dd3723d043dac25f5b2 Mon Sep 17 00:00:00 2001 From: Ryan Crabbe Date: Wed, 22 Apr 2026 17:28:05 -0700 Subject: [PATCH 2/7] Surface budget_reset_at on team info and members tab Adds a formatBudgetReset helper (dayjs-based, with validity guard) that renders the next reset as "today" / "in N days" / "on MMM D, YYYY". The team budget card now shows the team's reset timestamp and the member- default reset (when a shared team_member_budget is configured), and the Members tab gains a Budget Reset column per member. --- .../src/components/team/TeamInfo.tsx | 20 +++++++++++++++---- .../src/components/team/TeamMemberTab.tsx | 19 ++++++++++++++++++ ui/litellm-dashboard/src/utils/budgetUtils.ts | 13 ++++++++++++ 3 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 ui/litellm-dashboard/src/utils/budgetUtils.ts diff --git a/ui/litellm-dashboard/src/components/team/TeamInfo.tsx b/ui/litellm-dashboard/src/components/team/TeamInfo.tsx index 4bc7ff3ea8..04b9b53140 100644 --- a/ui/litellm-dashboard/src/components/team/TeamInfo.tsx +++ b/ui/litellm-dashboard/src/components/team/TeamInfo.tsx @@ -15,6 +15,7 @@ import { teamUpdateCall, } from "@/components/networking"; import { useGuardrails } from "@/app/(dashboard)/hooks/guardrails/useGuardrails"; +import { formatBudgetReset } from "@/utils/budgetUtils"; import { formatNumberWithCommas } from "@/utils/dataUtils"; import { mapEmptyStringToNull } from "@/utils/keyUpdateUtils"; import { isProxyAdminRole } from "@/utils/roles"; @@ -70,6 +71,7 @@ export interface TeamMembership { rpm_limit: number | null; model_max_budget: Record | null; budget_duration: string | null; + budget_reset_at: string | null; allowed_models?: string[] | null; }; } @@ -120,6 +122,7 @@ export interface TeamData { team_member_budget_table: { max_budget: number; budget_duration: string; + budget_reset_at: string | null; tpm_limit: number | null; rpm_limit: number | null; } | null; @@ -732,12 +735,21 @@ const TeamInfoView: React.FC = ({ of {info.max_budget === null ? "Unlimited" : `$${formatNumberWithCommas(info.max_budget, 4)}`} - {info.budget_duration && Reset: {info.budget_duration}} + {formatBudgetReset(info.budget_reset_at) && ( + Resets {formatBudgetReset(info.budget_reset_at)} + )}
{info.team_member_budget_table && ( - - Team Member Budget: ${formatNumberWithCommas(info.team_member_budget_table.max_budget, 4)} - + <> + + Team Member Budget: ${formatNumberWithCommas(info.team_member_budget_table.max_budget, 4)} + + {formatBudgetReset(info.team_member_budget_table.budget_reset_at) && ( + + Member budgets reset {formatBudgetReset(info.team_member_budget_table.budget_reset_at)} + + )} + )} diff --git a/ui/litellm-dashboard/src/components/team/TeamMemberTab.tsx b/ui/litellm-dashboard/src/components/team/TeamMemberTab.tsx index 7c9e47d9e1..e997875968 100644 --- a/ui/litellm-dashboard/src/components/team/TeamMemberTab.tsx +++ b/ui/litellm-dashboard/src/components/team/TeamMemberTab.tsx @@ -1,6 +1,7 @@ import { useUISettings } from "@/app/(dashboard)/hooks/uiSettings/useUISettings"; import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized"; import { Member } from "@/components/networking"; +import { formatBudgetReset } from "@/utils/budgetUtils"; import { formatNumberWithCommas } from "@/utils/dataUtils"; import { isProxyAdminRole, isUserTeamAdminForSingleTeam } from "@/utils/roles"; import { InfoCircleOutlined } from "@ant-design/icons"; @@ -88,6 +89,12 @@ export default function TeamMemberTab({ return models && models.length > 0 ? models : null; }; + const getUserBudgetReset = (userId: string | null): string | null => { + if (!userId) return null; + const membership = teamData.team_memberships.find((tm) => tm.user_id === userId); + return formatBudgetReset(membership?.litellm_budget_table?.budget_reset_at); + }; + const extraColumns: ColumnsType = [ { title: ( @@ -146,6 +153,18 @@ export default function TeamMemberTab({ ); }, }, + { + title: "Budget Reset", + key: "budget_reset", + render: (_: unknown, record: Member) => { + const reset = getUserBudgetReset(record.user_id); + return reset ? ( + {reset} + ) : ( + + ); + }, + }, { title: ( diff --git a/ui/litellm-dashboard/src/utils/budgetUtils.ts b/ui/litellm-dashboard/src/utils/budgetUtils.ts new file mode 100644 index 0000000000..ba13528bee --- /dev/null +++ b/ui/litellm-dashboard/src/utils/budgetUtils.ts @@ -0,0 +1,13 @@ +import dayjs from "dayjs"; + +export function formatBudgetReset(iso: string | null | undefined): string | null { + if (!iso) return null; + const resetDate = dayjs(iso); + if (!resetDate.isValid()) return null; + + const days = resetDate.diff(dayjs(), "day"); + if (days < 0) return `on ${resetDate.format("MMM D, YYYY")}`; + if (days === 0) return "today"; + if (days < 7) return `in ${days} day${days === 1 ? "" : "s"}`; + return `on ${resetDate.format("MMM D, YYYY")}`; +} From a23edd73b14aab0271349e1c4b811cb08d79f6df Mon Sep 17 00:00:00 2001 From: Ryan Crabbe Date: Wed, 22 Apr 2026 17:33:41 -0700 Subject: [PATCH 3/7] Restore Current Cycle Spend column on team members tab MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds back the per-cycle spend column that was replaced by Total Spend in 331e3f22. Current Cycle Spend reads membership.spend (zeroed on budget_reset_at) — this is the value enforced against the member's budget, so admins need it to see whether a member is approaching their cap for the active window. Total Spend remains for lifetime analytics. --- .../src/components/team/TeamMemberTab.tsx | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/ui/litellm-dashboard/src/components/team/TeamMemberTab.tsx b/ui/litellm-dashboard/src/components/team/TeamMemberTab.tsx index e997875968..1f2046fb90 100644 --- a/ui/litellm-dashboard/src/components/team/TeamMemberTab.tsx +++ b/ui/litellm-dashboard/src/components/team/TeamMemberTab.tsx @@ -46,6 +46,12 @@ export default function TeamMemberTab({ return "0"; }; + const getUserCurrentCycleSpend = (userId: string | null): number => { + if (!userId) return 0; + const membership = teamData.team_memberships.find((tm) => tm.user_id === userId); + return membership?.spend ?? 0; + }; + const getUserTotalSpend = (userId: string | null): number => { if (!userId) return 0; const membership = teamData.team_memberships.find((tm) => tm.user_id === userId); @@ -127,11 +133,25 @@ export default function TeamMemberTab({ ); }, }, + { + title: ( + + Current Cycle Spend (USD) + + + + + ), + key: "spend", + render: (_: unknown, record: Member) => ( + ${formatNumberWithCommas(getUserCurrentCycleSpend(record.user_id), 4)} + ), + }, { title: ( Total Spend (USD) - + From ac453c958ed438efe1fc63e9d3a315233de99a1e Mon Sep 17 00:00:00 2001 From: Ryan Crabbe Date: Wed, 22 Apr 2026 18:27:36 -0700 Subject: [PATCH 4/7] fix(team): surface budget_reset_at on /team/info and cloned member budgets Two independent bugs both masked budget_reset_at from consumers that needed it: 1. /team/info.team_member_budget_table was typed as LiteLLM_BudgetTable (the user-settable allowlist), which dropped server-managed fields. Switched to LiteLLM_BudgetTableFull so budget_reset_at and created_at are serialized. 2. _clone_team_default_budget_for_member copied the pool's numeric fields but never set budget_reset_at on the cloned row. With budget_duration present but no reset timestamp, the reset job never fires on the member's budget (its query is reset_at <= now, which never matches NULL). Now computes budget_reset_at from the cloned budget_duration via get_budget_reset_time so each member's cycle starts at clone time rather than inheriting the pool's stale reset. --- litellm/proxy/_types.py | 2 +- litellm/proxy/management_helpers/utils.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/litellm/proxy/_types.py b/litellm/proxy/_types.py index 84a9c4b793..f11b29103b 100644 --- a/litellm/proxy/_types.py +++ b/litellm/proxy/_types.py @@ -3907,7 +3907,7 @@ class OrganizationMemberUpdateResponse(MemberUpdateResponse): class TeamInfoResponseObjectTeamTable(LiteLLM_TeamTable): - team_member_budget_table: Optional[LiteLLM_BudgetTable] = None + team_member_budget_table: Optional[LiteLLM_BudgetTableFull] = None # Resources inherited from access groups (separate from direct assignments) access_group_models: Optional[List[str]] = None access_group_mcp_server_ids: Optional[List[str]] = None diff --git a/litellm/proxy/management_helpers/utils.py b/litellm/proxy/management_helpers/utils.py index 5cf53ae06f..f2d6e9612f 100644 --- a/litellm/proxy/management_helpers/utils.py +++ b/litellm/proxy/management_helpers/utils.py @@ -9,6 +9,7 @@ from fastapi import HTTPException, Request import litellm from litellm._logging import verbose_logger from litellm._uuid import uuid +from litellm.proxy.common_utils.timezone_utils import get_budget_reset_time from litellm.proxy._types import ( # key request types; user request types; team request types; customer request types BudgetNewRequest, DeleteCustomerRequest, @@ -192,6 +193,13 @@ async def _clone_team_default_budget_for_member( continue cloned_data[field] = value + # Start the member's budget window at clone time, not the pool's reset + # timestamp — otherwise a member joining mid-cycle inherits a stale reset. + if cloned_data.get("budget_duration"): + cloned_data["budget_reset_at"] = get_budget_reset_time( + cloned_data["budget_duration"] + ) + new_budget = await prisma_client.db.litellm_budgettable.create(data=cloned_data) return new_budget.budget_id From 1f6e01802de8a9485c5cc9965259865391ec4caf Mon Sep 17 00:00:00 2001 From: Ryan Crabbe Date: Thu, 23 Apr 2026 15:57:22 -0700 Subject: [PATCH 5/7] Show absolute date in Budget Reset column Relative labels ("today", "in 2 days", "on May 12, 2026") mixed three shapes in one column, breaking scannability. Always render MMM D, YYYY for consistency and easier at-a-glance comparison across members. --- ui/litellm-dashboard/src/utils/budgetUtils.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/ui/litellm-dashboard/src/utils/budgetUtils.ts b/ui/litellm-dashboard/src/utils/budgetUtils.ts index ba13528bee..3d3278db88 100644 --- a/ui/litellm-dashboard/src/utils/budgetUtils.ts +++ b/ui/litellm-dashboard/src/utils/budgetUtils.ts @@ -4,10 +4,5 @@ export function formatBudgetReset(iso: string | null | undefined): string | null if (!iso) return null; const resetDate = dayjs(iso); if (!resetDate.isValid()) return null; - - const days = resetDate.diff(dayjs(), "day"); - if (days < 0) return `on ${resetDate.format("MMM D, YYYY")}`; - if (days === 0) return "today"; - if (days < 7) return `in ${days} day${days === 1 ? "" : "s"}`; - return `on ${resetDate.format("MMM D, YYYY")}`; + return resetDate.format("MMM D, YYYY"); } From fbaedc36dcdd72fca9ac2379f53fa015d394b000 Mon Sep 17 00:00:00 2001 From: Ryan Crabbe Date: Thu, 23 Apr 2026 17:01:32 -0700 Subject: [PATCH 6/7] revert TeamInfo budget reset display changes Out of scope for the members-tab feature and regressed legacy teams whose budget_reset_at is null (duration was previously shown as a fallback). --- .../src/components/team/TeamInfo.tsx | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/ui/litellm-dashboard/src/components/team/TeamInfo.tsx b/ui/litellm-dashboard/src/components/team/TeamInfo.tsx index 04b9b53140..4bc7ff3ea8 100644 --- a/ui/litellm-dashboard/src/components/team/TeamInfo.tsx +++ b/ui/litellm-dashboard/src/components/team/TeamInfo.tsx @@ -15,7 +15,6 @@ import { teamUpdateCall, } from "@/components/networking"; import { useGuardrails } from "@/app/(dashboard)/hooks/guardrails/useGuardrails"; -import { formatBudgetReset } from "@/utils/budgetUtils"; import { formatNumberWithCommas } from "@/utils/dataUtils"; import { mapEmptyStringToNull } from "@/utils/keyUpdateUtils"; import { isProxyAdminRole } from "@/utils/roles"; @@ -71,7 +70,6 @@ export interface TeamMembership { rpm_limit: number | null; model_max_budget: Record | null; budget_duration: string | null; - budget_reset_at: string | null; allowed_models?: string[] | null; }; } @@ -122,7 +120,6 @@ export interface TeamData { team_member_budget_table: { max_budget: number; budget_duration: string; - budget_reset_at: string | null; tpm_limit: number | null; rpm_limit: number | null; } | null; @@ -735,21 +732,12 @@ const TeamInfoView: React.FC = ({ of {info.max_budget === null ? "Unlimited" : `$${formatNumberWithCommas(info.max_budget, 4)}`} - {formatBudgetReset(info.budget_reset_at) && ( - Resets {formatBudgetReset(info.budget_reset_at)} - )} + {info.budget_duration && Reset: {info.budget_duration}}
{info.team_member_budget_table && ( - <> - - Team Member Budget: ${formatNumberWithCommas(info.team_member_budget_table.max_budget, 4)} - - {formatBudgetReset(info.team_member_budget_table.budget_reset_at) && ( - - Member budgets reset {formatBudgetReset(info.team_member_budget_table.budget_reset_at)} - - )} - + + Team Member Budget: ${formatNumberWithCommas(info.team_member_budget_table.max_budget, 4)} + )} From 6b6b8c74186569c6c2b40b92a3a9db861c7745f0 Mon Sep 17 00:00:00 2001 From: Ryan Crabbe Date: Thu, 23 Apr 2026 17:07:21 -0700 Subject: [PATCH 7/7] restore budget_reset_at on TeamMembership type Members tab column reads this field; dropping it from the type in the previous revert broke the type check without affecting the reverted render logic. --- ui/litellm-dashboard/src/components/team/TeamInfo.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/litellm-dashboard/src/components/team/TeamInfo.tsx b/ui/litellm-dashboard/src/components/team/TeamInfo.tsx index 4bc7ff3ea8..302a3a02f1 100644 --- a/ui/litellm-dashboard/src/components/team/TeamInfo.tsx +++ b/ui/litellm-dashboard/src/components/team/TeamInfo.tsx @@ -70,6 +70,7 @@ export interface TeamMembership { rpm_limit: number | null; model_max_budget: Record | null; budget_duration: string | null; + budget_reset_at: string | null; allowed_models?: string[] | null; }; }