{"record":{"id":"8cf0ea5b54ff891c","repo":"BerriAI/litellm","slug":"levoai-org-id-environment-variable-is-required-for","errorCode":null,"errorMessage":"LEVOAI_ORG_ID environment variable is required for Levo integration.","messagePattern":"LEVOAI_ORG_ID environment variable is required for Levo integration\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/levo/levo.py","lineNumber":61,"sourceCode":"        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}\")\n        headers_parts.append(f\"x-levo-workspace-id={workspace_id}\")\n","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/levo/levo.py#L43-L79","documentation":"The Levo integration (an OpenTelemetry-based observability callback) validates its required environment variables in the logger constructor and raises ValueError when one is missing. LEVOAI_ORG_ID specifically identifies your organization and is sent as the x-levo-organization-id header on every OTLP export, so telemetry cannot be routed without it. The check runs after the LEVOAI_API_KEY check and before LEVOAI_WORKSPACE_ID / LEVOAI_COLLECTOR_URL, so seeing this error means the API key is already set.","triggerScenarios":"Instantiating the Levo callback (via litellm.callbacks, litellm_settings.callbacks in config.yaml, or direct construction) in a process where LEVOAI_API_KEY is present but LEVOAI_ORG_ID is unset or an empty string. Typical in CI, Docker, or a .env that only copied some of the four LEVOAI_* values from the Levo dashboard.","commonSituations":"Partial .env files (API key copied but org/workspace/collector URL forgotten), docker-compose services that define only some LEVOAI_* variables, secrets managers that sync a subset of keys, or trailing-whitespace/empty-string values that still fail the truthiness check.","solutions":["Set LEVOAI_ORG_ID in the environment of the process running litellm: export LEVOAI_ORG_ID=<value from Levo dashboard>","Verify all four required vars are non-empty before startup: for v in LEVOAI_API_KEY LEVOAI_ORG_ID LEVOAI_WORKSPACE_ID LEVOAI_COLLECTOR_URL; do [ -n \"$v\" ] || echo missing $v; done (check via printenv if needed)","If running under Docker/systemd/supervisor, confirm the variable is passed into that execution context (docker-compose environment: block, systemd Environment=, etc.), not just your shell","Redeploy/restart so the callback constructor re-runs validation"],"exampleFix":"# before (only the API key is set)\nLEVOAI_API_KEY=lv-****\n# after (all four required vars)\nLEVOAI_API_KEY=lv-****\nLEVOAI_ORG_ID=your-org-id\nLEVOAI_WORKSPACE_ID=your-workspace-id\nLEVOAI_COLLECTOR_URL=https://collector.levo.ai","handlingStrategy":"validation","validationCode":"import os\n\nLEVO_REQUIRED = (\n    'LEVOAI_API_KEY',\n    'LEVOAI_ORG_ID',\n    'LEVOAI_WORKSPACE_ID',\n    'LEVOAI_COLLECTOR_URL',\n)\nmissing = [k for k in LEVO_REQUIRED if not os.environ.get(k)]\nif missing:\n    raise SystemExit(f'Refuse to start: missing Levo env vars: {missing}')","typeGuard":null,"tryCatchPattern":"try:\n    from litellm.integrations.levo.levo import LevoLogger  # construct callback\n    cb = LevoLogger()\nexcept ValueError as e:\n    # env validation failure: report and fail deployment, do not retry\n    raise RuntimeError(f'Levo callback misconfigured: {e}') from e","preventionTips":["Declare all four LEVOAI_* variables in the same env file/template so they are reviewed together","Add a startup preflight that asserts every required integration env var before litellm boots","Fail CI deployments on missing env rather than discovering the ValueError at runtime","Keep a runbook entry mapping each Levo var to where its value comes from (dashboard vs support email)"],"tags":["levo","environment-variables","configuration","opentelemetry","startup"],"backgroundTag":"missing-env-var","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}