diff --git a/ui/litellm-dashboard/src/components/networking.tsx b/ui/litellm-dashboard/src/components/networking.tsx index f80a0f096..a10fa42c0 100644 --- a/ui/litellm-dashboard/src/components/networking.tsx +++ b/ui/litellm-dashboard/src/components/networking.tsx @@ -341,6 +341,35 @@ export const keySpendLogsCall = async (accessToken: String, token: String) => { } }; + +export const teamSpendLogsCall = async (accessToken: String) => { + try { + const url = proxyBaseUrl + ? `${proxyBaseUrl}/global/spend/teams` + : `/global/spend/teams`; + console.log("in teamSpendLogsCall:", url); + const response = await fetch(`${url}`, { + method: "GET", + headers: { + Authorization: `Bearer ${accessToken}`, + "Content-Type": "application/json", + }, + }); + if (!response.ok) { + const errorData = await response.text(); + message.error(errorData); + throw new Error("Network response was not ok"); + } + + const data = await response.json(); + console.log(data); + return data; + } catch (error) { + console.error("Failed to create key:", error); + throw error; + } +}; + export const userSpendLogsCall = async ( accessToken: String, token: String, diff --git a/ui/litellm-dashboard/src/components/usage.tsx b/ui/litellm-dashboard/src/components/usage.tsx index 974c2e5c0..01c057427 100644 --- a/ui/litellm-dashboard/src/components/usage.tsx +++ b/ui/litellm-dashboard/src/components/usage.tsx @@ -8,6 +8,7 @@ import { adminSpendLogsCall, adminTopKeysCall, adminTopModelsCall, + teamSpendLogsCall, } from "./networking"; import { start } from "repl"; @@ -157,6 +158,8 @@ const UsagePage: React.FC = ({ const [topKeys, setTopKeys] = useState([]); const [topModels, setTopModels] = useState([]); const [topUsers, setTopUsers] = useState([]); + const [teamSpendData, setTeamSpendData] = useState([]); + const [uniqueTeamIds, setUniqueTeamIds] = useState([]); const firstDay = new Date( currentDate.getFullYear(), @@ -217,6 +220,11 @@ const UsagePage: React.FC = ({ spend: k["total_spend"], })); setTopModels(filtered_models); + + const teamSpend = await teamSpendLogsCall(accessToken); + console.log("teamSpend", teamSpend); + setTeamSpendData(teamSpend.daily_spend); + setUniqueTeamIds(teamSpend.teams) } else if (userRole == "App Owner") { await userSpendLogsCall( accessToken, @@ -346,9 +354,9 @@ const UsagePage: React.FC = ({ Monthly Team Spend