{"record":{"id":"634fc79e6956df8e","repo":"BerriAI/litellm","slug":"missing-keys-missing-keys-in-environment-634fc7","errorCode":null,"errorMessage":"Missing keys={missing_keys} in environment.","messagePattern":"Missing keys=(.+?) in environment\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/integrations/lago.py","lineNumber":61,"sourceCode":"        LAGO_API_EVENT_CODE,\n\n        Optional:\n        LAGO_API_CHARGE_BY\n\n        in the environment\n        \"\"\"\n        missing_keys: Final = []\n        if os.getenv(\"LAGO_API_KEY\", None) is None:\n            missing_keys.append(\"LAGO_API_KEY\")\n\n        if os.getenv(\"LAGO_API_BASE\", None) is None:\n            missing_keys.append(\"LAGO_API_BASE\")\n\n        if os.getenv(\"LAGO_API_EVENT_CODE\", None) is None:\n            missing_keys.append(\"LAGO_API_EVENT_CODE\")\n\n        if len(missing_keys) > 0:\n            raise Exception(f\"Missing keys={missing_keys} in environment.\")\n\n    def _common_logic(self, kwargs: dict, response_obj) -> dict:\n        response_obj.get(\"id\", kwargs.get(\"litellm_call_id\"))\n        get_utc_datetime().isoformat()\n        cost: Final = kwargs.get(\"response_cost\", None)\n        model: Final = kwargs.get(\"model\")\n        usage = {}\n\n        if (\n            isinstance(response_obj, litellm.ModelResponse) or isinstance(response_obj, litellm.EmbeddingResponse)\n        ) and hasattr(response_obj, \"usage\"):\n            usage = {\n                \"prompt_tokens\": response_obj[\"usage\"].get(\"prompt_tokens\", 0),\n                \"completion_tokens\": response_obj[\"usage\"].get(\"completion_tokens\", 0),\n                \"total_tokens\": response_obj[\"usage\"].get(\"total_tokens\"),\n            }\n\n        litellm_params: Final = kwargs.get(\"litellm_params\", {}) or {}","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/lago.py#L43-L79","documentation":"Exception raised by the Lago billing integration's environment validation: it requires LAGO_API_KEY, LAGO_API_BASE, and LAGO_API_EVENT_CODE to all be present as environment variables before it will log billing events to Lago. The message lists exactly which keys are missing.","triggerScenarios":"Enabling the Lago callback (litellm.callbacks = ['lago']) in a process where one or more of the three LAGO_* env vars are unset. Validation runs at logging time, so the first completion after enabling the callback triggers it.","commonSituations":"Deploying with the callback enabled but secrets not mounted in the container; .env file not loaded in the runtime; CI/local machine missing the vars while production has them (or vice versa); typo in var names.","solutions":["Set all three vars: LAGO_API_KEY, LAGO_API_BASE, LAGO_API_EVENT_CODE","For Docker/k8s, ensure the secret/env mapping injects all three into the proxy/SDK process","If Lago billing is not intended, remove 'lago' from litellm.callbacks"],"exampleFix":"# before\nlitellm.callbacks = ['lago']  # env vars unset\n\n# after\nexport LAGO_API_KEY=...\nexport LAGO_API_BASE=https://api.getlago.com\nexport LAGO_API_EVENT_CODE=llm-usage\nlitellm.callbacks = ['lago']","handlingStrategy":"validation","validationCode":"import os\n\nREQUIRED = (\"LAGO_API_KEY\", \"LAGO_API_BASE\", \"LAGO_API_EVENT_CODE\")\nmissing = [k for k in REQUIRED if not os.getenv(k)]\nif missing:\n    raise RuntimeError(f\"Set required env vars: {missing}\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check required LAGO_* vars at process startup, not at first log event","Use a config checklist/secrets manifest for deployments","Remove 'lago' from callbacks when billing is disabled"],"tags":["lago","litellm","environment","configuration","billing"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}