mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 03:34:10 +00:00
feat(proxy_server.py): support cost tracking on user id via JWT-Auth
allows admin to track cost for LiteLLM_UserTable via JWT
This commit is contained in:
parent
a9285710d1
commit
4b2d13322e
4 changed files with 59 additions and 24 deletions
|
@ -74,6 +74,16 @@ class JWTHandler:
|
|||
team_id = default_value
|
||||
return team_id
|
||||
|
||||
def get_user_id(self, token: dict, default_value: Optional[str]) -> Optional[str]:
|
||||
try:
|
||||
if self.litellm_jwtauth.user_id_jwt_field is not None:
|
||||
user_id = token[self.litellm_jwtauth.user_id_jwt_field]
|
||||
else:
|
||||
user_id = None
|
||||
except KeyError:
|
||||
user_id = default_value
|
||||
return user_id
|
||||
|
||||
def get_scopes(self, token: dict) -> list:
|
||||
try:
|
||||
if isinstance(token["scope"], str):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue