BerriAI/litellm · error · ValueError

endpoint not set for GenericAPILogger…

Error message

endpoint not set for GenericAPILogger, GENERIC_LOGGER_ENDPOINT not found in environment variables

What it means

GenericAPILogger.__init__ raises ValueError when no endpoint was provided and GENERIC_LOGGER_ENDPOINT is unset. GenericAPILogger posts log events to an arbitrary HTTP endpoint; without one there is nowhere to send data, so construction fails fast.

Solutions

  1. Pass endpoint explicitly: GenericAPILogger(endpoint='https://logs.example.com/ingest', ...).
  2. Or set GENERIC_LOGGER_ENDPOINT in the environment before the proxy starts.
  3. Double-check spelling: it is GENERIC_LOGGER_ENDPOINT, not GENERIC_API_LOGGER_ENDPOINT.
  4. Add the env var to your deployment manifest (compose/k8s) once and reuse across environments.

Example fix

# before
GenericAPILogger()  # no env var -> ValueError

# after
GenericAPILogger(endpoint='https://logs.example.com/ingest')
Defensive patterns

Strategy: validation

Validate before calling

import os

endpoint = endpoint or os.getenv('GENERIC_LOGGER_ENDPOINT')
if endpoint is None:
    raise SystemExit('GENERIC_LOGGER_ENDPOINT env var or endpoint= arg is required for GenericAPILogger')

Type guard

def generic_logger_endpoint_set() -> bool:
    return os.getenv('GENERIC_LOGGER_ENDPOINT') is not None

Try / catch

try:
    GenericAPILogger()
except ValueError as e:
    if 'GENERIC_LOGGER_ENDPOINT' in str(e):
        raise ConfigError('Set GENERIC_LOGGER_ENDPOINT or pass endpoint=') from e
    raise

Prevention

When it happens

Trigger: Instantiating GenericAPILogger(...) without endpoint= in an environment lacking GENERIC_LOGGER_ENDPOINT; env var defined in .env.local but the process runs from another environment; callback loaded via config.yaml where the endpoint field didn't map to the constructor argument.

Common situations: Switching from another HTTP logging callback and assuming the endpoint comes from callback config YAML; deploying to staging/prod where the env var was never added; renaming the env var between litellm versions.

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/b2a21c8e00330628. Report an issue: GitHub.

Appendix: source

Thrown at litellm/integrations/generic_api/generic_api_callback.py:157

                                headers[key] = substitute_env_variables(value)

                    if event_types is None and "event_types" in callback_config:
                        event_types = callback_config["event_types"]

                    if log_format is None and "log_format" in callback_config:
                        log_format = callback_config["log_format"]
            else:
                verbose_logger.warning(
                    "callback_name '%s' not found in generic_api_compatible_callbacks.json", callback_name
                )

        #########################################################
        # Init httpx client
        #########################################################
        self.async_httpx_client = get_async_httpx_client(llm_provider=httpxSpecialProvider.LoggingCallback)
        endpoint = endpoint or os.getenv("GENERIC_LOGGER_ENDPOINT")
        if endpoint is None:
            raise ValueError(
                "endpoint not set for GenericAPILogger, GENERIC_LOGGER_ENDPOINT not found in environment variables"
            )

        self.headers: dict[str, str] = self._get_headers(headers)
        self.endpoint: str = endpoint
        self.event_types: list[API_EVENT_TYPES] | None = event_types
        self.callback_name: str | None = callback_name
        self.max_retries = max(0, int(max_retries or 0))
        retry_delay_value: Final = 0.0 if retry_delay is None else retry_delay
        self.retry_delay = max(0.0, float(retry_delay_value))
        self.timeout = timeout

        # Validate and store log_format
        if log_format is not None and log_format not in [
            "json_array",
            "ndjson",
            "single",
        ]:

View on GitHub (pinned to 77b7c6c40c)