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]

Merge branch 'main' into feat/virtual-keys-team-table

Alejandro Tapia474eea5a1b58
diff --cc ui/litellm-dashboard/src/components/key_team_helpers/filter_helpers.ts
index 0a5590d78ce,b269ef5897f..97166f92735
--- a/ui/litellm-dashboard/src/components/key_team_helpers/filter_helpers.ts
+++ b/ui/litellm-dashboard/src/components/key_team_helpers/filter_helpers.ts
@@@ -2,104 -2,6 +2,85 @@@ import { teamListCall, organizationList
import { Team } from "./key_list";
import { Organization } from "../networking";
+export interface TeamFilterOptions {
+ keyAliases: string[];
+ organizationIds: string[];
+ userIds: Array<{ id: string; email: string }>;
+}
+
+const FILTER_OPTIONS_PAGE_SIZE = 100; // API max per page
+const MAX_PAGES = 50; // Cap at 5000 keys to avoid unbounded fetches
+
+/**
+ * Fetches filter options (key aliases, org IDs, user IDs) from all team keys.
+ * Paginates through pages to build complete dropdowns. Capped at 50 pages
+ * (5000 keys) to limit load for very large teams.
+ */
+export const fetchTeamFilterOptions = async (
+ accessToken: string | null,
+ teamId: string,
+): Promise<TeamFilterOptions> => {
+ if (!accessToken || !teamId) {
+ return { keyAliases: [], organizationIds: [], userIds: [] };
+ }
+
+ try {
+ const keyAliases = new Set<string>();
+ const organizationIds = new Set<string>();
+ const userMap = new Map<string, string>();
+
+ let page = 1;
+ let totalPages = 1;
+
+ do {
+ const response = await keyListCall(
+ accessToken,
+ null,
+ teamId,
+ null,
+ null,
+ null,
+ page,
+ FILTER_OPTIONS_PAGE_SIZE,
+ null,
+ null,
+ "user",
+ null,
+ );
+
+ const keys = response?.keys || [];
+ totalPages = response?.total_pages ?? 1;
+
+ for (const key of keys) {
+ const alias = key?.key_alias;
+ if (alias && typeof alias === "string") {
+ keyAliases.add(alias.trim());
+ }
+ const orgId = key?.organization_id;
+ if (orgId && typeof orgId === "string") {
+ organizationIds.add(orgId.trim());
+ }
+ const userId = key?.user_id;
+ if (userId && typeof userId === "string") {
+ const email = key?.user?.user_email || userId;
+ userMap.set(userId, email);
+ }
+ }
+
+ page++;
+ } while (page <= totalPages && page <= MAX_PAGES);
+
+ return {
+ keyAliases: Array.from(keyAliases).sort(),
+ organizationIds: Array.from(organizationIds).sort(),
+ userIds: Array.from(userMap.entries()).map(([id, email]) => ({ id, email })),
+ };
+ } catch (error) {
+ console.error("Error fetching team filter options:", error);
+ return { keyAliases: [], organizationIds: [], userIds: [] };
+ }
+};
+
- /**
- * Fetches all key aliases via the dedicated /key/aliases endpoint
- * @param accessToken The access token for API authentication
- * @returns Array of all unique key aliases
- */
- export const fetchAllKeyAliases = async (accessToken: string | null): Promise<string[]> => {
- if (!accessToken) return [];
-
- try {
- const { aliases } = await keyAliasesCall(accessToken as unknown as string);
- // Defensive dedupe & null-guard
- return Array.from(new Set((aliases || []).filter(Boolean)));
- } catch (error) {
- console.error("Error fetching all key aliases:", error);
- return [];
- }
- };
-
-
/**
* Fetches all teams across all pages
* @param accessToken The access token for API authentication