BerriAI/litellm · error · ValueError

LEVOAI_ORG_ID environment variable is required for Levo inte

Error message

LEVOAI_ORG_ID environment variable is required for Levo integration.

What it means

Levo integration validation: LEVOAI_ORG_ID is missing. The org id becomes the x-levo-organization-id OTLP header, so without it the collector cannot attribute events and the exporter config build aborts with ValueError.

Source

Thrown at litellm/integrations/levo/levo.py:61

        Retrieves the Levo configuration based on environment variables.

        Returns:
            LevoConfig: Configuration object containing Levo OTLP settings.

        Raises:
            ValueError: If required environment variables are missing.
        """
        # Required environment variables
        api_key: Final = os.environ.get("LEVOAI_API_KEY", None)
        org_id: Final = os.environ.get("LEVOAI_ORG_ID", None)
        workspace_id: Final = os.environ.get("LEVOAI_WORKSPACE_ID", None)
        collector_url: Final = os.environ.get("LEVOAI_COLLECTOR_URL", None)

        # Validate required env vars
        if not api_key:
            raise ValueError("LEVOAI_API_KEY environment variable is required for Levo integration.")
        if not org_id:
            raise ValueError("LEVOAI_ORG_ID environment variable is required for Levo integration.")
        if not workspace_id:
            raise ValueError("LEVOAI_WORKSPACE_ID environment variable is required for Levo integration.")
        if not collector_url:
            raise ValueError(
                "LEVOAI_COLLECTOR_URL environment variable is required for Levo integration. "
                "Please contact Levo support to get your collector URL."
            )

        # Use collector URL exactly as provided by the user
        endpoint: Final = collector_url
        protocol: Final[Protocol] = "otlp_http"

        # Build OTLP headers string
        # Format: Authorization=Bearer {api_key},x-levo-organization-id={org_id},x-levo-workspace-id={workspace_id}
        headers_parts: Final = [f"Authorization=Bearer {api_key}"]
        headers_parts.append(f"x-levo-organization-id={org_id}")
        headers_parts.append(f"x-levo-workspace-id={workspace_id}")

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. export LEVOAI_ORG_ID=<org id from Levo console>
  2. Confirm all four LEVOAI_* vars are present in the same environment ('env | grep LEVOAI')
  3. Add the var to your secret manager / K8s secret so restarts keep it
  4. Disable the levo callback if unused

Example fix

# before
# only LEVOAI_API_KEY, LEVOAI_WORKSPACE_ID, LEVOAI_COLLECTOR_URL set
# ValueError: LEVOAI_ORG_ID environment variable is required

# after
export LEVOAI_API_KEY=...
export LEVOAI_ORG_ID=my-org
export LEVOAI_WORKSPACE_ID=...
export LEVOAI_COLLECTOR_URL=https://...
Defensive patterns

Strategy: validation

Validate before calling

import os

def levo_config_valid() -> bool:
    return bool(os.getenv("LEVOAI_ORG_ID"))

Prevention

When it happens

Trigger: Enabling the levo callback without LEVOAI_ORG_ID exported; copying Levo's onboarding snippet that lists the key/URL but skips the org id; org id set as an empty string.

Common situations: Levo onboarding where the customer receives collector URL and API key immediately but must look up org/workspace ids in the Levo console; misordered secret injection in deploy pipelines.

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/8cf0ea5b54ff891c. Report an issue: GitHub.