BerriAI/litellm · error · Exception

DD_SITE is not set, set 'DD_SITE=<>', example sit =…

Error message

DD_SITE is not set, set 'DD_SITE=<>', example sit = `us5.datadoghq.com`

What it means

Second guard in DataDogLLMObsLogger.__init__ direct-API branch: when LITELLM_DD_AGENT_HOST is unset and DD_API_KEY exists but DD_SITE does not, construction fails with this Exception. DD_SITE selects the Datadog region (e.g. us5.datadoghq.com) used to build the intake URL, so direct mode refuses to guess a default region.

Solutions

  1. Export DD_SITE matching your Datadog region, e.g. DD_SITE=us5.datadoghq.com (find it in your browser URL: app.<DD_SITE>)
  2. Pair it with DD_API_KEY and restart the process, verifying both with printenv
  3. Prefer agent mode (LITELLM_DD_AGENT_HOST) where neither variable is required

Example fix

# before
export DD_API_KEY=<key>  # no DD_SITE -> Exception

# after
export DD_API_KEY=<key>
export DD_SITE=us5.datadoghq.com
Defensive patterns

Strategy: validation

Validate before calling

import os

VALID_SITES_PREFIXES = ("us", "eu", "ap", "datadoghq")

def dd_site_ok() -> bool:
    site = os.getenv("DD_SITE")
    return bool(site) and any(site == p or site.startswith(p + ".") for p in VALID_SITES_PREFIXES)

Prevention

When it happens

Trigger: Setting only DD_API_KEY because the account is on a non-default region (us5, eu1) and assuming us1 defaults; env file with DD_SITE misspelled or never exported; agent-mode deployment missing LITELLM_DD_AGENT_HOST so it accidentally enters direct mode with a key but no site.

Common situations: Copy-pasting Datadog docs that only mention the key; region-specific accounts (app.us5.datadoghq.com) where developers don't realize DD_SITE is mandatory; docker/k8s env stripped during deployment.

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


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/10fba62a9bd0dc2a. Report an issue: GitHub.

Appendix: source

Thrown at litellm/integrations/datadog/datadog_llm_obs.py:73

                create_mock_datadog_client()
                verbose_logger.debug("[DATADOG MOCK] DataDogLLMObs logger initialized in mock mode")

            # Configure DataDog endpoint (Agent or Direct API)
            # Use LITELLM_DD_AGENT_HOST to avoid conflicts with ddtrace's DD_AGENT_HOST
            # Check for agent mode FIRST - agent mode doesn't require DD_API_KEY or DD_SITE
            dd_agent_host: Final = os.getenv("LITELLM_DD_AGENT_HOST")

            self.async_client = get_async_httpx_client(llm_provider=httpxSpecialProvider.LoggingCallback)
            self.DD_API_KEY = os.getenv("DD_API_KEY")

            if dd_agent_host:
                self._configure_dd_agent(dd_agent_host=dd_agent_host)
            else:
                # Only require DD_API_KEY and DD_SITE for direct API mode
                if os.getenv("DD_API_KEY", None) is None:
                    raise Exception("DD_API_KEY is not set, set 'DD_API_KEY=<>'")
                if os.getenv("DD_SITE", None) is None:
                    raise Exception("DD_SITE is not set, set 'DD_SITE=<>', example sit = `us5.datadoghq.com`")
                self._configure_dd_direct_api()

            # Optional override for testing
            dd_base_url: Final = get_datadog_base_url_from_env()
            if dd_base_url:
                self.intake_url = f"{dd_base_url}/api/intake/llm-obs/v1/trace/spans"

            asyncio.create_task(self.periodic_flush())
            self.flush_lock = asyncio.Lock()
            self.log_queue: list[LLMObsPayload] = []

            #########################################################
            # Handle datadog_llm_observability_params set as litellm.datadog_llm_observability_params
            #########################################################
            dict_datadog_llm_obs_params: Final = self._get_datadog_llm_obs_params()
            kwargs.update(dict_datadog_llm_obs_params)
            CustomBatchLogger.__init__(self, **kwargs, flush_lock=self.flush_lock)
        except Exception as e:

View on GitHub (pinned to 77b7c6c40c)