BerriAI/litellm · error · ValueError
LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY must be set for
Error message
LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY must be set for Langfuse OpenTelemetry integration.
What it means
LangfuseOtelLogger.get_config reads LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY directly from os.environ and raises ValueError if either is unset or empty. Unlike the HTTP logger, the OpenTelemetry-based integration does not accept credentials as constructor arguments or per-request params — env vars are mandatory.
Source
Thrown at litellm/integrations/langfuse/langfuse_otel.py:301
"""
Retrieves the Langfuse OpenTelemetry configuration based on environment variables.
Environment Variables:
LANGFUSE_PUBLIC_KEY: Required. Langfuse public key for authentication.
LANGFUSE_SECRET_KEY: Required. Langfuse secret key for authentication.
LANGFUSE_HOST: Optional. Custom Langfuse host URL. Defaults to US cloud.
Returns:
OpenTelemetryConfig: A Pydantic model containing Langfuse OTEL configuration.
Raises:
ValueError: If required keys are missing.
"""
public_key: Final = os.environ.get("LANGFUSE_PUBLIC_KEY", None)
secret_key: Final = os.environ.get("LANGFUSE_SECRET_KEY", None)
if not public_key or not secret_key:
raise ValueError(
"LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY must be set for Langfuse OpenTelemetry integration."
)
return LangfuseOtelLogger._build_langfuse_otel_config(
public_key=public_key,
secret_key=secret_key,
langfuse_host=LangfuseOtelLogger._get_langfuse_otel_host(),
)
@staticmethod
def _build_langfuse_otel_config(
public_key: str, secret_key: str, langfuse_host: str | None
) -> "OpenTelemetryConfig":
"""
Builds an OTLP HTTP config pointing at the Langfuse OTEL endpoint for the
given host (US cloud when no host is provided), authorized with the given keys.
"""
if langfuse_host:View on GitHub (pinned to 6c2dcb801b)
Solutions
- export LANGFUSE_PUBLIC_KEY=pk-lf-... and export LANGFUSE_SECRET_KEY=sk-lf-... in the environment of the litellm process
- In Docker/K8s, verify with 'env | grep LANGFUSE' inside the running container — secrets may exist locally but not in the pod spec
- Optionally set LANGFUSE_HOST if not using the US cloud
- If secrets are managed via a vault, inject them as env vars before litellm imports/initializes the OTEL logger
Example fix
# before litellm_settings: opentelemetry: true # ValueError: LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY must be set... # after # environment: # LANGFUSE_PUBLIC_KEY=pk-lf-xxx # LANGFUSE_SECRET_KEY=sk-lf-xxx litellm_settings: opentelemetry: true
Defensive patterns
Strategy: validation
Validate before calling
import os
_REQUIRED = ("LANGFUSE_PUBLIC_KEY", "LANGFUSE_SECRET_KEY")
missing = [k for k in _REQUIRED if not os.environ.get(k)]
if missing:
raise RuntimeError(f"Set env vars before enabling Langfuse OTEL: {missing}") Prevention
- Validate required env vars at process start, not lazily at first request
- Use a single secret manifest that carries both LANGFUSE keys together
- Add a container healthcheck that asserts the env vars exist
When it happens
Trigger: Enabling litellm_settings.opentelemetry with the Langfuse OTEL exporter (or calling LangfuseOtelLogger.get_config()) without exporting both env vars; setting only one of the two keys; exporting them in a different shell/container than the one running litellm.
Common situations: Docker/Kubernetes deployments where the env vars were added to the image but not the deployment spec (or vice versa); CI pipelines that only set LANGFUSE_PUBLIC_KEY; migrating from the legacy langfuse callback (which resolves credentials differently) to the OTEL integration.
Related errors
- LEVOAI_API_KEY environment variable is required for Levo int
- LEVOAI_ORG_ID environment variable is required for Levo inte
- LEVOAI_WORKSPACE_ID environment variable is required for Lev
- LEVOAI_COLLECTOR_URL environment variable is required for Le
- Missing keys={missing_keys} in environment.
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/9c031d51e85e53c8.
Report an issue: GitHub.