BerriAI/litellm · error · Exception

\033[91mLangfuse not installed, try running 'pip install lan

Error message

\033[91mLangfuse not installed, try running 'pip install langfuse' to fix this error: {e}\n{traceback.format_exc()}\033[0m

What it means

LangFuseLogger.__init__ failed while importing the langfuse package (original exception and traceback interpolated into the red-highlighted message); the logger cannot start without the SDK installed.

Source

Thrown at litellm/integrations/langfuse/langfuse.py:134

    return public_key, secret_key, resolved_host


class LangFuseLogger:
    # Class variables or attributes
    def __init__(
        self,
        langfuse_public_key=None,
        langfuse_secret=None,
        langfuse_host=None,
        flush_interval=1,
        allow_env_credentials: bool = True,
    ):
        try:
            import langfuse
            from langfuse import Langfuse
        except Exception as e:
            raise Exception(
                f"\033[91mLangfuse not installed, try running 'pip install langfuse' to fix this error: {e}\n{traceback.format_exc()}\033[0m"
            )
        self.public_key, self.secret_key, self.langfuse_host = resolve_langfuse_credentials(
            langfuse_public_key=langfuse_public_key,
            langfuse_secret=langfuse_secret,
            langfuse_host=langfuse_host,
            allow_env_credentials=allow_env_credentials,
        )
        if not (self.langfuse_host.startswith("http://") or self.langfuse_host.startswith("https://")):
            # add http:// if unset, assume communicating over private network - e.g. render
            self.langfuse_host = "http://" + self.langfuse_host
        self.langfuse_release = os.getenv("LANGFUSE_RELEASE")
        self.langfuse_debug = os.getenv("LANGFUSE_DEBUG")
        self.langfuse_flush_interval = LangFuseLogger._get_langfuse_flush_interval(flush_interval)

        if should_use_langfuse_mock():
            self.langfuse_client = create_mock_langfuse_client()
            self.is_mock_mode = True

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Install langfuse with: pip install langfuse.
  2. Check the traceback in the message for the underlying import failure.

Example fix

pip install 'langfuse>=2.0.0'
Defensive patterns

Strategy: validation

When it happens

Trigger: Enabling the langfuse callback without the langfuse package installed.

Common situations: Optional dependency not installed in the environment or an incompatible langfuse major version.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/1a20d8419b249431. Report an issue: GitHub.