{"record":{"id":"7a789772bfb0751c","repo":"BerriAI/litellm","slug":"levoai-api-key-environment-variable-is-required-fo","errorCode":null,"errorMessage":"LEVOAI_API_KEY environment variable is required for Levo integration.","messagePattern":"LEVOAI_API_KEY environment variable is required for Levo integration\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/levo/levo.py","lineNumber":59,"sourceCode":"    def get_levo_config() -> LevoConfig:\n        \"\"\"\n        Retrieves the Levo configuration based on environment variables.\n\n        Returns:\n            LevoConfig: Configuration object containing Levo OTLP settings.\n\n        Raises:\n            ValueError: If required environment variables are missing.\n        \"\"\"\n        # Required environment variables\n        api_key: Final = os.environ.get(\"LEVOAI_API_KEY\", None)\n        org_id: Final = os.environ.get(\"LEVOAI_ORG_ID\", None)\n        workspace_id: Final = os.environ.get(\"LEVOAI_WORKSPACE_ID\", None)\n        collector_url: Final = os.environ.get(\"LEVOAI_COLLECTOR_URL\", None)\n\n        # Validate required env vars\n        if not api_key:\n            raise ValueError(\"LEVOAI_API_KEY environment variable is required for Levo integration.\")\n        if not org_id:\n            raise ValueError(\"LEVOAI_ORG_ID environment variable is required for Levo integration.\")\n        if not workspace_id:\n            raise ValueError(\"LEVOAI_WORKSPACE_ID environment variable is required for Levo integration.\")\n        if not collector_url:\n            raise ValueError(\n                \"LEVOAI_COLLECTOR_URL environment variable is required for Levo integration. \"\n                \"Please contact Levo support to get your collector URL.\"\n            )\n\n        # Use collector URL exactly as provided by the user\n        endpoint: Final = collector_url\n        protocol: Final[Protocol] = \"otlp_http\"\n\n        # Build OTLP headers string\n        # Format: Authorization=Bearer {api_key},x-levo-organization-id={org_id},x-levo-workspace-id={workspace_id}\n        headers_parts: Final = [f\"Authorization=Bearer {api_key}\"]\n        headers_parts.append(f\"x-levo-organization-id={org_id}\")","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/levo/levo.py#L41-L77","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\nlitellm_settings:\n  success_callback: [\"levo\"]  # ValueError: LEVOAI_API_KEY ... required\n\n# after\n# export LEVOAI_API_KEY=...\n# export LEVOAI_ORG_ID=...\n# export LEVOAI_WORKSPACE_ID=...\n# export LEVOAI_COLLECTOR_URL=https://...\nlitellm_settings:\n  success_callback: [\"levo\"]","handlingStrategy":"validation","validationCode":"import os\n\ndef levo_config_valid() -> bool:\n    return bool(os.getenv(\"LEVOAI_API_KEY\"))","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Group all four LEVOAI_* vars in one secret so they are never partially set","Assert required env vars at startup with a clear message"],"tags":["python","levo","environment","configuration","observability"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}