mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 19:54:13 +00:00
fix - send email alert when token crossed it's budget
This commit is contained in:
parent
fd5a7a738f
commit
35a767d52c
1 changed files with 7 additions and 0 deletions
|
@ -1062,12 +1062,19 @@ async def user_api_key_auth(
|
||||||
|
|
||||||
# Check 4. Token Spend is under budget
|
# Check 4. Token Spend is under budget
|
||||||
if valid_token.spend is not None and valid_token.max_budget is not None:
|
if valid_token.spend is not None and valid_token.max_budget is not None:
|
||||||
|
# collect information for alerting
|
||||||
|
|
||||||
|
if isinstance(user_id_information, list):
|
||||||
|
user_id_information = user_id_information[0]
|
||||||
|
user_email = user_id_information.get("user_email", None)
|
||||||
call_info = CallInfo(
|
call_info = CallInfo(
|
||||||
token=valid_token.token,
|
token=valid_token.token,
|
||||||
spend=valid_token.spend,
|
spend=valid_token.spend,
|
||||||
max_budget=valid_token.max_budget,
|
max_budget=valid_token.max_budget,
|
||||||
user_id=valid_token.user_id,
|
user_id=valid_token.user_id,
|
||||||
team_id=valid_token.team_id,
|
team_id=valid_token.team_id,
|
||||||
|
user_email=user_email,
|
||||||
|
key_alias=valid_token.key_alias,
|
||||||
)
|
)
|
||||||
asyncio.create_task(
|
asyncio.create_task(
|
||||||
proxy_logging_obj.budget_alerts(
|
proxy_logging_obj.budget_alerts(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue