BerriAI/litellm · error · Exception
DD_SITE is not set in .env, set 'DD_SITE=<>
Error message
DD_SITE is not set in .env, set 'DD_SITE=<>
What it means
The site twin of the Datadog credential check: DatadogLogger.__init__ resolves dd_site from the argument or the DD_SITE env var (there is no allow_env_credentials gate on the site) and raises this Exception when both are empty. Without the site the intake URL (https://http-intake.logs.<site>/api/v2/logs) cannot be built, so the logger refuses to start.
Solutions
- export DD_SITE=<your site, e.g. us5.datadoghq.com or eu1.datadoghq.eu> and restart the process
- Or pass dd_site explicitly in the logger construction alongside dd_api_key
- Verify with the Datadog API which site your org belongs to and use that exact hostname
- Add both DD_API_KEY and DD_SITE to your deployment's secret/env spec
Example fix
# before export DD_API_KEY=xxxx datadog_logger = DatadogLogger() # Exception: DD_SITE is not set # after export DD_API_KEY=xxxx export DD_SITE=us5.datadoghq.com datadog_logger = DatadogLogger()
Defensive patterns
Strategy: validation
Validate before calling
import os
if not (os.getenv('DD_SITE') or explicit_dd_site):
raise RuntimeError('DD_SITE missing: set it (e.g. us5.datadoghq.com) before adding the datadog callback') Type guard
def datadog_site_configured() -> bool:
import os
return bool(os.getenv('DD_SITE')) Try / catch
except Exception as e:
if 'DD_SITE is not set' in str(e):
export the correct DD_SITE for your Datadog region and restart the logger/process
raise Prevention
- Copy both credential values from the Datadog setup page, not just the API key
- Confirm your org's site hostname (us5.datadoghq.com, eu1.datadoghq.eu, ...) in deployment env
- Include DD_SITE in the same secret/env checklist as DD_API_KEY
When it happens
Trigger: DD_API_KEY set but DD_SITE unset when the datadog callback initializes; passing dd_api_key explicitly while forgetting dd_site; EU/custom-region Datadog accounts where the correct site (e.g. eu1.datadoghq.eu, us5.datadoghq.com) was never configured.
Common situations: Deployments that copy only the API key from Datadog's setup page; orgs on non-us1 regions wondering why logs vanish — here they fail fast instead; env files trimmed during containerization.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- DD_API_KEY is not set, set 'DD_API_KEY=<>
- LiteLLM Error, trying to use DynamoDB but not table name…
- Missing required environment variable…
- All values in argilla_transformation_object must be a key…
- api_base is required
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/2c73ddd3c9deeda1.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/integrations/datadog/datadog.py:238
) -> None:
"""
Configure direct DataDog API connection
Args:
dd_api_key: Datadog API key. Falls back to DD_API_KEY env var when allow_env_credentials is True.
dd_site: Datadog site. Falls back to DD_SITE env var.
allow_env_credentials: When False, never read the API key from DD_API_KEY env var.
Raises:
Exception: If required credentials are not provided via args or env vars
"""
resolved_api_key: Final = dd_api_key or (os.getenv("DD_API_KEY") if allow_env_credentials else None)
resolved_site: Final = dd_site or os.getenv("DD_SITE")
if resolved_api_key is None:
raise Exception("DD_API_KEY is not set, set 'DD_API_KEY=<>")
if resolved_site is None:
raise Exception("DD_SITE is not set in .env, set 'DD_SITE=<>")
self.DD_API_KEY = resolved_api_key
self.intake_url = f"https://http-intake.logs.{resolved_site}/api/v2/logs"
async def async_log_success_event(self, kwargs, response_obj, start_time, end_time):
"""
Async Log success events to Datadog
- Creates a Datadog payload
- Adds the Payload to the in memory logs queue
- Payload is flushed every 10 seconds or when batch size is greater than 100
Raises:
Raises a NON Blocking verbose_logger.exception if an error occurs
"""
try:
verbose_logger.debug("Datadog: Logging - Enters logging function for model %s", kwargs)View on GitHub (pinned to 77b7c6c40c)