Skip to main content

Langfuse Python SDK - LLM observability/tracing, datasets, experiments, LLM-as-a-judge evaluation, and prompt management

Project description

hero-b

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

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langfuse-4.14.2.tar.gz (389.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langfuse-4.14.2-py3-none-any.whl (688.1 kB view details)

Uploaded Python 3

File details

Details for the file langfuse-4.14.2.tar.gz.

File metadata

  • Download URL: langfuse-4.14.2.tar.gz
  • Upload date:
  • Size: 389.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for langfuse-4.14.2.tar.gz
Algorithm Hash digest
SHA256 76eb3f2c2106ddd63271154d1a33f8b3d4036f449a9f9b48403c36bd5e7c1bba
MD5 9ba5b398b03f3e0afb9914f886175eb3
BLAKE2b-256 367c4cdf76a100f169a0855d4a7e69598a3bbe19bd2f048c5de3c298af1aa2c0

See more details on using hashes here.

File details

Details for the file langfuse-4.14.2-py3-none-any.whl.

File metadata

  • Download URL: langfuse-4.14.2-py3-none-any.whl
  • Upload date:
  • Size: 688.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for langfuse-4.14.2-py3-none-any.whl
Algorithm Hash digest
SHA256 27879cbaea570e94323c6ced60a0997feedf5294f18b51436009947c42f9f92e
MD5 8b45359bbe5dd4562fcd674e0cf8161c
BLAKE2b-256 8bb51499bcedb6872e8acc4e7043c522c9f3a4fe2eafd78a6f37e73308d18753

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page