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
Litellm UI stable version 02 12 2025 (#8497)
Krish Dholakia1195fe2a4483
diff --git a/litellm/proxy/_experimental/out/onboarding.html b/litellm/proxy/_experimental/out/onboarding.htmldeleted file mode 100644index 51290ebef10..00000000000--- a/litellm/proxy/_experimental/out/onboarding.html+++ /dev/null@@ -1 +0,0 @@-<!DOCTYPE html><html id="__next_error__"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/ui/_next/static/chunks/webpack-75a5453f51d60261.js"/><script src="/ui/_next/static/chunks/fd9d1056-f8f374bd771def60.js" async=""></script><script src="/ui/_next/static/chunks/117-2d8e84979f319d39.js" async=""></script><script src="/ui/_next/static/chunks/main-app-475d6efe4080647d.js" async=""></script><title>LiteLLM Dashboard</title><meta name="description" content="LiteLLM Proxy Admin UI"/><link rel="icon" href="/ui/favicon.ico" type="image/x-icon" sizes="16x16"/><meta name="next-size-adjust"/><script src="/ui/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body><script src="/ui/_next/static/chunks/webpack-75a5453f51d60261.js" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0]);self.__next_f.push([2,null])</script><script>self.__next_f.push([1,"1:HL[\"/ui/_next/static/media/a34f9d1faa5f3315-s.p.woff2\",\"font\",{\"crossOrigin\":\"\",\"type\":\"font/woff2\"}]\n2:HL[\"/ui/_next/static/css/86f6cc749f6b8493.css\",\"style\"]\n3:HL[\"/ui/_next/static/css/17e707d690fab559.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"4:I[12846,[],\"\"]\n6:I[19107,[],\"ClientPageRoot\"]\n7:I[12011,[\"665\",\"static/chunks/3014691f-6bdd9c4659caabcd.js\",\"42\",\"static/chunks/42-85111ce0453ddfcd.js\",\"755\",\"static/chunks/755-288e79da1358e7df.js\",\"250\",\"static/chunks/250-9fe99e6518e0255a.js\",\"461\",\"static/chunks/app/onboarding/page-c062a46fc186ad04.js\"],\"default\",1]\n8:I[4707,[],\"\"]\n9:I[36423,[],\"\"]\nb:I[61060,[],\"\"]\nc:[]\n"])</script><script>self.__next_f.push([1,"0:[\"$\",\"$L4\",null,{\"buildId\":\"u7jIPHZY9RhOYpS_V7EDA\",\"assetPrefix\":\"/ui\",\"urlParts\":[\"\",\"onboarding\"],\"initialTree\":[\"\",{\"children\":[\"onboarding\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],\"initialSeedData\":[\"\",{\"children\":[\"onboarding\",{\"children\":[\"__PAGE__\",{},[[\"$L5\",[\"$\",\"$L6\",null,{\"props\":{\"params\":{},\"searchParams\":{}},\"Component\":\"$7\"}],null],null],null]},[null,[\"$\",\"$L8\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"onboarding\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L9\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\"}]],null]},[[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/ui/_next/static/css/86f6cc749f6b8493.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}],[\"$\",\"link\",\"1\",{\"rel\":\"stylesheet\",\"href\":\"/ui/_next/static/css/17e707d690fab559.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}]],[\"$\",\"html\",null,{\"lang\":\"en\",\"children\":[\"$\",\"body\",null,{\"className\":\"__className_cf7686\",\"children\":[\"$\",\"$L8\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L9\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],\"notFoundStyles\":[]}]}]}]],null],null],\"couldBeIntercepted\":false,\"initialHead\":[null,\"$La\"],\"globalErrorComponent\":\"$b\",\"missingSlots\":\"$Wc\"}]\n"])</script><script>self.__next_f.push([1,"a:[[\"$\",\"meta\",\"0\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}],[\"$\",\"meta\",\"1\",{\"charSet\":\"utf-8\"}],[\"$\",\"title\",\"2\",{\"children\":\"LiteLLM Dashboard\"}],[\"$\",\"meta\",\"3\",{\"name\":\"description\",\"content\":\"LiteLLM Proxy Admin UI\"}],[\"$\",\"link\",\"4\",{\"rel\":\"icon\",\"href\":\"/ui/favicon.ico\",\"type\":\"image/x-icon\",\"sizes\":\"16x16\"}],[\"$\",\"meta\",\"5\",{\"name\":\"next-size-adjust\"}]]\n5:null\n"])</script></body></html>\ No newline at end of filediff --git a/litellm/proxy/_types.py b/litellm/proxy/_types.pyindex c98e5406128..00ea8fb7f49 100644--- a/litellm/proxy/_types.py+++ b/litellm/proxy/_types.py@@ -268,10 +268,11 @@ class LiteLLMRoutes(enum.Enum):"/v2/key/info","/model_group/info","/health",+ "/key/list",]# NOTE: ROUTES ONLY FOR MASTER KEY - only the Master Key should be able to Reset Spend- master_key_only_routes = ["/global/spend/reset", "/key/list"]+ master_key_only_routes = ["/global/spend/reset"]management_routes = [ # key"/key/generate",@@ -280,6 +281,7 @@ class LiteLLMRoutes(enum.Enum):"/key/delete","/key/info","/key/health",+ "/key/list",# user"/user/new","/user/update",@@ -1348,7 +1350,7 @@ class LiteLLM_VerificationToken(LiteLLMPydanticObjectBase):key_alias: Optional[str] = Nonespend: float = 0.0max_budget: Optional[float] = None- expires: Optional[str] = None+ expires: Optional[Union[str, datetime]] = Nonemodels: List = []aliases: Dict = {}config: Dict = {}diff --git a/litellm/proxy/management_endpoints/key_management_endpoints.py b/litellm/proxy/management_endpoints/key_management_endpoints.pyindex f0b8c84683c..fff4c16b2dc 100644--- a/litellm/proxy/management_endpoints/key_management_endpoints.py+++ b/litellm/proxy/management_endpoints/key_management_endpoints.py@@ -1676,6 +1676,52 @@ async def regenerate_key_fn(raise handle_exception_on_proxy(e)+def validate_key_list_check(+ complete_user_info: LiteLLM_UserTable,+ user_id: Optional[str],+ team_id: Optional[str],+ organization_id: Optional[str],+ key_alias: Optional[str],+):+ if complete_user_info.user_role == LitellmUserRoles.PROXY_ADMIN.value:+ return # proxy admin can see all keys++ # internal user can only see their own keys+ if user_id:+ if complete_user_info.user_id != user_id:+ raise ProxyException(+ message="You are not authorized to check another user's keys",+ type=ProxyErrorTypes.bad_request_error,+ param="user_id",+ code=status.HTTP_403_FORBIDDEN,+ )++ if team_id:+ if team_id not in complete_user_info.teams:+ raise ProxyException(+ message="You are not authorized to check this team's keys",+ type=ProxyErrorTypes.bad_request_error,+ param="team_id",+ code=status.HTTP_403_FORBIDDEN,+ )++ if organization_id:+ if (+ complete_user_info.organization_memberships is None+ or organization_id+ not in [+ membership.organization_id+ for membership in complete_user_info.organization_memberships+ ]+ ):+ raise ProxyException(+ message="You are not authorized to check this organization's keys",+ type=ProxyErrorTypes.bad_request_error,+ param="organization_id",+ code=status.HTTP_403_FORBIDDEN,+ )++@router.get("/key/list",tags=["key management"],@@ -1689,14 +1735,18 @@ async def list_keys(size: int = Query(10, description="Page size", ge=1, le=100),user_id: Optional[str] = Query(None, description="Filter keys by user ID"),team_id: Optional[str] = Query(None, description="Filter keys by team ID"),+ organization_id: Optional[str] = Query(+ None, description="Filter keys by organization ID"+ ),key_alias: Optional[str] = Query(None, description="Filter keys by key alias"),+ return_full_object: bool = Query(False, description="Return full key object"),) -> KeyListResponseObject:"""- List all keys for a given user or team.+ List all keys for a given user / team / organization.Returns:{- "keys": List[str],+ "keys": List[str] or List[UserAPIKeyAuth],"total_count": int,"current_page": int,"total_pages": int,@@ -1706,7 +1756,14 @@ async def list_keys(from litellm.proxy.proxy_server import prisma_client# Check for unsupported parameters- supported_params = {"page", "size", "user_id", "team_id", "key_alias"}+ supported_params = {+ "page",+ "size",+ "user_id",+ "team_id",+ "key_alias",+ "return_full_object",+ }unsupported_params = set(request.query_params.keys()) - supported_paramsif unsupported_params:raise ProxyException(@@ -1722,6 +1779,47 @@ async def list_keys(verbose_proxy_logger.error("Database not connected")raise Exception("Database not connected")+ if not user_api_key_dict.user_id:+ raise ProxyException(+ message="You are not authorized to access this endpoint. No 'user_id' is associated with your API key.",+ type=ProxyErrorTypes.bad_request_error,+ param="user_id",+ code=status.HTTP_403_FORBIDDEN,+ )++ complete_user_info: Optional[BaseModel] = (+ await prisma_client.db.litellm_usertable.find_unique(+ where={"user_id": user_api_key_dict.user_id},+ include={"organization_memberships": True},+ )+ )++ if complete_user_info is None:+ raise ProxyException(+ message="You are not authorized to access this endpoint. No 'user_id' is associated with your API key.",+ type=ProxyErrorTypes.bad_request_error,+ param="user_id",+ code=status.HTTP_403_FORBIDDEN,+ )++ complete_user_info_pydantic_obj = LiteLLM_UserTable(+ **complete_user_info.model_dump()+ )++ validate_key_list_check(+ complete_user_info=complete_user_info_pydantic_obj,+ user_id=user_id,+ team_id=team_id,+ organization_id=organization_id,+ key_alias=key_alias,+ )++ if user_id is None and complete_user_info_pydantic_obj.user_role != [+ LitellmUserRoles.PROXY_ADMIN.value,+ LitellmUserRoles.PROXY_ADMIN_VIEW_ONLY.value,+ ]:+ user_id = user_api_key_dict.user_id+response = await _list_key_helper(prisma_client=prisma_client,page=page,@@ -1729,6 +1827,7 @@ async def list_keys(user_id=user_id,team_id=team_id,key_alias=key_alias,+ return_full_object=return_full_object,)verbose_proxy_logger.debug("Successfully prepared response")@@ -1736,6 +1835,7 @@ async def list_keys(return responseexcept Exception as e:+ verbose_proxy_logger.exception(f"Error in list_keys: {e}")if isinstance(e, HTTPException):raise ProxyException(message=getattr(e, "detail", f"error({str(e)})"),diff --git a/ui/litellm-dashboard/src/app/page.tsx b/ui/litellm-dashboard/src/app/page.tsxindex 3a089bf8067..9fca59315d7 100644--- a/ui/litellm-dashboard/src/app/page.tsx+++ b/ui/litellm-dashboard/src/app/page.tsx@@ -4,7 +4,7 @@ import React, { Suspense, useEffect, useState } from "react";import { useSearchParams } from "next/navigation";import { jwtDecode } from "jwt-decode";import { QueryClient, QueryClientProvider } from "@tanstack/react-query";-+import { defaultOrg } from "@/components/common_components/default_org";import Navbar from "@/components/navbar";import UserDashboard from "@/components/user_dashboard";import ModelDashboard from "@/components/model_dashboard";@@ -78,7 +78,7 @@ export default function CreateKeyPage() {const [userEmail, setUserEmail] = useState<null | string>(null);const [teams, setTeams] = useState<null | any[]>(null);const [keys, setKeys] = useState<null | any[]>(null);- const [currentOrg, setCurrentOrg] = useState<Organization | null>(null);+ const [currentOrg, setCurrentOrg] = useState<Organization>(defaultOrg);const [organizations, setOrganizations] = useState<Organization[]>([]);const [proxySettings, setProxySettings] = useState<ProxySettings>({PROXY_BASE_URL: "",diff --git a/ui/litellm-dashboard/src/components/common_components/default_org.tsx b/ui/litellm-dashboard/src/components/common_components/default_org.tsxnew file mode 100644index 00000000000..a1c06a24395--- /dev/null+++ b/ui/litellm-dashboard/src/components/common_components/default_org.tsx@@ -0,0 +1,6 @@+import { Organization } from "../networking";++export const defaultOrg = {+ organization_id: null,+ organization_alias: "Default Organization"+} as Organization\ No newline at end of filediff --git a/ui/litellm-dashboard/src/components/key_team_helpers/key_list.tsx b/ui/litellm-dashboard/src/components/key_team_helpers/key_list.tsxnew file mode 100644index 00000000000..8bb7cf98b36--- /dev/null+++ b/ui/litellm-dashboard/src/components/key_team_helpers/key_list.tsx@@ -0,0 +1,144 @@+import { useState, useEffect } from 'react';+import { keyListCall, Organization } from '../networking';+interface Team {+team_id: string;+team_alias: string;+}++export interface KeyResponse {+token: string;+key_name: string;+key_alias: string;+spend: number;+max_budget: number;+expires: string;+models: string[];+aliases: Record<string, unknown>;+config: Record<string, unknown>;+user_id: string;+team_id: string | null;+max_parallel_requests: number;+metadata: Record<string, unknown>;+tpm_limit: number;+rpm_limit: number;+budget_duration: string;+budget_reset_at: string;+allowed_cache_controls: string[];+permissions: Record<string, unknown>;+model_spend: Record<string, number>;+model_max_budget: Record<string, number>;+soft_budget_cooldown: boolean;+blocked: boolean;+litellm_budget_table: Record<string, unknown>;+org_id: string | null;+created_at: string;+updated_at: string;+team_spend: number;+team_alias: string;+team_tpm_limit: number;+team_rpm_limit: number;+team_max_budget: number;+team_models: string[];+team_blocked: boolean;+soft_budget: number;+team_model_aliases: Record<string, string>;+team_member_spend: number;+team_member?: {+ user_id: string;+ user_email: string;+ role: 'admin' | 'user';+};+team_metadata: Record<string, unknown>;+end_user_id: string;+end_user_tpm_limit: number;+end_user_rpm_limit: number;+end_user_max_budget: number;+last_refreshed_at: number;+api_key: string;+user_role: 'proxy_admin' | 'user';+allowed_model_region?: 'eu' | 'us' | string;+parent_otel_span?: string;+rpm_limit_per_model: Record<string, number>;+tpm_limit_per_model: Record<string, number>;+user_tpm_limit: number;+user_rpm_limit: number;+user_email: string;+}++interface KeyListResponse {+keys: KeyResponse[];+total_count: number;+current_page: number;+total_pages: number;+}++interface UseKeyListProps {+selectedTeam?: Team;+currentOrg: Organization | null;+accessToken: string;+}++interface PaginationData {+currentPage: number;+totalPages: number;+totalCount: number;+}++interface UseKeyListReturn {+keys: KeyResponse[];+isLoading: boolean;+error: Error | null;+pagination: PaginationData;+refresh: (params?: Record<string, unknown>) => Promise<void>;+}++const useKeyList = ({ selectedTeam, currentOrg, accessToken }: UseKeyListProps): UseKeyListReturn => {+ const [keyData, setKeyData] = useState<KeyListResponse>({+ keys: [],+ total_count: 0,+ current_page: 1,+ total_pages: 0+ });+ const [isLoading, setIsLoading] = useState<boolean>(true);+ const [error, setError] = useState<Error | null>(null);++ const fetchKeys = async (params: Record<string, unknown> = {}): Promise<void> => {+ try {+ console.log("calling fetchKeys");+ if (!currentOrg || !selectedTeam || !accessToken) {+ console.log("currentOrg", currentOrg);+ console.log("selectedTeam", selectedTeam);+ console.log("accessToken", accessToken);+ return+ }+ setIsLoading(true);++ const data = await keyListCall(accessToken, currentOrg.organization_id, selectedTeam.team_id);+ console.log("data", data);+ setKeyData(data);+ setError(null);+ } catch (err) {+ setError(err instanceof Error ? err : new Error('An error occurred'));+ } finally {+ setIsLoading(false);+ }+ };++ useEffect(() => {+ fetchKeys();+ }, [selectedTeam, currentOrg]);++ return {+ keys: keyData.keys,+ isLoading,+ error,+ pagination: {+ currentPage: keyData.current_page,+ totalPages: keyData.total_pages,+ totalCount: keyData.total_count+ },+ refresh: fetchKeys+ };+};++export default useKeyList;\ No newline at end of filediff --git a/ui/litellm-dashboard/src/components/navbar.tsx b/ui/litellm-dashboard/src/components/navbar.tsxindex e304f931a34..e02706ec437 100644--- a/ui/litellm-dashboard/src/components/navbar.tsx+++ b/ui/litellm-dashboard/src/components/navbar.tsx@@ -2,9 +2,8 @@ import Link from "next/link";import React from "react";import type { MenuProps } from "antd";import { Dropdown } from "antd";-import { CogIcon } from "@heroicons/react/outline";import { Organization } from "@/components/networking";-+import { defaultOrg } from "@/components/common_components/default_org";interface NavbarProps {userID: string | null;userRole: string | null;@@ -75,10 +74,7 @@ const Navbar: React.FC<NavbarProps> = ({<span className="text-sm">Default Organization</span></div>),- onClick: () => onOrgChange({- organization_id: null,- organization_alias: "Default Organization"- } as Organization)+ onClick: () => onOrgChange(defaultOrg)},...organizations.filter(org => org.organization_id !== null).map(org => ({key: org.organization_id ?? "default",diff --git a/ui/litellm-dashboard/src/components/networking.tsx b/ui/litellm-dashboard/src/components/networking.tsxindex a59cf146007..f385423979a 100644--- a/ui/litellm-dashboard/src/components/networking.tsx+++ b/ui/litellm-dashboard/src/components/networking.tsx@@ -2075,6 +2075,58 @@ export const keyInfoCall = async (accessToken: String, keys: String[]) => {}};+export const keyListCall = async (+ accessToken: String,+ organizationID: string | null,+ teamID: string | null,+) => {+ /**+ * Get all available teams on proxy+ */+ try {+ let url = proxyBaseUrl ? `${proxyBaseUrl}/key/list` : `/key/list`;+ console.log("in keyListCall");+ const queryParams = new URLSearchParams();++ if (teamID) {+ queryParams.append('team_id', teamID.toString());+ }++ if (organizationID) {+ queryParams.append('organization_id', organizationID.toString());+ }++ queryParams.append('return_full_object', 'true');++ const queryString = queryParams.toString();+ if (queryString) {+ url += `?${queryString}`;+ }++ const response = await fetch(url, {+ method: "GET",+ headers: {+ [globalLitellmHeaderName]: `Bearer ${accessToken}`,+ "Content-Type": "application/json",+ },+ });++ if (!response.ok) {+ const errorData = await response.text();+ handleError(errorData);+ throw new Error("Network response was not ok");+ }++ const data = await response.json();+ console.log("/team/list API Response:", data);+ return data;+ // Handle success - you might want to update some state or UI based on the created key+ } catch (error) {+ console.error("Failed to create key:", error);+ throw error;+ }+};+export const spendUsersCall = async (accessToken: String, userID: String) => {try {const url = proxyBaseUrl ? `${proxyBaseUrl}/spend/users` : `/spend/users`;diff --git a/ui/litellm-dashboard/src/components/view_key_table.tsx b/ui/litellm-dashboard/src/components/view_key_table.tsxindex ad90932cac1..012782b8bf7 100644--- a/ui/litellm-dashboard/src/components/view_key_table.tsx+++ b/ui/litellm-dashboard/src/components/view_key_table.tsx@@ -69,8 +69,10 @@ import {import { CopyToClipboard } from "react-copy-to-clipboard";import TextArea from "antd/es/input/TextArea";-+import useKeyList from "./key_team_helpers/key_list";+import { KeyResponse } from "./key_team_helpers/key_list";const { Option } = Select;+const isLocal = process.env.NODE_ENV === "development";const proxyBaseUrl = isLocal ? "http://localhost:4000" : null;if (isLocal != true) {@@ -87,7 +89,7 @@ interface EditKeyModalProps {interface ModelLimitModalProps {visible: boolean;onCancel: () => void;- token: ItemData;+ token: KeyResponse;onSubmit: (updatedMetadata: any) => void;accessToken: string;}@@ -125,6 +127,19 @@ interface ItemData {// Add any other properties that exist in the item data}+interface ModelLimits {+ [key: string]: number; // Index signature allowing string keys+}++interface CombinedLimit {+ tpm: number;+ rpm: number;+}++interface CombinedLimits {+ [key: string]: CombinedLimit; // Index signature allowing string keys+}+const ViewKeyTable: React.FC<ViewKeyTableProps> = ({userID,userRole,@@ -139,15 +154,22 @@ const ViewKeyTable: React.FC<ViewKeyTableProps> = ({const [isButtonClicked, setIsButtonClicked] = useState(false);const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);const [keyToDelete, setKeyToDelete] = useState<string | null>(null);- const [selectedItem, setSelectedItem] = useState<ItemData | null>(null);+ const [selectedItem, setSelectedItem] = useState<KeyResponse | null>(null);const [spendData, setSpendData] = useState<{ day: string; spend: number }[] | null>(null);- const [predictedSpendString, setPredictedSpendString] = useState("");++ const { keys, isLoading, error, refresh } = useKeyList({+ selectedTeam,+ currentOrg,+ accessToken+ });++ console.log("keys", keys);const [editModalVisible, setEditModalVisible] = useState(false);const [infoDialogVisible, setInfoDialogVisible] = useState(false);- const [selectedToken, setSelectedToken] = useState<ItemData | null>(null);+ const [selectedToken, setSelectedToken] = useState<KeyResponse | null>(null);const [userModels, setUserModels] = useState<string[]>([]);const initialKnownTeamIDs: Set<string> = new Set();const [modelLimitModalVisible, setModelLimitModalVisible] = useState(false);@@ -160,75 +182,6 @@ const ViewKeyTable: React.FC<ViewKeyTableProps> = ({const [knownTeamIDs, setKnownTeamIDs] = useState(initialKnownTeamIDs);const [guardrailsList, setGuardrailsList] = useState<string[]>([]);- // Function to check if user is admin of a team- const isUserTeamAdmin = (team: any) => {- if (!team.members_with_roles) return false;- return team.members_with_roles.some(- (member: any) => member.role === "admin" && member.user_id === userID- );- };-- // Combine all keys that user should have access to- const all_keys_to_display = React.useMemo(() => {- if (!data) return [];-- // Helper function for default team org check- const matchesDefaultTeamOrg = (key: any) => {- console.log(`Checking if key matches default team org: ${JSON.stringify(key)}, currentOrg: ${JSON.stringify(currentOrg)}`)- if (!currentOrg || currentOrg.organization_id === null) {- return !('organization_id' in key) || key.organization_id === null;- }- return key.organization_id === currentOrg.organization_id;- };-- let allKeys: any[] = [];-- // Handle no team selected or Default Team case- if (!selectedTeam || selectedTeam.team_alias === "Default Team") {-- console.log(`inside personal keys`)- // Get personal keys (with org check)- const personalKeys = data.filter(key =>- key.team_id == null &&- matchesDefaultTeamOrg(key)- );-- console.log(`personalKeys: ${JSON.stringify(personalKeys)}`)-- // Get admin team keys (no org check)- const adminTeamKeys = data.filter(key => {- const keyTeam = teams?.find(team => team.team_id === key.team_id);- return keyTeam && isUserTeamAdmin(keyTeam) && key.team_id !== "default-team";- });-- console.log(`adminTeamKeys: ${JSON.stringify(adminTeamKeys)}`)-- allKeys = [...personalKeys, ...adminTeamKeys];- }- // Handle specific team selected- else {- const selectedTeamData = teams?.find(t => t.team_id === selectedTeam.team_id);- if (selectedTeamData) {- const teamKeys = data.filter(key => {- if (selectedTeamData.team_id === "default-team") {- return key.team_id == null && matchesDefaultTeamOrg(key);- }- return key.team_id === selectedTeamData.team_id;- });- allKeys = teamKeys;- }- }-- // Final filtering and deduplication- return Array.from(- new Map(- allKeys- .filter(key => key.team_id !== "litellm-dashboard")- .map(key => [key.token, key])- ).values()- );- }, [data, teams, selectedTeam, currentOrg]);-useEffect(() => {const calculateNewExpiryTime = (duration: string | undefined) => {if (!duration) {@@ -298,7 +251,7 @@ const ViewKeyTable: React.FC<ViewKeyTableProps> = ({fetchUserModels();}, [accessToken, userID, userRole]);- const handleModelLimitClick = (token: ItemData) => {+ const handleModelLimitClick = (token: KeyResponse) => {setSelectedToken(token);setModelLimitModalVisible(true);};@@ -668,13 +621,12 @@ const ViewKeyTable: React.FC<ViewKeyTableProps> = ({if (token.metadata) {const tpmLimits = token.metadata.model_tpm_limit || {};const rpmLimits = token.metadata.model_rpm_limit || {};- const combinedLimits: { [key: string]: { tpm: number; rpm: number } } =- {};+ const combinedLimits: CombinedLimits = {};Object.keys({ ...tpmLimits, ...rpmLimits }).forEach((model) => {combinedLimits[model] = {- tpm: tpmLimits[model] || 0,- rpm: rpmLimits[model] || 0,+ tpm: (tpmLimits as ModelLimits)[model] || 0,+ rpm: (rpmLimits as ModelLimits)[model] || 0,};});@@ -1061,10 +1013,6 @@ const ViewKeyTable: React.FC<ViewKeyTableProps> = ({}};- if (data == null) {- return;- }- console.log("RERENDER TRIGGERED");return (<div><Card className="w-full mx-auto flex-auto overflow-y-auto max-h-[50vh] mb-4 mt-2">@@ -1084,8 +1032,8 @@ const ViewKeyTable: React.FC<ViewKeyTableProps> = ({</TableRow></TableHead><TableBody>- {all_keys_to_display &&- all_keys_to_display.map((item) => {+ {keys &&+ keys.map((item) => {console.log(item);// skip item if item.team_id == "litellm-dashboard"if (item.team_id === "litellm-dashboard") {@@ -1095,9 +1043,7 @@ const ViewKeyTable: React.FC<ViewKeyTableProps> = ({/*** if selected team id is null -> show the keys with no team id or team id's that don't exist in db*/- console.log(- `item team id: ${item.team_id}, knownTeamIDs.has(item.team_id): ${knownTeamIDs.has(item.team_id)}, selectedTeam id: ${selectedTeam.team_id}`- );+if (selectedTeam.team_id == null &&item.team_id !== null &&@@ -1147,7 +1093,7 @@ const ViewKeyTable: React.FC<ViewKeyTableProps> = ({<Text>{(() => {try {- return parseFloat(item.spend).toFixed(4);+ return item.spend.toFixed(4);} catch (error) {return item.spend;}@@ -1324,9 +1270,7 @@ const ViewKeyTable: React.FC<ViewKeyTableProps> = ({<p className="text-tremor font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong">{(() => {try {- return parseFloat(- selectedToken.spend- ).toFixed(4);+ return selectedToken.spend.toFixed(4);} catch (error) {return selectedToken.spend;}@@ -1334,7 +1278,7 @@ const ViewKeyTable: React.FC<ViewKeyTableProps> = ({</p></div></Card>- <Card key={item.name}>+ <Card key={item.key_name}><p className="text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content">Budget</p>@@ -1359,7 +1303,7 @@ const ViewKeyTable: React.FC<ViewKeyTableProps> = ({</p></div></Card>- <Card key={item.name}>+ <Card key={item.key_name}><p className="text-tremor-default font-medium text-tremor-content dark:text-dark-tremor-content">Expires</p>