BerriAI/litellm · error · ValueError
LEVOAI_API_KEY environment variable is required for Levo int
Error message
LEVOAI_API_KEY environment variable is required for Levo integration.
What it means
Levo's observability integration requires four env vars to construct; this one fires when LEVOAI_API_KEY is unset or empty. Validation happens when the Levo OTel exporter config is built (proxy startup / callback init), before any telemetry is sent, so the process fails fast rather than silently dropping events.
Source
Thrown at litellm/integrations/levo/levo.py:59
def get_levo_config() -> LevoConfig:
"""
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}")View on GitHub (pinned to 6c2dcb801b)
Solutions
- export LEVOAI_API_KEY=<key from Levo> in the litellm process environment
- Also set LEVOAI_ORG_ID, LEVOAI_WORKSPACE_ID, LEVOAI_COLLECTOR_URL — all four are required together
- For Docker/K8s, add all four to the container env / secret manifest and verify with 'env | grep LEVOAI'
- Remove the levo callback if Levo telemetry is not intended
Example fix
# before litellm_settings: success_callback: ["levo"] # ValueError: LEVOAI_API_KEY ... required # after # export LEVOAI_API_KEY=... # export LEVOAI_ORG_ID=... # export LEVOAI_WORKSPACE_ID=... # export LEVOAI_COLLECTOR_URL=https://... litellm_settings: success_callback: ["levo"]
Defensive patterns
Strategy: validation
Validate before calling
import os
def levo_config_valid() -> bool:
return bool(os.getenv("LEVOAI_API_KEY")) Prevention
- Group all four LEVOAI_* vars in one secret so they are never partially set
- Assert required env vars at startup with a clear message
When it happens
Trigger: Adding 'levo' to callbacks/litellm_settings without exporting LEVOAI_API_KEY; setting the key only in a .env file that the process never loads; an empty-string value counts as missing.
Common situations: Env vars provisioned for the other three Levo settings but the API key stored in a secret manager and never injected; local development copying config from docs without the secrets section.
Related errors
- LEVOAI_ORG_ID environment variable is required for Levo inte
- LEVOAI_WORKSPACE_ID environment variable is required for Lev
- LEVOAI_COLLECTOR_URL environment variable is required for Le
- LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY must be set for
- Missing keys={missing_keys} in environment.
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/7a789772bfb0751c.
Report an issue: GitHub.