BerriAI/litellm · error · ValueError
LOGFIRE_TOKEN not found in environment variables
Error message
LOGFIRE_TOKEN not found in environment variables
What it means
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.
Source
Thrown at litellm/litellm_core_utils/litellm_logging.py:4106
from litellm.integrations.vantage.vantage_logger import VantageLogger
for callback in _in_memory_loggers:
if isinstance(callback, VantageLogger):
return callback
vantage_logger: Final = VantageLogger()
_in_memory_loggers.append(vantage_logger)
return vantage_logger
elif logging_integration == "deepeval":
for callback in _in_memory_loggers:
if isinstance(callback, DeepEvalLogger):
return callback
deepeval_logger: Final = DeepEvalLogger()
_in_memory_loggers.append(deepeval_logger)
return deepeval_logger
elif logging_integration == "logfire":
if "LOGFIRE_TOKEN" not in os.environ:
raise ValueError("LOGFIRE_TOKEN not found in environment variables")
from litellm.integrations.opentelemetry import (
OpenTelemetry,
OpenTelemetryConfig,
)
logfire_base_url: Final = os.getenv("LOGFIRE_BASE_URL", "https://logfire-api.pydantic.dev")
otel_config = OpenTelemetryConfig(
exporter="otlp_http",
endpoint=f"{logfire_base_url.rstrip('/')}/v1/traces",
headers=f"Authorization={os.getenv('LOGFIRE_TOKEN')}",
)
for callback in _in_memory_loggers:
# Use exact type check to avoid matching ArizePhoenixLogger (subclass)
if type(callback) is OpenTelemetry:
return callback
_otel_logger = OpenTelemetry(config=otel_config)
_in_memory_loggers.append(_otel_logger)
return _otel_loggerView on GitHub (pinned to 6c2dcb801b)
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
Example fix
# before docker run berriai/litellm --config /app/config.yaml # config has callbacks: [logfire] # after docker run -e LOGFIRE_TOKEN=$LOGFIRE_TOKEN berriai/litellm --config /app/config.yaml
Defensive patterns
Strategy: validation
Validate before calling
import os
assert os.getenv('LOGFIRE_TOKEN'), 'LOGFIRE_TOKEN must be set before enabling the logfire callback' Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- No valid endpoint found for Arize, please set 'ARIZE_ENDPOIN
- LANGTRACE_API_KEY not found in environment variables
- ARIZE_API_KEY not found in environment variables
- Missing keys={missing_keys} in environment.
- Callback param '{param}' (from {source}) contains an 'os.env
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/5fc93ba65a202454.
Report an issue: GitHub.