Skip to content

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]

fix: show and allow editing team model aliases after team creation (#33047)

ryan-crabbe-berrie6d916b82e8a
diff --git a/litellm/proxy/management_endpoints/team_endpoints.py b/litellm/proxy/management_endpoints/team_endpoints.py
index f468f5ec30b..797f4600857 100644
--- a/litellm/proxy/management_endpoints/team_endpoints.py
+++ b/litellm/proxy/management_endpoints/team_endpoints.py
@@ -3550,7 +3550,7 @@ async def team_info(
try:
team_info: Optional[BaseModel] = await TeamRepository(prisma_client).table.find_unique(
where={"team_id": team_id},
- include={"object_permission": True},
+ include={"litellm_model_table": True, "object_permission": True},
)
if team_info is None:
raise Exception
diff --git a/tests/test_litellm/proxy/management_endpoints/test_team_endpoints.py b/tests/test_litellm/proxy/management_endpoints/test_team_endpoints.py
index 59b08a7ec4e..f7b2df45a85 100644
--- a/tests/test_litellm/proxy/management_endpoints/test_team_endpoints.py
+++ b/tests/test_litellm/proxy/management_endpoints/test_team_endpoints.py
@@ -18,6 +18,7 @@ sys.path.insert(
from litellm.proxy._types import UserAPIKeyAuth # Import UserAPIKeyAuth
from litellm.proxy._types import (
LiteLLM_BudgetTableFull,
+ LiteLLM_ModelTable,
LiteLLM_OrganizationMembershipTable,
LiteLLM_OrganizationTable,
LiteLLM_OrganizationTableWithMembers,
@@ -30,6 +31,7 @@ from litellm.proxy._types import (
ProxyErrorTypes,
ProxyException,
TeamMemberAddRequest,
+ UpdateTeamRequest,
)
from litellm.proxy.management_endpoints.team_endpoints import (
user_api_key_auth, # Assuming this dependency is needed
@@ -40,6 +42,7 @@ from litellm.proxy.management_endpoints.team_endpoints import (
_persist_deleted_team_records,
_save_deleted_team_records,
_transform_teams_to_deleted_records,
+ _update_model_table,
_validate_and_populate_member_user_info,
_verify_team_access,
delete_team,
@@ -9436,6 +9439,96 @@ async def test_team_info_forwards_key_limit_to_get_data():
assert mock_prisma.get_data.await_args.kwargs["limit"] == 7
+async def test_team_info_returns_model_aliases():
+ """/team/info must join LiteLLM_ModelTable so the response exposes the team's
+ current model aliases; without the ``litellm_model_table`` include the field
+ comes back null and the Admin UI can never display them.
+ """
+ from fastapi import Request
+
+ from litellm.proxy.management_endpoints import team_endpoints
+
+ team_row = LiteLLM_TeamTable(
+ team_id="team-1",
+ litellm_model_table=LiteLLM_ModelTable(
+ id=1,
+ model_aliases={"gpt-4o": "gpt-4o-team-1"},
+ created_by="admin",
+ updated_by="admin",
+ ),
+ )
+
+ mock_prisma = MagicMock()
+ mock_prisma.db.litellm_teamtable.find_unique = AsyncMock(return_value=team_row)
+ mock_prisma.get_data = AsyncMock(return_value=[])
+
+ with (
+ patch("litellm.proxy.proxy_server.prisma_client", mock_prisma),
+ patch.object(
+ team_endpoints, "get_all_team_memberships", AsyncMock(return_value=[])
+ ),
+ ):
+ response = await team_endpoints.team_info(
+ http_request=MagicMock(spec=Request),
+ team_id="team-1",
+ user_api_key_dict=UserAPIKeyAuth(user_role=LitellmUserRoles.PROXY_ADMIN),
+ )
+
+ include = mock_prisma.db.litellm_teamtable.find_unique.await_args.kwargs["include"]
+ assert include["litellm_model_table"] is True
+
+ litellm_model_table = response["team_info"].litellm_model_table
+ assert litellm_model_table is not None
+ assert litellm_model_table.model_aliases == {"gpt-4o": "gpt-4o-team-1"}
+
+
+async def test_update_model_table_clears_aliases_with_empty_map():
+ """``model_aliases={}`` on /team/update must persist an empty map (json.dumps({}))
+ so existing aliases are cleared, while ``model_aliases=None`` must be a no-op that
+ leaves the model table untouched.
+ """
+ mock_prisma = MagicMock()
+ mock_prisma.db.litellm_modeltable.create = AsyncMock()
+ mock_prisma.db.litellm_modeltable.upsert = AsyncMock(
+ return_value=MagicMock(id="model-123")
+ )
+ user_api_key_dict = UserAPIKeyAuth(
+ user_role=LitellmUserRoles.PROXY_ADMIN, user_id="admin"
+ )
+
+ returned_model_id = await _update_model_table(
+ data=UpdateTeamRequest(team_id="team-1", model_aliases={}),
+ model_id="model-123",
+ prisma_client=mock_prisma,
+ user_api_key_dict=user_api_key_dict,
+ litellm_proxy_admin_name="default_user_id",
+ )
+
+ mock_prisma.db.litellm_modeltable.upsert.assert_awaited_once()
+ upsert_kwargs = mock_prisma.db.litellm_modeltable.upsert.await_args.kwargs
+ assert upsert_kwargs["where"] == {"id": "model-123"}
+ assert upsert_kwargs["data"]["update"]["model_aliases"] == json.dumps({})
+ assert upsert_kwargs["data"]["create"]["model_aliases"] == json.dumps({})
+ assert returned_model_id == "model-123"
+
+ mock_prisma.db.litellm_modeltable.create.reset_mock()
+ mock_prisma.db.litellm_modeltable.upsert.reset_mock()
+
+ noop_model_id = await _update_model_table(
+ data=UpdateTeamRequest(team_id="team-1", model_aliases=None),
+ model_id="model-123",
+ prisma_client=mock_prisma,
+ user_api_key_dict=user_api_key_dict,
+ litellm_proxy_admin_name="default_user_id",
+ )
+
+ mock_prisma.db.litellm_modeltable.create.assert_not_called()
+ mock_prisma.db.litellm_modeltable.upsert.assert_not_called()
+ assert noop_model_id == "model-123"
+
+
class TestEmitTeamMembersMetric:
"""The _emit_team_members_metric seam between the team handlers and Prometheus."""
diff --git a/ui/litellm-dashboard/e2e_tests/helpers/navigation.ts b/ui/litellm-dashboard/e2e_tests/helpers/navigation.ts
index 6b5e7f7bb8d..a58ece16f9c 100644
--- a/ui/litellm-dashboard/e2e_tests/helpers/navigation.ts
+++ b/ui/litellm-dashboard/e2e_tests/helpers/navigation.ts
@@ -41,7 +41,7 @@ export async function dismissFeedbackPopup(page: PlaywrightPage): Promise<void>
/**
* Click on a team ID in the table. Team IDs are rendered differently depending
* on the component version — try button first (Tremor Button), fall back to
- * clickable span (OldTeams Typography.Text).
+ * clickable span (Teams Typography.Text).
*/
export async function clickTeamId(page: PlaywrightPage, teamId: string): Promise<void> {
const cell = page.locator("td").filter({ hasText: teamId }).first();
diff --git a/ui/litellm-dashboard/eslint-suppressions.json b/ui/litellm-dashboard/eslint-suppressions.json
index 3f6f4da25d0..ba2e2a375ca 100644
--- a/ui/litellm-dashboard/eslint-suppressions.json
+++ b/ui/litellm-dashboard/eslint-suppressions.json
@@ -1400,22 +1400,6 @@
"count": 1
}
},
- "src/components/OldTeams.test.tsx": {
- "max-nested-callbacks": {
- "count": 4
- }
- },
- "src/components/OldTeams.tsx": {
- "no-nested-ternary": {
- "count": 4
- },
- "no-restricted-imports": {
- "count": 1
- },
- "react-hooks/set-state-in-effect": {
- "count": 4
- }
- },
"src/components/SCIM.tsx": {
"no-restricted-imports": {
"count": 1
@@ -1506,6 +1490,22 @@
"count": 1
}
},
+ "src/components/Teams.test.tsx": {
+ "max-nested-callbacks": {
+ "count": 4
+ }
+ },
+ "src/components/Teams.tsx": {
+ "no-nested-ternary": {
+ "count": 4
+ },
+ "no-restricted-imports": {
+ "count": 1
+ },
+ "react-hooks/set-state-in-effect": {
+ "count": 4
+ }
+ },
"src/components/ToolDetail.tsx": {
"unused-imports/no-unused-imports": {
"count": 2
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/teams/page.tsx b/ui/litellm-dashboard/src/app/(dashboard)/teams/page.tsx
index 7d3f019e6e3..2d99041c1ce 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/teams/page.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/teams/page.tsx
@@ -1,9 +1,9 @@
"use client";
-import OldTeams from "@/components/OldTeams";
+import Teams from "@/components/Teams";
import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
export default function TeamsPage() {
const { accessToken, userId, userRole, premiumUser } = useAuthorized();
- return <OldTeams accessToken={accessToken} userID={userId} userRole={userRole} premiumUser={premiumUser ?? false} />;
+ return <Teams accessToken={accessToken} userID={userId} userRole={userRole} premiumUser={premiumUser ?? false} />;
}
diff --git a/ui/litellm-dashboard/src/components/OldTeams.test.tsx b/ui/litellm-dashboard/src/components/Teams.test.tsx
similarity index 92%
rename from ui/litellm-dashboard/src/components/OldTeams.test.tsx
rename to ui/litellm-dashboard/src/components/Teams.test.tsx
index 0b6e5786aaf..ee84e17d0c9 100644
--- a/ui/litellm-dashboard/src/components/OldTeams.test.tsx
+++ b/ui/litellm-dashboard/src/components/Teams.test.tsx
@@ -4,7 +4,7 @@ import React from "react";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { fetchAvailableModelsForTeamOrKey } from "./key_team_helpers/fetch_available_models_team_key";
import { fetchMCPAccessGroups, getGuardrailsList, teamCreateCall } from "./networking";
-import OldTeams from "./OldTeams";
+import Teams from "./Teams";
import { teamListCall } from "@/app/(dashboard)/hooks/teams/useTeams";
const mockTeamInfoView = vi.fn();
@@ -131,7 +131,7 @@ const renderWithQueryClient = (component: React.ReactElement) => {
return render(<QueryClientProvider client={queryClient}>{component}</QueryClientProvider>);
};
-describe("OldTeams - handleCreate organization handling", () => {
+describe("Teams - handleCreate organization handling", () => {
beforeEach(() => {
vi.clearAllMocks();
mockTeamInfoView.mockClear();
@@ -372,7 +372,7 @@ describe("OldTeams - handleCreate organization handling", () => {
page_size: 100,
total_pages: 1,
});
- renderWithQueryClient(<OldTeams accessToken="test-token" userID="user-123" userRole="Admin" />);
+ renderWithQueryClient(<Teams accessToken="test-token" userID="user-123" userRole="Admin" />);
await waitFor(() => {
expect(screen.getByTestId("delete-team-button")).toBeInTheDocument();
});
@@ -384,7 +384,7 @@ describe("OldTeams - handleCreate organization handling", () => {
});
});
-describe("OldTeams - empty state", () => {
+describe("Teams - empty state", () => {
beforeEach(() => {
vi.clearAllMocks();
mockUseOrganizations.mockReturnValue({ data: [] });
@@ -392,7 +392,7 @@ describe("OldTeams - empty state", () => {
it("should display empty state message when teams array is empty", async () => {
vi.mocked(teamListCall).mockResolvedValue({ teams: [], total: 0, page: 1, page_size: 100, total_pages: 1 });
- renderWithQueryClient(<OldTeams accessToken="test-token" userID="user-123" userRole="Admin" />);
+ renderWithQueryClient(<Teams accessToken="test-token" userID="user-123" userRole="Admin" />);
await waitFor(() => {
expect(screen.getByText("No teams yet")).toBeInTheDocument();
@@ -404,7 +404,7 @@ describe("OldTeams - empty state", () => {
it("should display empty state message when teams is null", async () => {
vi.mocked(teamListCall).mockResolvedValue({ teams: [], total: 0, page: 1, page_size: 100, total_pages: 1 });
- renderWithQueryClient(<OldTeams accessToken="test-token" userID="user-123" userRole="Admin" />);
+ renderWithQueryClient(<Teams accessToken="test-token" userID="user-123" userRole="Admin" />);
await waitFor(() => {
expect(screen.getByText("No teams yet")).toBeInTheDocument();
@@ -437,7 +437,7 @@ describe("OldTeams - empty state", () => {
page_size: 100,
total_pages: 1,
});
- renderWithQueryClient(<OldTeams accessToken="test-token" userID="user-123" userRole="Admin" />);
+ renderWithQueryClient(<Teams accessToken="test-token" userID="user-123" userRole="Admin" />);
await waitFor(() => {
expect(screen.getByText("Test Team")).toBeInTheDocument();
@@ -449,7 +449,7 @@ describe("OldTeams - empty state", () => {
});
});
-describe("OldTeams - helper functions", () => {
+describe("Teams - helper functions", () => {
describe("getAdminOrganizations", () => {
it("should return all organizations for Admin role", () => {
const organizations = [
@@ -575,7 +575,7 @@ describe("OldTeams - helper functions", () => {
});
});
-describe("OldTeams - premium props", () => {
+describe("Teams - premium props", () => {
beforeEach(() => {
mockTeamInfoView.mockClear();
vi.mocked(fetchAvailableModelsForTeamOrKey).mockResolvedValue([]);
@@ -607,7 +607,7 @@ describe("OldTeams - premium props", () => {
page_size: 100,
total_pages: 1,
});
- renderWithQueryClient(<OldTeams accessToken="test-token" userID="user-123" userRole="Admin" premiumUser={true} />);
+ renderWithQueryClient(<Teams accessToken="test-token" userID="user-123" userRole="Admin" premiumUser={true} />);
const teamIdElement = await screen.findByText("team-123456789");
act(() => {
@@ -620,7 +620,7 @@ describe("OldTeams - premium props", () => {
});
});
-describe("OldTeams - Default Team Settings tab visibility", () => {
+describe("Teams - Default Team Settings tab visibility", () => {
beforeEach(() => {
vi.clearAllMocks();
mockUseOrganizations.mockReturnValue({ data: [] });
@@ -649,7 +649,7 @@ describe("OldTeams - Default Team Settings tab visibility", () => {
page_size: 100,
total_pages: 1,
});
- renderWithQueryClient(<OldTeams accessToken="test-token" userID="user-123" userRole="Admin" />);
+ renderWithQueryClient(<Teams accessToken="test-token" userID="user-123" userRole="Admin" />);
expect(screen.getByRole("tab", { name: "Default Team Settings" })).toBeInTheDocument();
});
@@ -677,7 +677,7 @@ describe("OldTeams - Default Team Settings tab visibility", () => {
page_size: 100,
total_pages: 1,
});
- renderWithQueryClient(<OldTeams accessToken="test-token" userID="user-123" userRole="proxy_admin" />);
+ renderWithQueryClient(<Teams accessToken="test-token" userID="user-123" userRole="proxy_admin" />);
expect(screen.getByRole("tab", { name: "Default Team Settings" })).toBeInTheDocument();
});
@@ -705,7 +705,7 @@ describe("OldTeams - Default Team Settings tab visibility", () => {
page_size: 100,
total_pages: 1,
});
- renderWithQueryClient(<OldTeams accessToken="test-token" userID="user-123" userRole="proxy_admin_viewer" />);
+ renderWithQueryClient(<Teams accessToken="test-token" userID="user-123" userRole="proxy_admin_viewer" />);
expect(screen.queryByRole("tab", { name: "Default Team Settings" })).not.toBeInTheDocument();
});
@@ -733,13 +733,13 @@ describe("OldTeams - Default Team Settings tab visibility", () => {
page_size: 100,
total_pages: 1,
});
- renderWithQueryClient(<OldTeams accessToken="test-token" userID="user-123" userRole="Admin Viewer" />);
+ renderWithQueryClient(<Teams accessToken="test-token" userID="user-123" userRole="Admin Viewer" />);
expect(screen.queryByRole("tab", { name: "Default Team Settings" })).not.toBeInTheDocument();
});
});
-describe("OldTeams - access_group_ids in team create", () => {
+describe("Teams - access_group_ids in team create", () => {
beforeEach(() => {
vi.clearAllMocks();
mockTeamInfoView.mockClear();
@@ -762,7 +762,7 @@ describe("OldTeams - access_group_ids in team create", () => {
it("should pass access_group_ids to teamCreateCall when creating team", async () => {
vi.mocked(teamListCall).mockResolvedValue({ teams: [], total: 0, page: 1, page_size: 100, total_pages: 1 });
- renderWithQueryClient(<OldTeams accessToken="test-token" userID="user-123" userRole="Admin" />);
+ renderWithQueryClient(<Teams accessToken="test-token" userID="user-123" userRole="Admin" />);
const createButton = screen.getAllByRole("button", { name: /create team/i })[0];
act(() => {
@@ -806,7 +806,7 @@ describe("OldTeams - access_group_ids in team create", () => {
});
});
-describe("OldTeams - models dropdown options", () => {
+describe("Teams - models dropdown options", () => {
beforeEach(() => {
vi.clearAllMocks();
vi.mocked(fetchAvailableModelsForTeamOrKey).mockResolvedValue(["gpt-4", "gpt-3.5-turbo"]);
@@ -817,7 +817,7 @@ describe("OldTeams - models dropdown options", () => {
vi.mocked(fetchAvailableModelsForTeamOrKey).mockResolvedValue(["gpt-4", "gpt-3.5-turbo"]);
vi.mocked(teamListCall).mockResolvedValue({ teams: [], total: 0, page: 1, page_size: 100, total_pages: 1 });
- renderWithQueryClient(<OldTeams accessToken="test-token" userID="user-123" userRole="Admin" />);
+ renderWithQueryClient(<Teams accessToken="test-token" userID="user-123" userRole="Admin" />);
await waitFor(() => {
expect(fetchAvailableModelsForTeamOrKey).toHaveBeenCalled();
@@ -836,7 +836,7 @@ describe("OldTeams - models dropdown options", () => {
});
});
-describe("OldTeams - organization alias display", () => {
+describe("Teams - organization alias display", () => {
beforeEach(() => {
vi.clearAllMocks();
mockUseOrganizations.mockReturnValue({ data: [] });
@@ -887,7 +887,7 @@ describe("OldTeams - organization alias display", () => {
page_size: 100,
total_pages: 1,
});
- renderWithQueryClient(<OldTeams accessToken="test-token" userID="user-123" userRole="Admin" />);
+ renderWithQueryClient(<Teams accessToken="test-token" userID="user-123" userRole="Admin" />);
await waitFor(() => {
expect(screen.getByText("Test Organization")).toBeInTheDocument();
@@ -920,7 +920,7 @@ describe("OldTeams - organization alias display", () => {
page_size: 100,
total_pages: 1,
});
- renderWithQueryClient(<OldTeams accessToken="test-token" userID="user-123" userRole="Admin" />);
+ renderWithQueryClient(<Teams accessToken="test-token" userID="user-123" userRole="Admin" />);
await waitFor(() => {
expect(screen.getByText("org-unknown")).toBeInTheDocument();
@@ -952,7 +952,7 @@ describe("OldTeams - organization alias display", () => {
page_size: 100,
total_pages: 1,
});
- renderWithQueryClient(<OldTeams accessToken="test-token" userID="user-123" userRole="Admin" />);
+ renderWithQueryClient(<Teams accessToken="test-token" userID="user-123" userRole="Admin" />);
await waitFor(() => {
// When organization_id is null, the table shows "—" in the Organization column
@@ -961,7 +961,7 @@ describe("OldTeams - organization alias display", () => {
});
});
-describe("OldTeams - Resources column keys badge", () => {
+describe("Teams - Resources column keys badge", () => {
beforeEach(() => {
vi.clearAllMocks();
mockUseOrganizations.mockReturnValue({ data: [] });
@@ -991,9 +991,7 @@ describe("OldTeams - Resources column keys badge", () => {
page_size: 100,
total_pages: 1,
});
- const { container } = renderWithQueryClient(
- <OldTeams accessToken="test-token" userID="user-123" userRole="Admin" />,
- );
+ const { container } = renderWithQueryClient(<Teams accessToken="test-token" userID="user-123" userRole="Admin" />);
await waitFor(() => {
expect(screen.getByText("Team With Keys")).toBeInTheDocument();
@@ -1026,9 +1024,7 @@ describe("OldTeams - Resources column keys badge", () => {
page_size: 100,
total_pages: 1,
});
- const { container } = renderWithQueryClient(
- <OldTeams accessToken="test-token" userID="user-123" userRole="Admin" />,
- );
+ const { container } = renderWithQueryClient(<Teams accessToken="test-token" userID="user-123" userRole="Admin" />);
await waitFor(() => {
expect(screen.getByText("Legacy Team")).toBeInTheDocument();
@@ -1039,7 +1035,7 @@ describe("OldTeams - Resources column keys badge", () => {
});
});
-describe("OldTeams - delete team warning copy", () => {
+describe("Teams - delete team warning copy", () => {
beforeEach(() => {
vi.clearAllMocks();
mockUseOrganizations.mockReturnValue({ data: [] });
@@ -1053,7 +1049,7 @@ describe("OldTeams - delete team warning copy", () => {
page_size: 100,
total_pages: 1,
});
- renderWithQueryClient(<OldTeams accessToken="test-token" userID="user-123" userRole="Admin" />);
+ renderWithQueryClient(<Teams accessToken="test-token" userID="user-123" userRole="Admin" />);
await waitFor(() => {
expect(screen.getByTestId("delete-team-button")).toBeInTheDocument();
});
@@ -1098,7 +1094,7 @@ describe("OldTeams - delete team warning copy", () => {
});
});
-describe("OldTeams - LIT-2530 organization stays optional for proxy admin with a single org", () => {
+describe("Teams - LIT-2530 organization stays optional for proxy admin with a single org", () => {
beforeEach(() => {
vi.clearAllMocks();
mockTeamInfoView.mockClear();
@@ -1121,7 +1117,7 @@ describe("OldTeams - LIT-2530 organization stays optional for proxy admin with a
});
it("creates a team with no organization when exactly one organization exists", async () => {
- renderWithQueryClient(<OldTeams accessToken="test-token" userID="user-123" userRole="Admin" />);
+ renderWithQueryClient(<Teams accessToken="test-token" userID="user-123" userRole="Admin" />);
const createButton = screen.getAllByRole("button", { name: /create team/i })[0];
act(() => {
diff --git a/ui/litellm-dashboard/src/components/OldTeams.tsx b/ui/litellm-dashboard/src/components/Teams.tsx
similarity index 100%
rename from ui/litellm-dashboard/src/components/OldTeams.tsx
rename to ui/litellm-dashboard/src/components/Teams.tsx
diff --git a/ui/litellm-dashboard/src/components/team/TeamInfo.test.tsx b/ui/litellm-dashboard/src/components/team/TeamInfo.test.tsx
index f0e27607ffb..a57676d07b8 100644
--- a/ui/litellm-dashboard/src/components/team/TeamInfo.test.tsx
+++ b/ui/litellm-dashboard/src/components/team/TeamInfo.test.tsx
@@ -91,6 +91,16 @@ vi.mock("@/components/team/member_permissions", () => ({
default: vi.fn(() => <div>Member Permissions</div>),
}));
+vi.mock("@/components/common_components/ModelAliasManager", () => ({
+ default: vi.fn(({ initialModelAliases, onAliasUpdate }) => (
+ <div>
+ <div data-testid="alias-editor-initial">{JSON.stringify(initialModelAliases)}</div>
+ <button onClick={() => onAliasUpdate({ "gpt-4o": "gpt-4" })}>Set Alias</button>
+ <button onClick={() => onAliasUpdate({})}>Clear Aliases</button>
+ </div>
+ )),
+}));
+
vi.mock("@/app/(dashboard)/hooks/accessGroups/useAccessGroups", () => ({
useAccessGroups: vi.fn().mockReturnValue({
data: [
@@ -858,4 +868,160 @@ describe("TeamInfoView", () => {
});
});
});
+
+ describe("model aliases", () => {
+ const openSettingsEditor = async (user: ReturnType<typeof userEvent.setup>) => {
+ await waitFor(() => {
+ const teamNameElements = screen.queryAllByText("Test Team");
+ expect(teamNameElements.length).toBeGreaterThan(0);
+ });
+
+ await user.click(screen.getByRole("tab", { name: "Settings" }));
+
+ await waitFor(() => {
+ expect(screen.getByRole("button", { name: /edit settings/i })).toBeInTheDocument();
+ });
+
+ await user.click(screen.getByRole("button", { name: /edit settings/i }));
+
+ await waitFor(() => {
+ expect(screen.getByLabelText("Team Name")).toBeInTheDocument();
+ });
+ };
+
+ it("should render existing model aliases in the read-only settings view", async () => {
+ const user = userEvent.setup({ delay: null });
+ vi.mocked(networking.teamInfoCall).mockResolvedValue(
+ createMockTeamData({
+ litellm_model_table: { model_aliases: { "my-smart-model": "gpt-4", "my-fast-model": "gpt-3.5-turbo" } },
+ }),
+ );
+
+ renderWithProviders(<TeamInfoView {...defaultProps} />);
+
+ await waitFor(() => {
+ const teamNameElements = screen.queryAllByText("Test Team");
+ expect(teamNameElements.length).toBeGreaterThan(0);
+ });
+
+ await user.click(screen.getByRole("tab", { name: "Settings" }));
+
+ await waitFor(() => {
+ expect(screen.getByText("Team Settings")).toBeInTheDocument();
+ });
+
+ expect(screen.getByText("Model Aliases")).toBeInTheDocument();
+ expect(screen.getByText("my-smart-model")).toBeInTheDocument();
+ expect(screen.getByText("gpt-4")).toBeInTheDocument();
+ expect(screen.getByText("my-fast-model")).toBeInTheDocument();
+ expect(screen.getByText("gpt-3.5-turbo")).toBeInTheDocument();
+ });
+
+ it("should show an empty state when the team has no model aliases", async () => {
+ const user = userEvent.setup({ delay: null });
+ vi.mocked(networking.teamInfoCall).mockResolvedValue(createMockTeamData({ litellm_model_table: null }));
+
+ renderWithProviders(<TeamInfoView {...defaultProps} />);
+
+ await waitFor(() => {
+ const teamNameElements = screen.queryAllByText("Test Team");
+ expect(teamNameElements.length).toBeGreaterThan(0);
+ });
+
+ await user.click(screen.getByRole("tab", { name: "Settings" }));
+
+ await waitFor(() => {
+ expect(screen.getByText("Team Settings")).toBeInTheDocument();
+ });
+
+ expect(screen.getByText("No model aliases configured")).toBeInTheDocument();
+ });
+
+ it("should seed the alias editor from existing team aliases", async () => {
+ const user = userEvent.setup({ delay: null });
+ vi.mocked(networking.teamInfoCall).mockResolvedValue(
+ createMockTeamData({
+ models: ["gpt-4"],
+ litellm_model_table: { model_aliases: { "my-smart-model": "gpt-4" } },
+ }),
+ );
+
+ renderWithProviders(<TeamInfoView {...defaultProps} />);
+
+ await openSettingsEditor(user);
+
+ expect(screen.getByTestId("alias-editor-initial")).toHaveTextContent(
+ JSON.stringify({ "my-smart-model": "gpt-4" }),
+ );
+ });
+
+ it("should pass model_aliases to teamUpdateCall when aliases are added", async () => {
+ const user = userEvent.setup({ delay: null });
+ vi.mocked(networking.teamInfoCall).mockResolvedValue(createMockTeamData({ models: ["gpt-4"] }));
+ vi.mocked(networking.teamUpdateCall).mockResolvedValue({ data: {}, team_id: "123" } as any);
+
+ renderWithProviders(<TeamInfoView {...defaultProps} />);
+
+ await openSettingsEditor(user);
+
+ await user.click(screen.getByRole("button", { name: "Set Alias" }));
+ await user.click(screen.getByRole("button", { name: /save changes/i }));
+
+ await waitFor(() => {
+ expect(networking.teamUpdateCall).toHaveBeenCalledWith(
+ "test-token",
+ expect.objectContaining({
+ team_id: "123",
+ model_aliases: { "gpt-4o": "gpt-4" },
+ }),
+ );
+ });
+ });
+
+ it("should send an empty model_aliases map to clear existing aliases", async () => {
+ const user = userEvent.setup({ delay: null });
+ vi.mocked(networking.teamInfoCall).mockResolvedValue(
+ createMockTeamData({
+ models: ["gpt-4"],
+ litellm_model_table: { model_aliases: { "my-smart-model": "gpt-4" } },
+ }),
+ );
+ vi.mocked(networking.teamUpdateCall).mockResolvedValue({ data: {}, team_id: "123" } as any);
+
+ renderWithProviders(<TeamInfoView {...defaultProps} />);
+
+ await openSettingsEditor(user);
+
+ await user.click(screen.getByRole("button", { name: "Clear Aliases" }));
+ await user.click(screen.getByRole("button", { name: /save changes/i }));
+
+ await waitFor(() => {
+ expect(networking.teamUpdateCall).toHaveBeenCalled();
+ });
+
+ const payload = vi.mocked(networking.teamUpdateCall).mock.calls[0][1] as Record<string, unknown>;
+ expect(payload.model_aliases).toEqual({});
+ });
+
+ it("should not include model_aliases when the team has none and the editor is untouched", async () => {
+ const user = userEvent.setup({ delay: null });
+ vi.mocked(networking.teamInfoCall).mockResolvedValue(
+ createMockTeamData({ models: ["gpt-4"], litellm_model_table: null }),
+ );
+ vi.mocked(networking.teamUpdateCall).mockResolvedValue({ data: {}, team_id: "123" } as any);
+
+ renderWithProviders(<TeamInfoView {...defaultProps} />);
+
+ await openSettingsEditor(user);
+
+ await user.click(screen.getByRole("button", { name: /save changes/i }));
+
+ await waitFor(() => {
+ expect(networking.teamUpdateCall).toHaveBeenCalled();
+ });
+
+ const payload = vi.mocked(networking.teamUpdateCall).mock.calls[0][1] as Record<string, unknown>;
+ expect(payload).not.toHaveProperty("model_aliases");
+ });
+ });
});
diff --git a/ui/litellm-dashboard/src/components/team/TeamInfo.tsx b/ui/litellm-dashboard/src/components/team/TeamInfo.tsx
index 3b80c598d34..74f201b40c6 100644
--- a/ui/litellm-dashboard/src/components/team/TeamInfo.tsx
+++ b/ui/litellm-dashboard/src/components/team/TeamInfo.tsx
@@ -34,6 +34,7 @@ import { CheckIcon, CopyIcon } from "lucide-react";
import React, { useEffect, useMemo, useState } from "react";
import { copyToClipboard as utilCopyToClipboard } from "../../utils/dataUtils";
import AccessGroupSelector from "../common_components/AccessGroupSelector";
+import ModelAliasManager from "../common_components/ModelAliasManager";
import AgentSelector from "../agent_management/AgentSelector";
import DeleteResourceModal from "../common_components/DeleteResourceModal";
import DurationSelect from "../common_components/DurationSelect";
@@ -106,7 +107,7 @@ export interface TeamData {
budget_reset_at: string | null;
model_id: string | null;
litellm_model_table: {
- model_aliases: Record<string, string>;
+ model_aliases: Record<string, string> | null;
} | null;
created_at: string;
access_group_ids?: string[];
@@ -206,6 +207,7 @@ const TeamInfoView: React.FC<TeamInfoProps> = ({
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
const [isDeleting, setIsDeleting] = useState(false);
const [isTeamSaving, setIsTeamSaving] = useState(false);
+ const [teamModelAliases, setTeamModelAliases] = useState<Record<string, string>>({});
const routerSettingsRef = React.useRef<RouterSettingsAccordionRef>(null);
const [organization, setOrganization] = useState<Organization | null>(null);
const { userRole, userId } = useAuthorized();
@@ -619,6 +621,11 @@ const TeamInfoView: React.FC<TeamInfoProps> = ({
updateData.default_team_member_models = values.default_team_member_models;
}
+ const previousModelAliases = info.litellm_model_table?.model_aliases ?? {};
+ if (Object.keys(teamModelAliases).length > 0 || Object.keys(previousModelAliases).length > 0) {
+ updateData.model_aliases = teamModelAliases;
+ }
+
// Handle router_settings - read fresh values from DOM at save time.
const currentRouterSettings = routerSettingsRef.current?.getValue();
if (currentRouterSettings?.router_settings) {
@@ -905,7 +912,13 @@ const TeamInfoView: React.FC<TeamInfoProps> = ({
<div className="flex justify-between items-center mb-4">
<Title>Team Settings</Title>
{canEditTeam && !isEditing && (
- <Button icon={<EditOutlined className="h-4 w-4" />} onClick={() => setIsEditing(true)}>
+ <Button
+ icon={<EditOutlined className="h-4 w-4" />}
+ onClick={() => {
+ setTeamModelAliases(info.litellm_model_table?.model_aliases ?? {});
+ setIsEditing(true);
+ }}
+ >
Edit Settings
</Button>
)}
@@ -1026,6 +1039,24 @@ const TeamInfoView: React.FC<TeamInfoProps> = ({
/>
</Form.Item>
+ <Form.Item
+ label={
+ <span>
+ Model Aliases{" "}
+ <Tooltip title="Map a custom alias to an underlying model. Team members can call the alias in API requests instead of the real model name.">
+ <InfoCircleOutlined style={{ marginLeft: "4px" }} />
+ </Tooltip>
+ </span>
+ }
+ >
+ <ModelAliasManager
+ accessToken={accessToken || ""}
+ initialModelAliases={teamModelAliases}
+ onAliasUpdate={setTeamModelAliases}
+ showExampleConfig={false}
+ />
+ </Form.Item>
+
<Form.Item label="Max Budget (USD)" name="max_budget">
<NumericalInput step={0.01} precision={2} style={{ width: "100%" }} />
</Form.Item>
@@ -1520,6 +1551,26 @@ const TeamInfoView: React.FC<TeamInfoProps> = ({
</div>
</div>
)}
+ <div>
+ <Text className="font-medium">Model Aliases</Text>
+ {(() => {
+ const aliasEntries = Object.entries(info.litellm_model_table?.model_aliases ?? {});
+ if (aliasEntries.length === 0) {
+ return <div className="text-gray-400">No model aliases configured</div>;
+ }
+ return (
+ <div className="mt-1 space-y-1">
+ {aliasEntries.map(([alias, target]) => (
+ <div key={alias} className="text-sm">
+ <span className="font-mono">{alias}</span>
+ <span className="text-gray-400">{" -> "}</span>
+ <span className="font-mono">{target}</span>
+ </div>
+ ))}
+ </div>
+ );
+ })()}
+ </div>
<div>
<Text className="font-medium">Rate Limits</Text>
<div>TPM: {info.tpm_limit || "Unlimited"}</div>