BerriAI/litellm · error · Exception
Missing webhook_url from environment
Error message
Missing webhook_url from environment
What it means
SlackAlerting.send_alert_webhook (budget alerts) posts to a generic webhook URL read from the WEBHOOK_URL environment variable; if unset it raises Exception (litellm/integrations/SlackAlerting/slack_alerting.py:1061). Unlike the Slack path, this generic path has no fallback.
Source
Thrown at litellm/integrations/SlackAlerting/slack_alerting.py:1061
async def model_removed_alert(self, model_name: str):
pass
async def send_webhook_alert(self, webhook_event: WebhookEvent) -> bool:
"""
Sends structured alert to webhook, if set.
Currently only implemented for budget alerts
Returns -> True if sent, False if not.
Raises Exception
- if WEBHOOK_URL is not set
"""
webhook_url: Final = os.getenv("WEBHOOK_URL", None)
if webhook_url is None:
raise Exception("Missing webhook_url from environment")
payload: Final = webhook_event.model_dump_json()
headers: Final = {"Content-type": "application/json"}
response: Final = await self.async_http_handler.post(
url=webhook_url,
headers=headers,
data=payload,
)
if response.status_code == 200:
return True
else:
print("Error sending webhook alert. Error=", response.text) # noqa: T201
return False
async def _check_if_using_premium_email_feature(
self,View on GitHub (pinned to 6c2dcb801b)
Solutions
- Export WEBHOOK_URL in the proxy/SDK process environment
- If you meant Slack alerts, use SLACK_WEBHOOK_URL and the Slack alerting config instead of the generic webhook path
- Verify the env var reaches the process (docker env, systemd Environment=, .env loading)
- Guard the call site: skip webhook alerts when the env var is absent
Example fix
# before
await alerting.send_alert_webhook(event) # WEBHOOK_URL unset
# after
import os
if os.getenv("WEBHOOK_URL"):
await alerting.send_alert_webhook(event) Defensive patterns
Strategy: validation
Validate before calling
import os
def webhook_configured() -> bool:
return bool(os.getenv("WEBHOOK_URL")) Try / catch
try:
await alerting.send_alert_webhook(event)
except Exception as e:
if "Missing webhook_url" in str(e):
log.warning("skipping webhook alert: WEBHOOK_URL not set")
else:
raise Prevention
- Set both WEBHOOK_URL and SLACK_WEBHOOK_URL explicitly when configuring alerting
- Add env-var presence checks to proxy startup validation
- Distinguish generic webhook alerts from Slack alerts in config review
When it happens
Trigger: Calling the alerting webhook send (budget alert flow) without WEBHOOK_URL exported; running the proxy with alerting configured for budget thresholds but only SLACK_WEBHOOK_URL set.
Common situations: Confusion between WEBHOOK_URL (generic webhook alerts) and SLACK_WEBHOOK_URL (Slack alerts); env file not loaded by the proxy process.
Related errors
- Missing SLACK_WEBHOOK_URL from environment
- PAGERDUTY_API_KEY is not set
- Trying to Customize Email Alerting {CommonProxyErrors.not_p
- AZURE_SENTINEL_DCR_IMMUTABLE_ID is required. Set it as an en
- AZURE_SENTINEL_ENDPOINT is required. Set it as an environmen
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/c252d000a689dd59.
Report an issue: GitHub.