langfuse/langfuse-python

🪢 Langfuse Python SDK - Instrument your LLM app with decorators or low-level SDK and get detailed tracing/observability. Works with any LLM or framework

464

stars

1,509

commits

Python

primary language

Sep 8, 2026

updated

langfuse.com/docs/sdk/python
decorators
langfuse
pydantic
pydantic-v2
python

README

Langfuse product overview

Langfuse Python SDK

MIT License CI test status PyPI Version GitHub Repo stars Discord YC W23

The Langfuse Python SDK covers the full platform: observability/tracing (OpenTelemetry-based, with OpenAI and LangChain integrations), datasets & experiments (offline evaluation and regression testing of prompt/model changes, including CI via GitHub Actions), LLM-as-a-judge and custom evaluations/scores, prompt management, and a full REST API client.

Installation

[!IMPORTANT] The SDK was rewritten in v4 and released in March 2026. Refer to the v4 migration guide for instructions on updating your code.

pip install langfuse

Quickstart

# env: LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY, LANGFUSE_BASE_URL

from langfuse import get_client

langfuse = get_client()

# Create a span using a context manager
with langfuse.start_as_current_observation(as_type="span", name="process-request") as span:
    # Your processing logic here
    span.update(output="Processing complete")

    # Create a nested generation for an LLM call
    with langfuse.start_as_current_observation(as_type="generation", name="llm-response", model="gpt-5.6") as generation:
        # Your LLM call logic here
        generation.update(output="Generated response")

# All spans are automatically closed when exiting their context blocks


# Flush events in short-lived applications
langfuse.flush()

Docs

Contributors

(top 30 of 74)

hassiebp

480 commits

maxdeichmann

436 commits

dependabot[bot]

281 commits

marcklingen

151 commits

langfuse/langfuse-python

🪢 Langfuse Python SDK - Instrument your LLM app with decorators or low-level SDK and get detailed tracing/observability. Works with any LLM or framework

464

stars

1,509

commits

Python

primary language

Sep 8, 2026

updated

langfuse.com/docs/sdk/python
decorators
langfuse
pydantic
pydantic-v2
python

README

Langfuse product overview

Langfuse Python SDK

MIT License CI test status PyPI Version GitHub Repo stars Discord YC W23

The Langfuse Python SDK covers the full platform: observability/tracing (OpenTelemetry-based, with OpenAI and LangChain integrations), datasets & experiments (offline evaluation and regression testing of prompt/model changes, including CI via GitHub Actions), LLM-as-a-judge and custom evaluations/scores, prompt management, and a full REST API client.

Installation

[!IMPORTANT] The SDK was rewritten in v4 and released in March 2026. Refer to the v4 migration guide for instructions on updating your code.

pip install langfuse

Quickstart

# env: LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY, LANGFUSE_BASE_URL

from langfuse import get_client

langfuse = get_client()

# Create a span using a context manager
with langfuse.start_as_current_observation(as_type="span", name="process-request") as span:
    # Your processing logic here
    span.update(output="Processing complete")

    # Create a nested generation for an LLM call
    with langfuse.start_as_current_observation(as_type="generation", name="llm-response", model="gpt-5.6") as generation:
        # Your LLM call logic here
        generation.update(output="Generated response")

# All spans are automatically closed when exiting their context blocks


# Flush events in short-lived applications
langfuse.flush()

Docs

Contributors

(top 30 of 74)

hassiebp

480 commits

maxdeichmann

436 commits

dependabot[bot]

281 commits

marcklingen

151 commits

Languages

Python

100.0%