Langfuse Python SDK
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
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
- SDK guide: https://langfuse.com/docs/observability/sdk/overview
- Full documentation: https://langfuse.com/docs
- Machine-readable docs index (for AI agents): https://langfuse.com/llms.txt
- API reference of this package: https://python.reference.langfuse.com
- REST API reference (Observations API v2, Metrics API v2, Scores API v3): https://api.reference.langfuse.com
- Data freshness and real-time ingestion: https://langfuse.com/docs/compatibility#faq-delay
Release files for langfuse 4.15.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| langfuse-4.15.6.tar.gz | 393.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langfuse-4.15.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.1 MB
Release files / langfuse-4.15.6.tar.gz
| Download URL | langfuse-4.15.6.tar.gz |
|---|---|
| Size | 393.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
af80ed1199e57c2641c9f228066bf9dc324657c06ce6e68660118fa46b237e35
|
|
BLAKE2b-256 checksum How to use checksums |
4a1959253a357d77147e8cd3ad97817519e158af5d3336654656c92c2fc922f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / langfuse-4.15.6-py3-none-any.whl
| Download URL | langfuse-4.15.6-py3-none-any.whl |
|---|---|
| Size | 706.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2364d5f17342301a8651ef166abb5bb260aaadd94d1ac72aa30c298b3a395d85
|
|
BLAKE2b-256 checksum How to use checksums |
1ac5927a01c47c0adf53832c6e5e35951e3d4998072ef955f3bb8e87e6d10517
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|