{"record":{"id":"5fc93ba65a202454","repo":"BerriAI/litellm","slug":"logfire-token-not-found-in-environment-variables","errorCode":null,"errorMessage":"LOGFIRE_TOKEN not found in environment variables","messagePattern":"LOGFIRE_TOKEN not found in environment variables","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/litellm_core_utils/litellm_logging.py","lineNumber":4106,"sourceCode":"            from litellm.integrations.vantage.vantage_logger import VantageLogger\n\n            for callback in _in_memory_loggers:\n                if isinstance(callback, VantageLogger):\n                    return callback\n            vantage_logger: Final = VantageLogger()\n            _in_memory_loggers.append(vantage_logger)\n            return vantage_logger\n        elif logging_integration == \"deepeval\":\n            for callback in _in_memory_loggers:\n                if isinstance(callback, DeepEvalLogger):\n                    return callback\n            deepeval_logger: Final = DeepEvalLogger()\n            _in_memory_loggers.append(deepeval_logger)\n            return deepeval_logger\n\n        elif logging_integration == \"logfire\":\n            if \"LOGFIRE_TOKEN\" not in os.environ:\n                raise ValueError(\"LOGFIRE_TOKEN not found in environment variables\")\n            from litellm.integrations.opentelemetry import (\n                OpenTelemetry,\n                OpenTelemetryConfig,\n            )\n\n            logfire_base_url: Final = os.getenv(\"LOGFIRE_BASE_URL\", \"https://logfire-api.pydantic.dev\")\n            otel_config = OpenTelemetryConfig(\n                exporter=\"otlp_http\",\n                endpoint=f\"{logfire_base_url.rstrip('/')}/v1/traces\",\n                headers=f\"Authorization={os.getenv('LOGFIRE_TOKEN')}\",\n            )\n            for callback in _in_memory_loggers:\n                # Use exact type check to avoid matching ArizePhoenixLogger (subclass)\n                if type(callback) is OpenTelemetry:\n                    return callback\n            _otel_logger = OpenTelemetry(config=otel_config)\n            _in_memory_loggers.append(_otel_logger)\n            return _otel_logger","sourceCodeStart":4088,"sourceCodeEnd":4124,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/litellm_core_utils/litellm_logging.py#L4088-L4124","documentation":"While lazily constructing the 'logfire' logging integration (first time a request is logged with logfire enabled), LiteLLM requires a LOGFIRE_TOKEN env var to build the OTLP Authorization header for the Logfire endpoint. If the token is absent from the proxy process environment, construction aborts with this ValueError.","triggerScenarios":"Enabling callbacks: ['logfire'] (or LITELLM_CALLBACKS=logfire) and sending the first logged request in a process where LOGFIRE_TOKEN is unset. Optionally LOGFIRE_BASE_URL overrides the default https://logfire-api.pydantic.dev.","commonSituations":"Env var set in local shell but not in Docker/k8s deployment; token removed during secret rotation; typo like LOGFIREKEY_TOKEN; running tests without the integration env.","solutions":["Set LOGFIRE_TOKEN (and optionally LOGFIRE_BASE_URL for self-hosted Logfire) in the environment of the process running LiteLLM, then restart it","If self-hosting Logfire, also point LOGFIRE_BASE_URL at your instance since the header is built as Authorization=LOGFIRE_TOKEN","Verify visibility inside the container: docker exec <proxy> printenv LOGFIRE_TOKEN","If you no longer want Logfire, remove it from litellm_settings.callbacks instead of leaving it half-configured"],"exampleFix":"# before\ndocker run berriai/litellm --config /app/config.yaml  # config has callbacks: [logfire]\n\n# after\ndocker run -e LOGFIRE_TOKEN=$LOGFIRE_TOKEN berriai/litellm --config /app/config.yaml","handlingStrategy":"validation","validationCode":"import os\nassert os.getenv('LOGFIRE_TOKEN'), 'LOGFIRE_TOKEN must be set before enabling the logfire callback'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set LOGFIRE_TOKEN (and LOGFIRE_BASE_URL for self-hosted) wherever litellm runs","Fail fast at startup on missing integration env vars instead of at first request","Scope env checks to every replica in multi-instance deployments"],"tags":["litellm","logfire","observability","callbacks","environment-variables"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}