{"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":4112,"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":4094,"sourceCodeEnd":4130,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/litellm_core_utils/litellm_logging.py#L4094-L4130","documentation":"Raised when the 'logfire' callback is initialized: before building the OTel HTTP exporter for Pydantic Logfire, LiteLLM requires LOGFIRE_TOKEN in os.environ and hard-fails otherwise. The token is used directly as an Authorization header against LOGFIRE_BASE_URL (default https://logfire-api.pydantic.dev), so without it the exporter could never authenticate.","triggerScenarios":"callbacks/success_callback including 'logfire' (SDK or proxy config.yaml) in a process where LOGFIRE_TOKEN is unset; token defined only in a .env file that the proxy does not load; env var present on a dev machine but missing in the deployment container.","commonSituations":"Enabling logfire tracing after copying a config example; Docker/k8s deployments missing the secret; CI test runs; shell-exported var not reaching a daemonized uvicorn/gunicorn.","solutions":["Set LOGFIRE_TOKEN in the LiteLLM process environment (export LOGFIRE_TOKEN=... or env in compose).","Optionally set LOGFIRE_BASE_URL for self-hosted Logfire.","For the proxy, load it via config.yaml environment_vars or the process manager's env, then restart.","Verify with printenv LOGFIRE_TOKEN inside the same process context."],"exampleFix":"# before\nimport litellm\nlitellm.success_callback = ['logfire']  # ValueError: LOGFIRE_TOKEN not found\n\n# after\nimport os\nos.environ['LOGFIRE_TOKEN'] = 'your-logfire-token'\nimport litellm\nlitellm.success_callback = ['logfire']","handlingStrategy":"validation","validationCode":"import os\n\nif not os.environ.get('LOGFIRE_TOKEN'):\n    raise RuntimeError('LOGFIRE_TOKEN must be set before enabling the logfire callback')","typeGuard":null,"tryCatchPattern":"try:\n    litellm.completion(model='gpt-4o', messages=m)\nexcept ValueError as e:\n    if 'LOGFIRE_TOKEN' in str(e):\n        raise RuntimeError('Set LOGFIRE_TOKEN in the LiteLLM process environment and restart')\n    raise","preventionTips":["Check required callback env vars in a preflight before the first LLM call.","Load secrets from your secret manager into the process env at boot, not per request."],"tags":["litellm","logfire","observability","callbacks","env-vars","opentelemetry"],"backgroundTag":"missing-env-var","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}