mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 03:04:13 +00:00
feat - email alerts on /key/generate
This commit is contained in:
parent
fa49833cdf
commit
41879ae002
2 changed files with 20 additions and 0 deletions
|
@ -5409,6 +5409,25 @@ async def generate_key_fn(
|
||||||
response["soft_budget"] = (
|
response["soft_budget"] = (
|
||||||
data.soft_budget
|
data.soft_budget
|
||||||
) # include the user-input soft budget in the response
|
) # include the user-input soft budget in the response
|
||||||
|
event = WebhookEvent(
|
||||||
|
event="key_created",
|
||||||
|
event_group="key",
|
||||||
|
event_message=f"API Key Created",
|
||||||
|
token=response.get("token", None),
|
||||||
|
spend=response.get("spend", 0.0),
|
||||||
|
max_budget=response.get("max_budget", "Unlimited"),
|
||||||
|
user_id=response.get("user_id", None),
|
||||||
|
team_id=response.get("team_id", "Default Team"),
|
||||||
|
key_alias=response.get("key_alias", None),
|
||||||
|
)
|
||||||
|
|
||||||
|
# If user configured email alerting - send an Email letting their end-user know the key was created
|
||||||
|
asyncio.create_task(
|
||||||
|
proxy_logging_obj.slack_alerting_instance.send_key_created_email(
|
||||||
|
webhook_event=event,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
return GenerateKeyResponse(**response)
|
return GenerateKeyResponse(**response)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
|
@ -12,6 +12,7 @@ from litellm.proxy._types import (
|
||||||
LiteLLM_TeamTable,
|
LiteLLM_TeamTable,
|
||||||
Member,
|
Member,
|
||||||
CallInfo,
|
CallInfo,
|
||||||
|
WebhookEvent,
|
||||||
)
|
)
|
||||||
from litellm.caching import DualCache, RedisCache
|
from litellm.caching import DualCache, RedisCache
|
||||||
from litellm.router import Deployment, ModelInfo, LiteLLM_Params
|
from litellm.router import Deployment, ModelInfo, LiteLLM_Params
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue