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.5
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.5.tar.gz | 392.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langfuse-4.15.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.1 MB
Release files / langfuse-4.15.5.tar.gz
| Download URL | langfuse-4.15.5.tar.gz |
|---|---|
| Size | 392.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
99f16fd10f529a3bc99a2f4867f2ab2136d402c657089ab63252d270d48017ef
|
|
BLAKE2b-256 checksum How to use checksums |
323ab661c3cc3e44120a0113c58784d5d23e50fbd5dd87b3a5f83487f4c085f3
|
| 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.5-py3-none-any.whl
| Download URL | langfuse-4.15.5-py3-none-any.whl |
|---|---|
| Size | 706.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3aa98c1f5838309ff66f798966a66bf1ca5d24117db0a6e4b8e3e99c40ebd80a
|
|
BLAKE2b-256 checksum How to use checksums |
540080d6386906f8ae54b7ae219af45ec2d552d94ba88f7abc406b6153779b65
|
| 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}
|