Litellm user daily activity allow non admin usage (#9695)

* feat(internal_user_endpoints.py): allow non-admin to view their own usage via `/user/daily/activity` route

* fix(leftnav.tsx): allow users to view their own usage via new_usage.tsx

allows internal users to see their usage via new api

Handles 1m+ spend logs scenario

* fix(leftnav.tsx): allow all users to see new usage tab
This commit is contained in:
Krish Dholakia 2025-04-01 22:27:26 -07:00 committed by GitHub
parent 4f9805c9aa
commit 5a3eab0247
3 changed files with 68 additions and 46 deletions

View file

@ -1480,6 +1480,14 @@ async def get_user_daily_activity(
if api_key:
where_conditions["api_key"] = api_key
if (
user_api_key_dict.user_role != LitellmUserRoles.PROXY_ADMIN
and user_api_key_dict.user_role != LitellmUserRoles.PROXY_ADMIN_VIEW_ONLY
):
where_conditions[
"user_id"
] = user_api_key_dict.user_id # only allow access to own data
# Get total count for pagination
total_count = await prisma_client.db.litellm_dailyuserspend.count(
where=where_conditions