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
Metadata
Release files for langfuse 5.0.2
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-5.0.2.tar.gz | 365.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langfuse-5.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.0 MB
Release files / langfuse-5.0.2.tar.gz
| Download URL | langfuse-5.0.2.tar.gz |
|---|---|
| Size | 365.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8ca53a2c49d99ad5dc3c1d356e3802f00765c0bf155da5d078978cb467a5a474
|
|
BLAKE2b-256 checksum How to use checksums |
05021da2d1753ded73faecf445e3944ecd13703e71ce7af6a136acc8ddfc7d17
|
| 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-5.0.2-py3-none-any.whl
| Download URL | langfuse-5.0.2-py3-none-any.whl |
|---|---|
| Size | 636.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fee8184e88a7310fdae521d6abf1e4ba5f4d3d8ce67055fa641d2aab94e50380
|
|
BLAKE2b-256 checksum How to use checksums |
ef9318acd320f902453a8c8d82d9a583b473c7c1f762ce0b8f1a9c0ecc2c0498
|
| 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}
|