diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 39eaf6519..544eb7731 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -1152,9 +1152,9 @@ async def update_database( payload["spend"] = response_cost if prisma_client is not None: await prisma_client.insert_data(data=payload, table_name="spend") - elif custom_db_client is not None: await custom_db_client.insert_data(payload, table_name="spend") + except Exception as e: verbose_proxy_logger.info(f"Update Spend Logs DB failed to execute") diff --git a/litellm/proxy/schema.prisma b/litellm/proxy/schema.prisma index 7e8e26fcd..eaf15d792 100644 --- a/litellm/proxy/schema.prisma +++ b/litellm/proxy/schema.prisma @@ -97,8 +97,9 @@ model LiteLLM_SpendLogs { cache_hit String @default("") cache_key String @default("") request_tags Json @default("[]") + team_id String? + end_user String? } - // Beta - allow team members to request access to a model model LiteLLM_UserNotifications { request_id String @unique diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.py index 6a0109443..76fc21242 100644 --- a/litellm/proxy/utils.py +++ b/litellm/proxy/utils.py @@ -1528,7 +1528,12 @@ def get_logging_payload(kwargs, response_obj, start_time, end_time): "startTime": start_time, "endTime": end_time, "model": kwargs.get("model", ""), - "user": kwargs.get("user", ""), + "user": kwargs.get("litellm_params", {}) + .get("metadata", {}) + .get("user_api_key_user_id", ""), + "team_id": kwargs.get("litellm_params", {}) + .get("metadata", {}) + .get("user_api_key_team_id", ""), "metadata": metadata, "cache_key": cache_key, "spend": kwargs.get("response_cost", 0), @@ -1536,6 +1541,7 @@ def get_logging_payload(kwargs, response_obj, start_time, end_time): "prompt_tokens": usage.get("prompt_tokens", 0), "completion_tokens": usage.get("completion_tokens", 0), "request_tags": metadata.get("tags", []), + "end_user": kwargs.get("user", ""), } verbose_proxy_logger.debug(f"SpendTable: created payload - payload: {payload}\n\n") diff --git a/schema.prisma b/schema.prisma index 7e8e26fcd..383b8d962 100644 --- a/schema.prisma +++ b/schema.prisma @@ -97,6 +97,8 @@ model LiteLLM_SpendLogs { cache_hit String @default("") cache_key String @default("") request_tags Json @default("[]") + team_id String? + end_user String? } // Beta - allow team members to request access to a model diff --git a/ui/litellm-dashboard/src/components/admins.tsx b/ui/litellm-dashboard/src/components/admins.tsx index 13cc34cfd..1d0568752 100644 --- a/ui/litellm-dashboard/src/components/admins.tsx +++ b/ui/litellm-dashboard/src/components/admins.tsx @@ -138,10 +138,13 @@ const AdminPanel: React.FC = ({ console.log(`admins: ${admins?.length}`); return (
- Proxy Admins + Restricted Access - Add other people to just view global spend. They cannot create teams or - grant users access to new models. + Add other people to just view spend. They cannot create keys, teams or + grant users access to new models.{" "} + + Requires SSO Setup +