forked from phoenix/litellm-mirror
(feat) /spend/users endpoint
This commit is contained in:
parent
d3848b6e6c
commit
2692afca75
2 changed files with 10 additions and 3 deletions
|
@ -2435,7 +2435,7 @@ async def spend_user_fn():
|
||||||
|
|
||||||
Example Request:
|
Example Request:
|
||||||
```
|
```
|
||||||
curl -X GET "http://0.0.0.0:8000/spend/keys" \
|
curl -X GET "http://0.0.0.0:8000/spend/users" \
|
||||||
-H "Authorization: Bearer sk-1234"
|
-H "Authorization: Bearer sk-1234"
|
||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
|
@ -2446,9 +2446,11 @@ async def spend_user_fn():
|
||||||
f"Database not connected. Connect a database to your proxy - https://docs.litellm.ai/docs/simple_proxy#managing-auth---virtual-keys"
|
f"Database not connected. Connect a database to your proxy - https://docs.litellm.ai/docs/simple_proxy#managing-auth---virtual-keys"
|
||||||
)
|
)
|
||||||
|
|
||||||
key_info = await prisma_client.get_data(table_name="key", query_type="find_all")
|
user_info = await prisma_client.get_data(
|
||||||
|
table_name="user", query_type="find_all"
|
||||||
|
)
|
||||||
|
|
||||||
return key_info
|
return user_info
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
|
@ -432,6 +432,11 @@ class PrismaClient:
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
return response
|
return response
|
||||||
|
elif table_name == "user" and query_type == "find_all":
|
||||||
|
response = await self.db.litellm_usertable.find_many( # type: ignore
|
||||||
|
order={"spend": "desc"},
|
||||||
|
)
|
||||||
|
return response
|
||||||
elif table_name == "spend":
|
elif table_name == "spend":
|
||||||
verbose_proxy_logger.debug(
|
verbose_proxy_logger.debug(
|
||||||
f"PrismaClient: get_data: table_name == 'spend'"
|
f"PrismaClient: get_data: table_name == 'spend'"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue