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
bringing tags into api top api keys table
DrQuacksfec3b553139a
diff --git a/ui/litellm-dashboard/src/components/entity_usage.tsx b/ui/litellm-dashboard/src/components/entity_usage.tsxindex 7b910dab57b..ee44fd58290 100644--- a/ui/litellm-dashboard/src/components/entity_usage.tsx+++ b/ui/litellm-dashboard/src/components/entity_usage.tsx@@ -175,8 +175,24 @@ const EntityUsage: React.FC<EntityUsageProps> = ({};const getTopAPIKeys = () => {+ console.log('debugTags',{spendData})const keySpend: { [key: string]: KeyMetricWithMetadata } = {};spendData.results.forEach((day) => {+ const {breakdown} = day;+ const {entities} = breakdown;+ console.log('debugTags',{entities})+ const tagDictionary = Object.keys(entities).reduce((acc: { [key: string]: string[] }, entity) => {+ const {api_key_breakdown} = entities[entity];+ Object.keys(api_key_breakdown).forEach((key) => {+ if (acc[key]) {+ acc[key].push(entity);+ } else {+ acc[key] = [entity];+ }+ })+ return acc;+ },{})+ console.log('debugTags',{tagDictionary})Object.entries(day.breakdown.api_keys || {}).forEach(([key, metrics]) => {if (!keySpend[key]) {keySpend[key] = {@@ -193,9 +209,11 @@ const EntityUsage: React.FC<EntityUsageProps> = ({},metadata: {key_alias: metrics.metadata.key_alias,- team_id: metrics.metadata.team_id || null+ team_id: metrics.metadata.team_id || null,+ tags: tagDictionary[key] || []}};+ console.log('debugTags',{keySpend})}keySpend[key].metrics.spend += metrics.metrics.spend;keySpend[key].metrics.prompt_tokens += metrics.metrics.prompt_tokens;@@ -218,6 +236,7 @@ const EntityUsage: React.FC<EntityUsageProps> = ({.map(([api_key, metrics]) => ({api_key,key_alias: metrics.metadata.key_alias || "-", // Using truncated key as alias+ tags: metrics.metadata.tags || "-",spend: metrics.metrics.spend,})).sort((a, b) => b.spend - a.spend)diff --git a/ui/litellm-dashboard/src/components/new_usage.tsx b/ui/litellm-dashboard/src/components/new_usage.tsxindex e17c2d78be3..10dc306c713 100644--- a/ui/litellm-dashboard/src/components/new_usage.tsx+++ b/ui/litellm-dashboard/src/components/new_usage.tsx@@ -269,6 +269,7 @@ const NewUsagePage: React.FC<NewUsagePageProps> = ({ accessToken, userRole, usermetadata: {key_alias: metrics.metadata.key_alias,team_id: null,+ tags: metrics.metadata.tags || [], // This gets key-level tags},}}@@ -284,10 +285,13 @@ const NewUsagePage: React.FC<NewUsagePageProps> = ({ accessToken, userRole, user})})+ console.log('debugTags',{keySpend,userSpendData})+return Object.entries(keySpend).map(([api_key, metrics]) => ({api_key,key_alias: metrics.metadata.key_alias || "-", // Using truncated key as alias+ tags: metrics.metadata.tags || [], // This will show key-level tagsspend: metrics.metrics.spend,})).sort((a, b) => b.spend - a.spend)diff --git a/ui/litellm-dashboard/src/components/top_key_view.tsx b/ui/litellm-dashboard/src/components/top_key_view.tsxindex 3db72123400..1c87807d81c 100644--- a/ui/litellm-dashboard/src/components/top_key_view.tsx+++ b/ui/litellm-dashboard/src/components/top_key_view.tsx@@ -88,6 +88,11 @@ const TopKeyView: React.FC<TopKeyViewProps> = ({ topKeys, accessToken, userID, uaccessorKey: "key_alias",cell: (info: any) => info.getValue() || "-",},+ {+ header: "Tags",+ accessorKey: "tags",+ cell: (info: any) => info.getValue() || "-",+ },{header: "Spend (USD)",accessorKey: "spend",diff --git a/ui/litellm-dashboard/src/components/usage/types.ts b/ui/litellm-dashboard/src/components/usage/types.tsindex 5d0779246cc..3848ba2e18b 100644--- a/ui/litellm-dashboard/src/components/usage/types.ts+++ b/ui/litellm-dashboard/src/components/usage/types.ts@@ -39,6 +39,7 @@ export interface KeyMetricWithMetadata {export interface KeyMetadata {key_alias: string | nullteam_id: string | null+ tags?: string[]}export interface TopApiKeyData {