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]

Reusable model select

yuneng-jiang812ac7e83864
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/hooks/models/useModels.ts b/ui/litellm-dashboard/src/app/(dashboard)/hooks/models/useModels.ts
index 9c7ddf18f54..fa7ab911ecd 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/hooks/models/useModels.ts
+++ b/ui/litellm-dashboard/src/app/(dashboard)/hooks/models/useModels.ts
@@ -1,9 +1,23 @@
import { useQuery } from "@tanstack/react-query";
import { createQueryKeys } from "../common/queryKeysFactory";
-import { modelInfoCall, modelHubCall } from "@/components/networking";
+import { modelInfoCall, modelHubCall, modelAvailableCall } from "@/components/networking";
import useAuthorized from "../useAuthorized";
+
+export interface ProxyModel {
+ id: string;
+ object: string;
+ created: number;
+ owned_by: string;
+}
+
+export interface AllProxyModelsResponse {
+ data: ProxyModel[];
+}
+
const modelKeys = createQueryKeys("models");
const modelHubKeys = createQueryKeys("modelHub");
+const allProxyModelsKeys = createQueryKeys("allProxyModels");
+const selectedTeamModelsKeys = createQueryKeys("selectedTeamModels");
export const useModelsInfo = () => {
const { accessToken, userId, userRole } = useAuthorized();
@@ -27,3 +41,21 @@ export const useModelHub = () => {
enabled: Boolean(accessToken),
});
};
+
+export const useAllProxyModels = () => {
+ const { accessToken, userId, userRole } = useAuthorized();
+ return useQuery<AllProxyModelsResponse>({
+ queryKey: allProxyModelsKeys.list({}),
+ queryFn: async () => await modelAvailableCall(accessToken!, userId!, userRole!, true),
+ enabled: Boolean(accessToken && userId && userRole),
+ });
+};
+
+export const useSelectedTeamModels = (teamID: string | null) => {
+ const { accessToken, userId, userRole } = useAuthorized();
+ return useQuery<AllProxyModelsResponse>({
+ queryKey: selectedTeamModelsKeys.list({}),
+ queryFn: async () => await modelAvailableCall(accessToken!, userId!, userRole!, true, teamID!),
+ enabled: Boolean(accessToken && userId && userRole && teamID),
+ });
+};
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/hooks/organizations/useOrganizations.ts b/ui/litellm-dashboard/src/app/(dashboard)/hooks/organizations/useOrganizations.ts
index 27a946d112a..323270f4360 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/hooks/organizations/useOrganizations.ts
+++ b/ui/litellm-dashboard/src/app/(dashboard)/hooks/organizations/useOrganizations.ts
@@ -1,10 +1,9 @@
-import { useQuery, UseQueryResult } from "@tanstack/react-query";
-import { createQueryKeys } from "../common/queryKeysFactory";
-import { organizationListCall, Organization } from "@/components/networking";
import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
+import { Organization, organizationInfoCall, organizationListCall } from "@/components/networking";
+import { useQuery, useQueryClient, UseQueryResult } from "@tanstack/react-query";
+import { createQueryKeys } from "../common/queryKeysFactory";
const organizationKeys = createQueryKeys("organizations");
-
export const useOrganizations = (): UseQueryResult<Organization[]> => {
const { accessToken, userId, userRole } = useAuthorized();
return useQuery<Organization[]>({
@@ -13,3 +12,28 @@ export const useOrganizations = (): UseQueryResult<Organization[]> => {
enabled: Boolean(accessToken && userId && userRole),
});
};
+
+export const useOrganization = (organizationID?: string) => {
+ const queryClient = useQueryClient();
+ const { accessToken } = useAuthorized();
+ return useQuery<Organization>({
+ queryKey: organizationKeys.detail(organizationID!),
+ enabled: Boolean(accessToken && organizationID),
+
+ queryFn: async () => {
+ if (!accessToken || !organizationID) {
+ throw new Error("Missing auth or teamId");
+ }
+
+ return organizationInfoCall(accessToken, organizationID);
+ },
+
+ initialData: () => {
+ if (!organizationID) return undefined;
+
+ const organizations = queryClient.getQueryData<Organization[]>(organizationKeys.list({}));
+
+ return organizations?.find((organization: Organization) => organization.organization_id === organizationID);
+ },
+ });
+};
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/hooks/teams/useTeams.ts b/ui/litellm-dashboard/src/app/(dashboard)/hooks/teams/useTeams.ts
index 5d2008a4d29..2beebb18718 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/hooks/teams/useTeams.ts
+++ b/ui/litellm-dashboard/src/app/(dashboard)/hooks/teams/useTeams.ts
@@ -1,17 +1,41 @@
-import { useQuery, UseQueryResult } from "@tanstack/react-query";
+import { useQuery, useQueryClient, UseQueryResult } from "@tanstack/react-query";
import { Team } from "@/components/key_team_helpers/key_list";
import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
import { fetchTeams } from "@/app/(dashboard)/networking";
import { createQueryKeys } from "@/app/(dashboard)/hooks/common/queryKeysFactory";
+import { teamInfoCall } from "@/components/networking";
const teamKeys = createQueryKeys("teams");
-
export const useTeams = (): UseQueryResult<Team[]> => {
const { accessToken, userId, userRole } = useAuthorized();
-
return useQuery<Team[]>({
queryKey: teamKeys.list({}),
queryFn: async () => await fetchTeams(accessToken!, userId, userRole, null),
enabled: Boolean(accessToken),
});
};
+
+export const useTeam = (teamId?: string) => {
+ const { accessToken } = useAuthorized();
+ const queryClient = useQueryClient();
+ return useQuery<Team>({
+ queryKey: teamKeys.detail(teamId!),
+ enabled: Boolean(accessToken && teamId),
+
+ queryFn: async () => {
+ if (!accessToken || !teamId) {
+ throw new Error("Missing auth or teamId");
+ }
+
+ return teamInfoCall(accessToken, teamId);
+ },
+
+ initialData: () => {
+ if (!teamId) return undefined;
+
+ const teams = queryClient.getQueryData<Team[]>(teamKeys.list({}));
+
+ return teams?.find((team) => team.team_id === teamId);
+ },
+ });
+};
diff --git a/ui/litellm-dashboard/src/components/ModelSelect/ModelSelect.test.tsx b/ui/litellm-dashboard/src/components/ModelSelect/ModelSelect.test.tsx
new file mode 100644
index 00000000000..4afc6ea7d27
--- /dev/null
+++ b/ui/litellm-dashboard/src/components/ModelSelect/ModelSelect.test.tsx
@@ -0,0 +1,367 @@
+import { describe, it, expect, vi, beforeEach } from "vitest";
+import { screen, waitFor } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
+import { renderWithProviders } from "../../../tests/test-utils";
+import { ModelSelect } from "./ModelSelect";
+import type { ProxyModel } from "@/app/(dashboard)/hooks/models/useModels";
+import type { Organization } from "@/components/networking";
+import type { Team } from "@/components/key_team_helpers/key_list";
+
+vi.mock("@/app/(dashboard)/hooks/models/useModels", () => ({
+ useAllProxyModels: vi.fn(),
+}));
+
+vi.mock("@/app/(dashboard)/hooks/teams/useTeams", () => ({
+ useTeam: vi.fn(),
+}));
+
+vi.mock("@/app/(dashboard)/hooks/organizations/useOrganizations", () => ({
+ useOrganization: vi.fn(),
+}));
+
+vi.mock("antd", async (importOriginal) => {
+ const actual = await importOriginal<typeof import("antd")>();
+ return {
+ ...actual,
+ Select: ({
+ value,
+ onChange,
+ options,
+ "data-testid": dataTestId,
+ allowClear,
+ maxTagCount,
+ maxTagPlaceholder,
+ mode,
+ ...props
+ }: any) => {
+ return (
+ <div data-testid={dataTestId || "model-select"}>
+ <select
+ multiple={mode === "multiple"}
+ role="listbox"
+ value={value}
+ onChange={(e) => {
+ const selectedValues = Array.from(e.target.selectedOptions, (option) => option.value);
+ onChange(mode === "multiple" ? selectedValues : selectedValues[0]);
+ }}
+ {...props}
+ >
+ {options?.map((group: any) => (
+ <optgroup
+ key={group.label?.props?.children || group.title}
+ label={group.title || group.label?.props?.children}
+ >
+ {group.options?.map((option: any) => (
+ <option key={option.value} value={option.value} disabled={option.disabled}>
+ {typeof option.label === "string" ? option.label : option.label?.props?.children}
+ </option>
+ ))}
+ </optgroup>
+ ))}
+ </select>
+ </div>
+ );
+ },
+ Skeleton: {
+ Input: ({ active, block }: any) => <div data-testid="skeleton-input" data-active={active} data-block={block} />,
+ },
+ Tooltip: ({ children }: { children: React.ReactNode }) => <>{children}</>,
+ };
+});
+
+import { useAllProxyModels } from "@/app/(dashboard)/hooks/models/useModels";
+import { useTeam } from "@/app/(dashboard)/hooks/teams/useTeams";
+import { useOrganization } from "@/app/(dashboard)/hooks/organizations/useOrganizations";
+
+const mockUseAllProxyModels = vi.mocked(useAllProxyModels);
+const mockUseTeam = vi.mocked(useTeam);
+const mockUseOrganization = vi.mocked(useOrganization);
+
+describe("ModelSelect", () => {
+ const mockProxyModels: ProxyModel[] = [
+ { id: "gpt-4", object: "model", created: 1234567890, owned_by: "openai" },
+ { id: "claude-3", object: "model", created: 1234567890, owned_by: "anthropic" },
+ { id: "openai/*", object: "model", created: 1234567890, owned_by: "openai" },
+ { id: "anthropic/*", object: "model", created: 1234567890, owned_by: "anthropic" },
+ ];
+
+ const mockOnChange = vi.fn();
+
+ beforeEach(() => {
+ vi.clearAllMocks();
+ mockUseAllProxyModels.mockReturnValue({
+ data: { data: mockProxyModels },
+ isLoading: false,
+ } as any);
+ mockUseTeam.mockReturnValue({
+ data: undefined,
+ isLoading: false,
+ } as any);
+ mockUseOrganization.mockReturnValue({
+ data: undefined,
+ isLoading: false,
+ } as any);
+ });
+
+ it("should render", async () => {
+ renderWithProviders(<ModelSelect onChange={mockOnChange} showAllProxyModelsOverride={true} />);
+
+ await waitFor(() => {
+ expect(screen.getByTestId("model-select")).toBeInTheDocument();
+ });
+ });
+
+ it("should show skeleton loader when loading", () => {
+ mockUseAllProxyModels.mockReturnValue({
+ data: undefined,
+ isLoading: true,
+ } as any);
+
+ renderWithProviders(<ModelSelect onChange={mockOnChange} />);
+
+ expect(screen.getByTestId("skeleton-input")).toBeInTheDocument();
+ expect(screen.queryByTestId("model-select")).not.toBeInTheDocument();
+ });
+
+ it("should show skeleton loader when team is loading", () => {
+ mockUseTeam.mockReturnValue({
+ data: undefined,
+ isLoading: true,
+ } as any);
+
+ renderWithProviders(<ModelSelect onChange={mockOnChange} teamID="team-1" />);
+
+ expect(screen.getByTestId("skeleton-input")).toBeInTheDocument();
+ });
+
+ it("should show skeleton loader when organization is loading", () => {
+ mockUseOrganization.mockReturnValue({
+ data: undefined,
+ isLoading: true,
+ } as any);
+
+ renderWithProviders(<ModelSelect onChange={mockOnChange} organizationID="org-1" />);
+
+ expect(screen.getByTestId("skeleton-input")).toBeInTheDocument();
+ });
+
+ it("should render special options group", async () => {
+ renderWithProviders(<ModelSelect onChange={mockOnChange} />);
+
+ await waitFor(() => {
+ const select = screen.getByTestId("model-select");
+ expect(select).toBeInTheDocument();
+ expect(screen.getByText("All Proxy Models")).toBeInTheDocument();
+ expect(screen.getByText("No Default Models")).toBeInTheDocument();
+ });
+ });
+
+ it("should render wildcard options group", async () => {
+ renderWithProviders(<ModelSelect onChange={mockOnChange} showAllProxyModelsOverride={true} />);
+
+ await waitFor(() => {
+ expect(screen.getByText("All Openai models")).toBeInTheDocument();
+ expect(screen.getByText("All Anthropic models")).toBeInTheDocument();
+ });
+ });
+
+ it("should render regular models group", async () => {
+ renderWithProviders(<ModelSelect onChange={mockOnChange} showAllProxyModelsOverride={true} />);
+
+ await waitFor(() => {
+ expect(screen.getByText("gpt-4")).toBeInTheDocument();
+ expect(screen.getByText("claude-3")).toBeInTheDocument();
+ });
+ });
+
+ it("should call onChange when selecting a regular model", async () => {
+ const user = userEvent.setup();
+ renderWithProviders(<ModelSelect onChange={mockOnChange} showAllProxyModelsOverride={true} />);
+
+ await waitFor(() => {
+ expect(screen.getByTestId("model-select")).toBeInTheDocument();
+ });
+
+ const select = screen.getByRole("listbox");
+ await user.selectOptions(select, "gpt-4");
+
+ expect(mockOnChange).toHaveBeenCalledWith(["gpt-4"]);
+ });
+
+ it("should call onChange with only last special option when multiple special options are selected", async () => {
+ const user = userEvent.setup();
+ renderWithProviders(<ModelSelect onChange={mockOnChange} showAllProxyModelsOverride={true} />);
+
+ await waitFor(() => {
+ expect(screen.getByTestId("model-select")).toBeInTheDocument();
+ });
+
+ const select = screen.getByRole("listbox");
+ await user.selectOptions(select, ["all-proxy-models", "no-default-models"]);
+
+ expect(mockOnChange).toHaveBeenCalledWith(["no-default-models"]);
+ });
+
+ it("should disable regular models when special option is selected", async () => {
+ renderWithProviders(
+ <ModelSelect onChange={mockOnChange} value={["all-proxy-models"]} showAllProxyModelsOverride={true} />,
+ );
+
+ await waitFor(() => {
+ const gpt4Option = screen.getByRole("option", { name: "gpt-4" });
+ expect(gpt4Option).toBeDisabled();
+ });
+ });
+
+ it("should disable wildcard models when special option is selected", async () => {
+ renderWithProviders(
+ <ModelSelect onChange={mockOnChange} value={["all-proxy-models"]} showAllProxyModelsOverride={true} />,
+ );
+
+ await waitFor(() => {
+ const openaiWildcardOption = screen.getByRole("option", { name: "All Openai models" });
+ expect(openaiWildcardOption).toBeDisabled();
+ });
+ });
+
+ it("should disable other special options when one special option is selected", async () => {
+ renderWithProviders(
+ <ModelSelect onChange={mockOnChange} value={["all-proxy-models"]} showAllProxyModelsOverride={true} />,
+ );
+
+ await waitFor(() => {
+ const noDefaultOption = screen.getByRole("option", { name: "No Default Models" });
+ expect(noDefaultOption).toBeDisabled();
+ });
+ });
+
+ it("should filter models when showAllProxyModelsOverride is true", async () => {
+ renderWithProviders(<ModelSelect onChange={mockOnChange} showAllProxyModelsOverride={true} />);
+
+ await waitFor(() => {
+ expect(screen.getByText("gpt-4")).toBeInTheDocument();
+ expect(screen.getByText("claude-3")).toBeInTheDocument();
+ });
+ });
+
+ it("should filter models when organization has all-proxy-models in models array", async () => {
+ const mockOrganization: Organization = {
+ organization_id: "org-1",
+ organization_alias: "Test Org",
+ budget_id: "budget-1",
+ metadata: {},
+ models: ["all-proxy-models"],
+ spend: 0,
+ model_spend: {},
+ created_at: "2024-01-01",
+ created_by: "user-1",
+ updated_at: "2024-01-01",
+ updated_by: "user-1",
+ litellm_budget_table: null,
+ teams: null,
+ users: null,
+ members: null,
+ };
+
+ mockUseOrganization.mockReturnValue({
+ data: mockOrganization,
+ isLoading: false,
+ } as any);
+
+ renderWithProviders(<ModelSelect onChange={mockOnChange} organizationID="org-1" />);
+
+ await waitFor(() => {
+ expect(screen.getByText("gpt-4")).toBeInTheDocument();
+ expect(screen.getByText("claude-3")).toBeInTheDocument();
+ });
+ });
+
+ it("should return empty models array when organization does not have all-proxy-models", async () => {
+ const mockOrganization: Organization = {
+ organization_id: "org-1",
+ organization_alias: "Test Org",
+ budget_id: "budget-1",
+ metadata: {},
+ models: ["gpt-4"],
+ spend: 0,
+ model_spend: {},
+ created_at: "2024-01-01",
+ created_by: "user-1",
+ updated_at: "2024-01-01",
+ updated_by: "user-1",
+ litellm_budget_table: null,
+ teams: null,
+ users: null,
+ members: null,
+ };
+
+ mockUseOrganization.mockReturnValue({
+ data: mockOrganization,
+ isLoading: false,
+ } as any);
+
+ renderWithProviders(<ModelSelect onChange={mockOnChange} organizationID="org-1" />);
+
+ await waitFor(() => {
+ expect(screen.queryByText("gpt-4")).not.toBeInTheDocument();
+ expect(screen.queryByText("claude-3")).not.toBeInTheDocument();
+ });
+ });
+
+ it("should use custom dataTestId when provided", async () => {
+ renderWithProviders(
+ <ModelSelect onChange={mockOnChange} dataTestId="custom-test-id" showAllProxyModelsOverride={true} />,
+ );
+
+ await waitFor(() => {
+ expect(screen.getByTestId("custom-test-id")).toBeInTheDocument();
+ });
+ });
+
+ it("should handle multiple model selections", async () => {
+ const user = userEvent.setup();
+ renderWithProviders(<ModelSelect onChange={mockOnChange} showAllProxyModelsOverride={true} />);
+
+ await waitFor(() => {
+ expect(screen.getByTestId("model-select")).toBeInTheDocument();
+ });
+
+ const select = screen.getByRole("listbox");
+ await user.selectOptions(select, "gpt-4");
+ expect(mockOnChange).toHaveBeenCalledWith(["gpt-4"]);
+
+ await user.selectOptions(select, "claude-3");
+ expect(mockOnChange).toHaveBeenCalled();
+ const allCalls = mockOnChange.mock.calls.map((call) => call[0]);
+ expect(allCalls.some((call) => Array.isArray(call) && call.includes("gpt-4"))).toBe(true);
+ expect(allCalls.some((call) => Array.isArray(call) && call.includes("claude-3"))).toBe(true);
+ });
+
+ it("should capitalize provider name in wildcard options", async () => {
+ renderWithProviders(<ModelSelect onChange={mockOnChange} showAllProxyModelsOverride={true} />);
+
+ await waitFor(() => {
+ expect(screen.getByText("All Openai models")).toBeInTheDocument();
+ expect(screen.getByText("All Anthropic models")).toBeInTheDocument();
+ });
+ });
+
+ it("should deduplicate models with same id", async () => {
+ const duplicateModels: ProxyModel[] = [
+ { id: "gpt-4", object: "model", created: 1234567890, owned_by: "openai" },
+ { id: "gpt-4", object: "model", created: 1234567890, owned_by: "openai" },
+ ];
+
+ mockUseAllProxyModels.mockReturnValue({
+ data: { data: duplicateModels },
+ isLoading: false,
+ } as any);
+
+ renderWithProviders(<ModelSelect onChange={mockOnChange} showAllProxyModelsOverride={true} />);
+
+ await waitFor(() => {
+ const gpt4Options = screen.getAllByText("gpt-4");
+ expect(gpt4Options.length).toBeGreaterThan(0);
+ });
+ });
+});
diff --git a/ui/litellm-dashboard/src/components/ModelSelect/ModelSelect.tsx b/ui/litellm-dashboard/src/components/ModelSelect/ModelSelect.tsx
new file mode 100644
index 00000000000..5aa1ba6a30a
--- /dev/null
+++ b/ui/litellm-dashboard/src/components/ModelSelect/ModelSelect.tsx
@@ -0,0 +1,157 @@
+import { ProxyModel, useAllProxyModels } from "@/app/(dashboard)/hooks/models/useModels";
+import { useTeam } from "@/app/(dashboard)/hooks/teams/useTeams";
+import { Select, Skeleton, Tooltip, type SelectProps } from "antd";
+import { Organization, Team } from "../networking";
+import { useOrganization } from "@/app/(dashboard)/hooks/organizations/useOrganizations";
+import { splitWildcardModels } from "./modelUtils";
+
+const MODEL_SELECT_SPECIAL_VALUES = {
+ ALL_PROXY_MODELS: {
+ label: "All Proxy Models",
+ value: "all-proxy-models",
+ },
+ NO_DEFAULT_MODELS: {
+ label: "No Default Models",
+ value: "no-default-models",
+ },
+};
+
+const MODEL_SELECT_SPECIAL_VALUES_ARRAY = Object.values(MODEL_SELECT_SPECIAL_VALUES);
+
+export interface ModelSelectContext {
+ teamID?: string;
+ organizationID?: string;
+ includeUserModels?: boolean;
+ showAllTeamModelsOption?: boolean;
+ showAllProxyModelsOverride?: boolean;
+ includeSpecialOptions?: boolean;
+ dataTestId?: string;
+ value?: string[];
+ onChange: (values: string[]) => void;
+}
+
+const filterModels = (
+ allProxyModels: ProxyModel[],
+ ctx: ModelSelectContext,
+ {
+ selectedTeam,
+ selectedOrganization,
+ userModels,
+ }: { selectedTeam?: Team; selectedOrganization?: Organization; userModels?: ProxyModel[] },
+): ProxyModel[] => {
+ const deduplicatedProxyModels = Array.from(new Map(allProxyModels.map((model) => [model.id, model])).values());
+ if (ctx.showAllProxyModelsOverride) {
+ return deduplicatedProxyModels;
+ }
+
+ if (selectedOrganization) {
+ if (selectedOrganization.models.includes(MODEL_SELECT_SPECIAL_VALUES.ALL_PROXY_MODELS.value)) {
+ return deduplicatedProxyModels;
+ }
+ }
+
+ return [];
+};
+
+export const ModelSelect = (ctx: ModelSelectContext) => {
+ const {
+ teamID,
+ organizationID,
+ includeUserModels,
+ showAllTeamModelsOption,
+ showAllProxyModelsOverride,
+ includeSpecialOptions,
+ dataTestId,
+ value = [],
+ onChange,
+ } = ctx;
+ const { data: allProxyModels, isLoading: isLoadingAllProxyModels } = useAllProxyModels();
+ const { data: team, isLoading: isLoadingTeam } = useTeam(teamID);
+ const { data: organization, isLoading: isLoadingOrganization } = useOrganization(organizationID);
+
+ const isSpecialOption = (value: string) => MODEL_SELECT_SPECIAL_VALUES_ARRAY.some((sv) => sv.value === value);
+ const hasSpecialOptionSelected = value.some(isSpecialOption);
+ const isLoading = isLoadingAllProxyModels || isLoadingTeam || isLoadingOrganization;
+
+ if (isLoading) {
+ return <Skeleton.Input active block />;
+ }
+
+ const optionRender: NonNullable<SelectProps["optionRender"]> = (option) => {
+ return <span>{option.label}</span>;
+ };
+
+ const handleChange = (values: string[]) => {
+ const specialValues = values.filter(isSpecialOption);
+
+ let finalValues: string[];
+ if (specialValues.length > 0) {
+ const lastSelectedSpecial = specialValues[specialValues.length - 1];
+ finalValues = [lastSelectedSpecial];
+ } else {
+ finalValues = values;
+ }
+
+ onChange(finalValues);
+ };
+
+ const filteredModels = filterModels(allProxyModels?.data ?? [], ctx, {
+ selectedTeam: team,
+ selectedOrganization: organization,
+ });
+
+ const { wildcard, regular } = splitWildcardModels(filteredModels);
+ return (
+ <Select
+ data-testid={dataTestId}
+ value={value}
+ onChange={handleChange}
+ options={[
+ {
+ label: <span>Special Options</span>,
+ title: "Special Options",
+ options: MODEL_SELECT_SPECIAL_VALUES_ARRAY.map((specialValue) => ({
+ label: <span>{specialValue.label}</span>,
+ value: specialValue.value,
+ disabled: value.length > 0 && value.some((v) => isSpecialOption(v) && v !== specialValue.value),
+ key: specialValue.value,
+ })),
+ },
+ {
+ label: <span>Wildcard Options</span>,
+ title: "Wildcard Options",
+ options: wildcard.map((model) => {
+ const provider = model.id.replace("/*", "");
+ const capitalizedProvider = provider.charAt(0).toUpperCase() + provider.slice(1);
+
+ return {
+ label: <span>{`All ${capitalizedProvider} models`}</span>,
+ value: model.id,
+ disabled: hasSpecialOptionSelected,
+ };
+ }),
+ },
+ {
+ label: <span>Models</span>,
+ title: "Models",
+ options: regular.map((model) => ({
+ label: <span>{model.id}</span>,
+ value: model.id,
+ disabled: hasSpecialOptionSelected,
+ })),
+ },
+ ]}
+ mode="multiple"
+ allowClear
+ maxTagCount="responsive"
+ maxTagPlaceholder={(omittedValues) => (
+ <Tooltip
+ styles={{ root: { pointerEvents: "none" } }}
+ title={omittedValues.map(({ value }) => value).join(", ")}
+ >
+ <span>+{omittedValues.length} more</span>
+ </Tooltip>
+ )}
+ />
+ );
+};
diff --git a/ui/litellm-dashboard/src/components/ModelSelect/modelUtils.test.ts b/ui/litellm-dashboard/src/components/ModelSelect/modelUtils.test.ts
new file mode 100644
index 00000000000..90c21a5d11b
--- /dev/null
+++ b/ui/litellm-dashboard/src/components/ModelSelect/modelUtils.test.ts
@@ -0,0 +1,67 @@
+import { describe, it, expect } from "vitest";
+import { splitWildcardModels, type GroupedModels } from "./modelUtils";
+import type { ProxyModel } from "@/app/(dashboard)/hooks/models/useModels";
+
+describe("splitWildcardModels", () => {
+ it("should return empty arrays when given empty array", () => {
+ const result = splitWildcardModels([]);
+ expect(result).toEqual({ wildcard: [], regular: [] });
+ });
+
+ it("should split models into wildcard and regular groups", () => {
+ const models: ProxyModel[] = [
+ { id: "gpt-4", object: "model", created: 1234567890, owned_by: "openai" },
+ { id: "openai/*", object: "model", created: 1234567890, owned_by: "openai" },
+ { id: "claude-3", object: "model", created: 1234567890, owned_by: "anthropic" },
+ { id: "anthropic/*", object: "model", created: 1234567890, owned_by: "anthropic" },
+ ];
+
+ const result = splitWildcardModels(models);
+
+ expect(result.wildcard).toHaveLength(2);
+ expect(result.wildcard[0].id).toBe("openai/*");
+ expect(result.wildcard[1].id).toBe("anthropic/*");
+
+ expect(result.regular).toHaveLength(2);
+ expect(result.regular[0].id).toBe("gpt-4");
+ expect(result.regular[1].id).toBe("claude-3");
+ });
+
+ it("should return only wildcard models when all models are wildcard", () => {
+ const models: ProxyModel[] = [
+ { id: "openai/*", object: "model", created: 1234567890, owned_by: "openai" },
+ { id: "anthropic/*", object: "model", created: 1234567890, owned_by: "anthropic" },
+ ];
+
+ const result = splitWildcardModels(models);
+
+ expect(result.wildcard).toHaveLength(2);
+ expect(result.regular).toHaveLength(0);
+ });
+
+ it("should return only regular models when no models are wildcard", () => {
+ const models: ProxyModel[] = [
+ { id: "gpt-4", object: "model", created: 1234567890, owned_by: "openai" },
+ { id: "claude-3", object: "model", created: 1234567890, owned_by: "anthropic" },
+ ];
+
+ const result = splitWildcardModels(models);
+
+ expect(result.wildcard).toHaveLength(0);
+ expect(result.regular).toHaveLength(2);
+ });
+
+ it("should correctly identify wildcard models ending with /*", () => {
+ const models: ProxyModel[] = [
+ { id: "provider/*", object: "model", created: 1234567890, owned_by: "provider" },
+ { id: "not-wildcard", object: "model", created: 1234567890, owned_by: "provider" },
+ { id: "also-not/*/wildcard", object: "model", created: 1234567890, owned_by: "provider" },
+ ];
+
+ const result = splitWildcardModels(models);
+
+ expect(result.wildcard).toHaveLength(1);
+ expect(result.wildcard[0].id).toBe("provider/*");
+ expect(result.regular).toHaveLength(2);
+ });
+});
diff --git a/ui/litellm-dashboard/src/components/ModelSelect/modelUtils.ts b/ui/litellm-dashboard/src/components/ModelSelect/modelUtils.ts
new file mode 100644
index 00000000000..54d176bd443
--- /dev/null
+++ b/ui/litellm-dashboard/src/components/ModelSelect/modelUtils.ts
@@ -0,0 +1,21 @@
+import { ProxyModel } from "@/app/(dashboard)/hooks/models/useModels";
+
+export interface GroupedModels {
+ wildcard: ProxyModel[];
+ regular: ProxyModel[];
+}
+
+export const splitWildcardModels = (models: ProxyModel[]): GroupedModels => {
+ const wildcard: ProxyModel[] = [];
+ const regular: ProxyModel[] = [];
+
+ for (const model of models) {
+ if (model.id.endsWith("/*")) {
+ wildcard.push(model);
+ } else {
+ regular.push(model);
+ }
+ }
+
+ return { wildcard, regular };
+};
diff --git a/ui/litellm-dashboard/src/components/organizations.tsx b/ui/litellm-dashboard/src/components/organizations.tsx
index 991bf247a41..783a7282585 100644
--- a/ui/litellm-dashboard/src/components/organizations.tsx
+++ b/ui/litellm-dashboard/src/components/organizations.tsx
@@ -34,6 +34,7 @@ import { Organization, organizationCreateCall, organizationDeleteCall, organizat
import OrganizationInfoView from "./organization/organization_view";
import NumericalInput from "./shared/numerical_input";
import VectorStoreSelector from "./vector_store_management/VectorStoreSelector";
+import { ModelSelect } from "./ModelSelect/ModelSelect";
interface OrganizationsTableProps {
organizations: Organization[];
@@ -473,18 +474,12 @@ const OrganizationsTable: React.FC<OrganizationsTableProps> = ({
<TextInput placeholder="" />
</Form.Item>
<Form.Item label="Models" name="models">
- <Select2 mode="multiple" placeholder="Select models" style={{ width: "100%" }}>
- <Select2.Option key="all-proxy-models" value="all-proxy-models">
- All Proxy Models
- </Select2.Option>
- {userModels &&
- userModels.length > 0 &&
- userModels.map((model) => (
- <Select2.Option key={model} value={model}>
- {getModelDisplayName(model)}
- </Select2.Option>
- ))}
- </Select2>
+ <ModelSelect
+ showAllProxyModelsOverride
+ includeSpecialOptions
+ value={form.getFieldValue("models")}
+ onChange={(values) => form.setFieldValue("models", values)}
+ />
</Form.Item>
<Form.Item label="Max Budget (USD)" name="max_budget">