BerriAI/litellm · error · ValueError
PAGERDUTY_API_KEY is not set
Error message
PAGERDUTY_API_KEY is not set
What it means
ValueError raised in PagerDutyAlerting.__init__ (extends SlackAlerting) when the PAGERDUTY_API_KEY environment variable is empty or unset. The callback needs the key to authenticate against PagerDuty's Events API, so proxy startup fails fast when the callback is configured but the key is missing.
Source
Thrown at enterprise/litellm_enterprise/enterprise_callbacks/pagerduty/pagerduty.py:57
PAGERDUTY_DEFAULT_FAILURE_THRESHOLD = 60
PAGERDUTY_DEFAULT_FAILURE_THRESHOLD_WINDOW_SECONDS = 60
PAGERDUTY_DEFAULT_HANGING_THRESHOLD_SECONDS = 60
PAGERDUTY_DEFAULT_HANGING_THRESHOLD_WINDOW_SECONDS = 600
class PagerDutyAlerting(SlackAlerting):
"""
Tracks failed requests and hanging requests separately.
If threshold is crossed for either type, triggers a PagerDuty alert.
"""
def __init__(
self, alerting_args: Optional[Union[AlertingConfig, dict]] = None, **kwargs
):
super().__init__()
_api_key = os.getenv("PAGERDUTY_API_KEY")
if not _api_key:
raise ValueError("PAGERDUTY_API_KEY is not set")
self.api_key: str = _api_key
alerting_args = alerting_args or {}
self.pagerduty_alerting_args: AlertingConfig = AlertingConfig(
failure_threshold=alerting_args.get(
"failure_threshold", PAGERDUTY_DEFAULT_FAILURE_THRESHOLD
),
failure_threshold_window_seconds=alerting_args.get(
"failure_threshold_window_seconds",
PAGERDUTY_DEFAULT_FAILURE_THRESHOLD_WINDOW_SECONDS,
),
hanging_threshold_seconds=alerting_args.get(
"hanging_threshold_seconds", PAGERDUTY_DEFAULT_HANGING_THRESHOLD_SECONDS
),
hanging_threshold_window_seconds=alerting_args.get(
"hanging_threshold_window_seconds",
PAGERDUTY_DEFAULT_HANGING_THRESHOLD_WINDOW_SECONDS,
),
View on GitHub (pinned to 6c2dcb801b)
Solutions
- Set PAGERDUTY_API_KEY in the proxy deployment environment (K8s secret, Compose environment, systemd Environment=).
- Verify inside the container: printenv PAGERDUTY_API_KEY.
- Confirm the key is a valid PagerDuty Events API v2 integration key so alerting works after startup.
- If PagerDuty alerting is not wanted, remove the pagerduty callback from the config.
Example fix
# before (docker-compose)
services:
litellm:
environment:
- ALERTING=pagerduty # key missing -> ValueError
# after
services:
litellm:
environment:
- ALERTING=pagerduty
- PAGERDUTY_API_KEY=${PAGERDUTY_API_KEY} Defensive patterns
Strategy: validation
Validate before calling
import os
if not os.getenv("PAGERDUTY_API_KEY"):
raise SystemExit("PAGERDUTY_API_KEY must be set when the pagerduty callback is enabled") Try / catch
try:
alerting = PagerDutyAlerting(alerting_args={...})
except ValueError as e:
if "PAGERDUTY_API_KEY" in str(e):
logger.error("set PAGERDUTY_API_KEY in the deployment environment")
raise Prevention
- Put PAGERDUTY_API_KEY in a K8s secret / Compose environment block, not shell dotfiles.
- Use a config lint that fails when callbacks include pagerduty without the env var.
- Use an Events API v2 integration key so alerts actually deliver after startup.
- Rotate the key via secret updates and redeploy — never hardcode it.
When it happens
Trigger: Adding the pagerduty callback to litellm_settings.callbacks (or alerting config) without setting PAGERDUTY_API_KEY in the proxy process environment. os.getenv returns None or empty string, triggering the raise during callback initialization.
Common situations: Env var defined in a local .env but not in the Docker Compose environment block, Kubernetes secret, or systemd unit actually running the proxy; key name typos (PAGERDUTY_APIKEY, PAGER_DUTY_API_KEY); rotating secrets and accidentally deleting the variable.
Related errors
- Missing `LLM_GUARD_API_BASE` from environment
- File not found. blocked_user_list={blocked_user_list}
- An error occurred: {str(e)}, blocked_user_list={blocked_user
- Missing google.cloud package. Run `pip install --upgrade goo
- model_name not set for LlamaGuard
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/77036ba9aa4687fc.
Report an issue: GitHub.