The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(ui): render team and org tpm/rpm limits of 0 as 0 instead of Unlimited (#37916)
yuneng-jiang5b1c142c6e2a
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/organizations/_components/OrganizationsTable.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/organizations/_components/OrganizationsTable.test.tsxindex a06c5c885e3..1ac33a27186 100644--- a/ui/litellm-dashboard/src/app/(dashboard)/organizations/_components/OrganizationsTable.test.tsx+++ b/ui/litellm-dashboard/src/app/(dashboard)/organizations/_components/OrganizationsTable.test.tsx@@ -165,6 +165,20 @@ describe("OrganizationsTable", () => {expect(screen.getByText("RPM: Unlimited")).toBeInTheDocument();});+ it("renders a tpm/rpm limit of 0 as 0, never as Unlimited", () => {+ render(+ <OrganizationsTable+ {...baseProps}+ organizations={[makeOrganization({ litellm_budget_table: { max_budget: null, tpm_limit: 0, rpm_limit: 0 } })]}+ />,+ );++ expect(screen.getByText("TPM: 0")).toBeInTheDocument();+ expect(screen.getByText("RPM: 0")).toBeInTheDocument();+ expect(screen.queryByText("TPM: Unlimited")).not.toBeInTheDocument();+ expect(screen.queryByText("RPM: Unlimited")).not.toBeInTheDocument();+ });+it("renders loading skeletons instead of rows while loading", () => {render(<OrganizationsTablediff --git a/ui/litellm-dashboard/src/app/(dashboard)/organizations/_components/OrganizationsTableColumns.tsx b/ui/litellm-dashboard/src/app/(dashboard)/organizations/_components/OrganizationsTableColumns.tsxindex 31f6a00916c..0fea6c6606e 100644--- a/ui/litellm-dashboard/src/app/(dashboard)/organizations/_components/OrganizationsTableColumns.tsx+++ b/ui/litellm-dashboard/src/app/(dashboard)/organizations/_components/OrganizationsTableColumns.tsx@@ -28,8 +28,8 @@ function OrganizationLimitsCell({ organization }: { organization: Organization }const { tpm_limit, rpm_limit } = getOrganizationBudget(organization);return (<div className="flex flex-col text-xs text-muted-foreground">- <span>TPM: {tpm_limit ? tpm_limit : "Unlimited"}</span>- <span>RPM: {rpm_limit ? rpm_limit : "Unlimited"}</span>+ <span>TPM: {tpm_limit ?? "Unlimited"}</span>+ <span>RPM: {rpm_limit ?? "Unlimited"}</span></div>);}diff --git a/ui/litellm-dashboard/src/components/organization/organization_view.test.tsx b/ui/litellm-dashboard/src/components/organization/organization_view.test.tsxindex 0337fea4131..b8d8e3ba9c8 100644--- a/ui/litellm-dashboard/src/components/organization/organization_view.test.tsx+++ b/ui/litellm-dashboard/src/components/organization/organization_view.test.tsx@@ -1,5 +1,5 @@import React from "react";-import { fireEvent, screen, waitFor } from "@testing-library/react";+import { fireEvent, screen, waitFor, within } from "@testing-library/react";import userEvent from "@testing-library/user-event";import { vi, test, expect, beforeEach } from "vitest";import { renderWithProviders } from "../../../tests/test-utils";@@ -290,3 +290,37 @@ test("should keep unsaved settings edits when switching tabs and back", async ()expect(screen.getByLabelText(/Organization Name/i)).toHaveValue("Renamed Org");});++test("renders a tpm/rpm limit of 0 as 0 in the overview and settings tabs, never as Unlimited", async () => {+ const zeroLimitOrg = {+ ...mockOrg,+ litellm_budget_table: { ...mockOrg.litellm_budget_table, tpm_limit: 0, rpm_limit: 0 },+ };+ mockUseOrganization.mockReturnValue({ data: zeroLimitOrg, isLoading: false } as unknown as ReturnType<+ typeof useOrganization+ >);++ const user = userEvent.setup();+ renderWithProviders(+ <OrganizationInfoView+ organizationId="org_123"+ onClose={() => {}}+ accessToken="test-token"+ is_org_admin={false}+ is_proxy_admin={true}+ userModels={[]}+ editOrg={false}+ />,+ );++ const overview = await screen.findByRole("tabpanel", { name: "Overview" });+ expect(within(overview).getByText("TPM: 0")).toBeInTheDocument();+ expect(within(overview).getByText("RPM: 0")).toBeInTheDocument();++ await user.click(screen.getByRole("tab", { name: "Settings" }));+ const settings = await screen.findByRole("tabpanel", { name: "Settings" });+ expect(within(settings).getByText("TPM: 0")).toBeInTheDocument();+ expect(within(settings).getByText("RPM: 0")).toBeInTheDocument();+ expect(screen.queryByText("TPM: Unlimited")).not.toBeInTheDocument();+ expect(screen.queryByText("RPM: Unlimited")).not.toBeInTheDocument();+});diff --git a/ui/litellm-dashboard/src/components/organization/organization_view.tsx b/ui/litellm-dashboard/src/components/organization/organization_view.tsxindex 2590f3bad52..7c250a5ef98 100644--- a/ui/litellm-dashboard/src/components/organization/organization_view.tsx+++ b/ui/litellm-dashboard/src/components/organization/organization_view.tsx@@ -206,8 +206,8 @@ const OrganizationInfoView: React.FC<OrganizationInfoProps> = ({<CardContent><p className="text-sm text-muted-foreground">Rate Limits</p><div className="mt-2 text-sm text-foreground">- <p>TPM: {orgData.litellm_budget_table.tpm_limit || "Unlimited"}</p>- <p>RPM: {orgData.litellm_budget_table.rpm_limit || "Unlimited"}</p>+ <p>TPM: {orgData.litellm_budget_table.tpm_limit ?? "Unlimited"}</p>+ <p>RPM: {orgData.litellm_budget_table.rpm_limit ?? "Unlimited"}</p>{orgData.litellm_budget_table.max_parallel_requests && (<p>Max Parallel Requests: {orgData.litellm_budget_table.max_parallel_requests}</p>)}@@ -311,8 +311,8 @@ const OrganizationInfoView: React.FC<OrganizationInfoProps> = ({</div><div><p className="font-medium text-foreground">Rate Limits</p>- <div>TPM: {orgData.litellm_budget_table.tpm_limit || "Unlimited"}</div>- <div>RPM: {orgData.litellm_budget_table.rpm_limit || "Unlimited"}</div>+ <div>TPM: {orgData.litellm_budget_table.tpm_limit ?? "Unlimited"}</div>+ <div>RPM: {orgData.litellm_budget_table.rpm_limit ?? "Unlimited"}</div></div><div><p className="font-medium text-foreground">Budget</p>diff --git a/ui/litellm-dashboard/src/components/team/EditMembership.integration.test.tsx b/ui/litellm-dashboard/src/components/team/EditMembership.integration.test.tsxindex b1dd3a2efcb..a82f475512c 100644--- a/ui/litellm-dashboard/src/components/team/EditMembership.integration.test.tsx+++ b/ui/litellm-dashboard/src/components/team/EditMembership.integration.test.tsx@@ -110,7 +110,7 @@ describe("EditMembership submit payload", () => {expect(submitted()).toStrictEqual(expected);});- it("collapses falsy budget and limit values to null and a missing model list to an empty array", async () => {+ it("keeps stored 0 budget and limits as 0 on an untouched save, collapsing only empty strings and a missing model list", async () => {renderEdit(teamMemberConfig, {user_id: "u1",user_email: "[email protected]",@@ -128,10 +128,10 @@ describe("EditMembership submit payload", () => {user_email: "[email protected]",user_id: "u1",role: "user",- max_budget_in_team: null,+ max_budget_in_team: 0,budget_duration: null,- tpm_limit: null,- rpm_limit: null,+ tpm_limit: 0,+ rpm_limit: 0,allowed_models: [],});});diff --git a/ui/litellm-dashboard/src/components/team/TeamInfo.test.tsx b/ui/litellm-dashboard/src/components/team/TeamInfo.test.tsxindex a7e8e6788dd..c3cc362e29e 100644--- a/ui/litellm-dashboard/src/components/team/TeamInfo.test.tsx+++ b/ui/litellm-dashboard/src/components/team/TeamInfo.test.tsx@@ -319,6 +319,34 @@ describe("TeamInfoView", () => {expect(screen.getByText(/of \$1,000\.00/)).toBeInTheDocument();});+ it("renders a tpm/rpm/budget limit of 0 as 0 in the overview and settings tabs, never as Unlimited or No Limit", async () => {+ vi.mocked(networking.teamInfoCall).mockResolvedValue(+ createMockTeamData({+ tpm_limit: 0,+ rpm_limit: 0,+ team_member_budget_table: { max_budget: 0, budget_duration: null, tpm_limit: 0, rpm_limit: 0 },+ }),+ );++ renderWithProviders(<TeamInfoView {...defaultProps} />);++ const overview = await screen.findByRole("tabpanel", { name: "Overview" });+ expect(within(overview).getByText("TPM: 0")).toBeInTheDocument();+ expect(within(overview).getByText("RPM: 0")).toBeInTheDocument();++ await userEvent.setup({ delay: null }).click(screen.getByRole("tab", { name: "Settings" }));+ const settings = await screen.findByRole("tabpanel", { name: "Settings" });+ expect(within(settings).getByText("TPM: 0")).toBeInTheDocument();+ expect(within(settings).getByText("RPM: 0")).toBeInTheDocument();+ expect(within(settings).getByText("TPM Limit: 0")).toBeInTheDocument();+ expect(within(settings).getByText("RPM Limit: 0")).toBeInTheDocument();+ expect(within(settings).getByText("Max Budget: 0")).toBeInTheDocument();+ expect(screen.queryByText("TPM: Unlimited")).not.toBeInTheDocument();+ expect(screen.queryByText("RPM: Unlimited")).not.toBeInTheDocument();+ expect(screen.queryByText("TPM Limit: No Limit")).not.toBeInTheDocument();+ expect(screen.queryByText("RPM Limit: No Limit")).not.toBeInTheDocument();+ });+it("should display guardrails in overview when present", async () => {vi.mocked(networking.teamInfoCall).mockResolvedValue(createMockTeamData({diff --git a/ui/litellm-dashboard/src/components/team/TeamInfo.tsx b/ui/litellm-dashboard/src/components/team/TeamInfo.tsxindex 727445e4fcd..88a893fd3e4 100644--- a/ui/litellm-dashboard/src/components/team/TeamInfo.tsx+++ b/ui/litellm-dashboard/src/components/team/TeamInfo.tsx@@ -971,8 +971,8 @@ const TeamInfoView: React.FC<TeamInfoProps> = ({<Card className="block p-6"><p>Rate Limits</p><div className="mt-2">- <p>TPM: {info.tpm_limit || "Unlimited"}</p>- <p>RPM: {info.rpm_limit || "Unlimited"}</p>+ <p>TPM: {info.tpm_limit ?? "Unlimited"}</p>+ <p>RPM: {info.rpm_limit ?? "Unlimited"}</p>{info.max_parallel_requests && <p>Max Parallel Requests: {info.max_parallel_requests}</p>}{(() => {const modelTpm = (info.metadata?.model_tpm_limit ?? {}) as Record<string, number>;@@ -1760,8 +1760,8 @@ const TeamInfoView: React.FC<TeamInfoProps> = ({</div><div><p className="font-medium">Rate Limits</p>- <div>TPM: {info.tpm_limit || "Unlimited"}</div>- <div>RPM: {info.rpm_limit || "Unlimited"}</div>+ <div>TPM: {info.tpm_limit ?? "Unlimited"}</div>+ <div>RPM: {info.rpm_limit ?? "Unlimited"}</div>{(() => {const modelTpm = (info.metadata?.model_tpm_limit ?? {}) as Record<string, number>;const modelRpm = (info.metadata?.model_rpm_limit ?? {}) as Record<string, number>;@@ -1811,11 +1811,11 @@ const TeamInfoView: React.FC<TeamInfoProps> = ({<Info className="ml-1 inline size-3.5 align-text-bottom" /></SimpleTooltip></p>- <div>Max Budget: {info.team_member_budget_table?.max_budget || "No Limit"}</div>+ <div>Max Budget: {info.team_member_budget_table?.max_budget ?? "No Limit"}</div><div>Budget Duration: {info.team_member_budget_table?.budget_duration || "No Limit"}</div><div>Key Duration: {info.metadata?.team_member_key_duration || "No Limit"}</div>- <div>TPM Limit: {info.team_member_budget_table?.tpm_limit || "No Limit"}</div>- <div>RPM Limit: {info.team_member_budget_table?.rpm_limit || "No Limit"}</div>+ <div>TPM Limit: {info.team_member_budget_table?.tpm_limit ?? "No Limit"}</div>+ <div>RPM Limit: {info.team_member_budget_table?.rpm_limit ?? "No Limit"}</div></div><div><p className="font-medium">Router Settings</p>diff --git a/ui/litellm-dashboard/src/components/team/TeamMemberTab.test.tsx b/ui/litellm-dashboard/src/components/team/TeamMemberTab.test.tsxindex 04234cf5a5e..6711514bfe9 100644--- a/ui/litellm-dashboard/src/components/team/TeamMemberTab.test.tsx+++ b/ui/litellm-dashboard/src/components/team/TeamMemberTab.test.tsx@@ -1,4 +1,4 @@-import { screen } from "@testing-library/react";+import { screen, within } from "@testing-library/react";import userEvent from "@testing-library/user-event";import { beforeEach, describe, expect, it, vi } from "vitest";import { renderWithProviders } from "../../../tests/test-utils";@@ -322,6 +322,43 @@ describe("TeamMembersComponent", () => {expect(mockSetSelectedEditMember).toHaveBeenCalled();});+ it("keeps a member's stored 0 limits as 0 in the table and in the edit payload, never unlimited", async () => {+ const user = userEvent.setup();+ vi.mocked(isProxyAdminRole).mockReturnValue(true);+ const baseTeamData = createMockTeamData();+ const teamData = {+ ...baseTeamData,+ team_memberships: baseTeamData.team_memberships.map((membership, index) =>+ index === 0+ ? {+ ...membership,+ litellm_budget_table: { ...membership.litellm_budget_table, max_budget: 0, tpm_limit: 0, rpm_limit: 0 },+ }+ : membership,+ ),+ };++ renderWithProviders(+ <TeamMembersComponent+ teamData={teamData}+ canEditTeam={true}+ handleMemberDelete={mockHandleMemberDelete}+ setSelectedEditMember={mockSetSelectedEditMember}+ setIsEditMemberModalVisible={mockSetIsEditMemberModalVisible}+ setIsAddMemberModalVisible={mockSetIsAddMemberModalVisible}+ />,+ );++ const memberRow = screen.getByRole("row", { name: /user1@test\.com/ });+ expect(within(memberRow).getByText("0 RPM / 0 TPM")).toBeInTheDocument();+ expect(within(memberRow).queryByText("No Limits")).not.toBeInTheDocument();++ await user.click(within(memberRow).getByTestId("edit-member"));++ const zeroLimitsMember = { user_id: "[email protected]", max_budget_in_team: 0, tpm_limit: 0, rpm_limit: 0 };+ expect(mockSetSelectedEditMember).toHaveBeenCalledWith(expect.objectContaining(zeroLimitsMember));+ });+it("should call setIsAddMemberModalVisible when Add Member button is clicked", async () => {const user = userEvent.setup();diff --git a/ui/litellm-dashboard/src/components/team/TeamMemberTab.tsx b/ui/litellm-dashboard/src/components/team/TeamMemberTab.tsxindex a662a02f91e..4d7246eb077 100644--- a/ui/litellm-dashboard/src/components/team/TeamMemberTab.tsx+++ b/ui/litellm-dashboard/src/components/team/TeamMemberTab.tsx@@ -71,8 +71,8 @@ export default function TeamMemberTab({const rpmLimit = membership?.litellm_budget_table?.rpm_limit;const tpmLimit = membership?.litellm_budget_table?.tpm_limit;- const rpmText = rpmLimit ? `${formatNumber(rpmLimit)} RPM` : null;- const tpmText = tpmLimit ? `${formatNumber(tpmLimit)} TPM` : null;+ const rpmText = rpmLimit != null ? `${formatNumber(rpmLimit)} RPM` : null;+ const tpmText = tpmLimit != null ? `${formatNumber(tpmLimit)} TPM` : null;const limits = [rpmText, tpmText].filter(Boolean);return limits.length > 0 ? limits.join(" / ") : "No Limits";@@ -191,9 +191,9 @@ export default function TeamMemberTab({const membership = teamData.team_memberships.find((tm) => tm.user_id === record.user_id);const enhancedMember = {...record,- max_budget_in_team: membership?.litellm_budget_table?.max_budget || null,- tpm_limit: membership?.litellm_budget_table?.tpm_limit || null,- rpm_limit: membership?.litellm_budget_table?.rpm_limit || null,+ max_budget_in_team: membership?.litellm_budget_table?.max_budget ?? null,+ tpm_limit: membership?.litellm_budget_table?.tpm_limit ?? null,+ rpm_limit: membership?.litellm_budget_table?.rpm_limit ?? null,budget_duration: membership?.litellm_budget_table?.budget_duration || null,allowed_models: membership?.litellm_budget_table?.allowed_models || [],};diff --git a/ui/litellm-dashboard/src/components/team/memberFormValues.test.ts b/ui/litellm-dashboard/src/components/team/memberFormValues.test.tsindex 398719c6197..7a1fcd85a80 100644--- a/ui/litellm-dashboard/src/components/team/memberFormValues.test.ts+++ b/ui/litellm-dashboard/src/components/team/memberFormValues.test.ts@@ -82,7 +82,7 @@ describe("buildMemberFormValues", () => {});});- it("collapses falsy budgets and limits to null and a missing model list to an empty array", () => {+ it("keeps a stored budget or limit of 0 as 0 because only null means unlimited", () => {expect(buildMemberFormValues("edit",@@ -90,6 +90,19 @@ describe("buildMemberFormValues", () => {teamConfig,),).toStrictEqual({+ user_email: "[email protected]",+ user_id: "u1",+ role: "user",+ max_budget_in_team: 0,+ budget_duration: null,+ tpm_limit: 0,+ rpm_limit: 0,+ allowed_models: [],+ });+ });++ it("collapses missing budgets and limits to null and a missing model list to an empty array", () => {+ const unlimitedMember = {user_email: "[email protected]",user_id: "u1",role: "user",@@ -98,7 +111,10 @@ describe("buildMemberFormValues", () => {tpm_limit: null,rpm_limit: null,allowed_models: [],- });+ };+ expect(+ buildMemberFormValues("edit", { user_email: "[email protected]", user_id: "u1", role: "user" }, teamConfig),+ ).toStrictEqual(unlimitedMember);});it("falls back to the configured default role when the member has none", () => {diff --git a/ui/litellm-dashboard/src/components/team/memberFormValues.ts b/ui/litellm-dashboard/src/components/team/memberFormValues.tsindex 942b9b665fe..51b8fac71c1 100644--- a/ui/litellm-dashboard/src/components/team/memberFormValues.ts+++ b/ui/litellm-dashboard/src/components/team/memberFormValues.ts@@ -43,9 +43,9 @@ export const buildMemberFormValues = (const seeded: MemberFormValues = {...initialData,role: (initialData.role as string) || config.defaultRole,- max_budget_in_team: initialData.max_budget_in_team || null,- tpm_limit: initialData.tpm_limit || null,- rpm_limit: initialData.rpm_limit || null,+ max_budget_in_team: initialData.max_budget_in_team ?? null,+ tpm_limit: initialData.tpm_limit ?? null,+ rpm_limit: initialData.rpm_limit ?? null,budget_duration: initialData.budget_duration || null,allowed_models: initialData.allowed_models || [],};