{"record":{"id":"9c031d51e85e53c8","repo":"BerriAI/litellm","slug":"langfuse-public-key-and-langfuse-secret-key-must-b","errorCode":null,"errorMessage":"LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY must be set for Langfuse OpenTelemetry integration.","messagePattern":"LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY must be set for Langfuse OpenTelemetry integration\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/langfuse/langfuse_otel.py","lineNumber":301,"sourceCode":"        \"\"\"\n        Retrieves the Langfuse OpenTelemetry configuration based on environment variables.\n\n        Environment Variables:\n            LANGFUSE_PUBLIC_KEY: Required. Langfuse public key for authentication.\n            LANGFUSE_SECRET_KEY: Required. Langfuse secret key for authentication.\n            LANGFUSE_HOST: Optional. Custom Langfuse host URL. Defaults to US cloud.\n\n        Returns:\n            OpenTelemetryConfig: A Pydantic model containing Langfuse OTEL configuration.\n\n        Raises:\n            ValueError: If required keys are missing.\n        \"\"\"\n        public_key: Final = os.environ.get(\"LANGFUSE_PUBLIC_KEY\", None)\n        secret_key: Final = os.environ.get(\"LANGFUSE_SECRET_KEY\", None)\n\n        if not public_key or not secret_key:\n            raise ValueError(\n                \"LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY must be set for Langfuse OpenTelemetry integration.\"\n            )\n\n        return LangfuseOtelLogger._build_langfuse_otel_config(\n            public_key=public_key,\n            secret_key=secret_key,\n            langfuse_host=LangfuseOtelLogger._get_langfuse_otel_host(),\n        )\n\n    @staticmethod\n    def _build_langfuse_otel_config(\n        public_key: str, secret_key: str, langfuse_host: str | None\n    ) -> \"OpenTelemetryConfig\":\n        \"\"\"\n        Builds an OTLP HTTP config pointing at the Langfuse OTEL endpoint for the\n        given host (US cloud when no host is provided), authorized with the given keys.\n        \"\"\"\n        if langfuse_host:","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/langfuse/langfuse_otel.py#L283-L319","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\nlitellm_settings:\n  opentelemetry: true  # ValueError: LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY must be set...\n\n# after\n# environment:\n#   LANGFUSE_PUBLIC_KEY=pk-lf-xxx\n#   LANGFUSE_SECRET_KEY=sk-lf-xxx\nlitellm_settings:\n  opentelemetry: true","handlingStrategy":"validation","validationCode":"import os\n\n_REQUIRED = (\"LANGFUSE_PUBLIC_KEY\", \"LANGFUSE_SECRET_KEY\")\nmissing = [k for k in _REQUIRED if not os.environ.get(k)]\nif missing:\n    raise RuntimeError(f\"Set env vars before enabling Langfuse OTEL: {missing}\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["python","langfuse","opentelemetry","environment","configuration"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}