Skip to content
Agents tracked: 440 Downloads (7d): 202M down 19.5% GitHub stars: 10.4M Releases (7d): 607 Agent status: all upSince last limit reset: Claude 28d · Codex 0d Updated Oct 21, 2026

Langfuse (Python)

Observability and tracing for LLM applications with evaluation and prompt management.

Prompts, structured output and evals PyPI MIT

Used in agent projects
15
0.9% of 1,622 Python repos built with AI coding agents; 231 counting our dependency samples
Gid Score
54 /100
#1207 of 3,794 tools, #13 in prompts, structured output and evals · ranking
Rank in prompts, structured output and evals
#5 of 72
by use in those projects
Downloads
6.9M
PyPI, last 7 days, langfuse
GitHub stars
502
378 forks · last push Oct 20, 2026

How Langfuse (Python) is used

Langfuse (Python) is a dependency in 15 of the 6,208 public GitHub projects set up for AI coding agents that we scanned, too few to describe it from them alone. Our scan also samples projects by dependency (Solana 2,661, Ethereum and EVM 1,496, 3D and games 2,818, agent frameworks and SDKs 10,983); counting those, it appears in 231 projects, and what it is used with below comes from all of them. The most used alternative in our scan is LangSmith (20 projects). Projects that use it most often also use python-dotenv (74.5%), Pydantic (69.3%), LangChain (67.1%).

Langfuse (Python) popularity over time

Top tools by Gid Score

Langfuse (Python): downloads per weekPyPI, langfuse 6,816,936
Langfuse (Python): GitHub starslangfuse/langfuse-python 502

Gid Score 54: downloads 82, use in agent projects 63, GitHub stars 0, downloads trend 62 (each 0-100). How it is calculated.

Often used with Langfuse (Python)

python-dotenv74.5% of Langfuse (Python) projects · 8.1× more than average
Pydantic69.3% of Langfuse (Python) projects · 8.0× more than average
LangChain67.1% of Langfuse (Python) projects · 33.1× more than average
FastAPI66.7% of Langfuse (Python) projects · 8.9× more than average
OpenAI Python Library63.6% of Langfuse (Python) projects · 16.1× more than average
Requests57.1% of Langfuse (Python) projects · 8.4× more than average
Uvicorn57.1% of Langfuse (Python) projects · 7.5× more than average
NumPy55.8% of Langfuse (Python) projects · 9.6× more than average

From all 231 projects in our scan that use Langfuse (Python), including the dependency samples.

By coding agent

Cursor0.3% of projects set up for it
Claude Code0.2% of projects set up for it

Share of public repos configured for each agent that list Langfuse (Python) as a dependency.

What Langfuse (Python) projects add to it

Share of the 15 public projects built with AI coding agents that use Langfuse (Python) and also depend on each package. From our scan of 6,208 repos, updated Oct 20, 2026.

Loads .env files python-dotenv74.5%
Data models and validation pydantic69.3%
Web API framework fastapi66.7%
OpenAI API client openai63.6%
ASGI server uvicorn57.1%
HTTP client requests57.1%
LLM app framework langchain56.7%
Numerical arrays numpy55.8%

Using Langfuse (Python) with an AI coding agent

Give your agent the official docs

The project publishes its docs in a form language models can read. Point your agent (or an MCP docs server) at:

Rules to paste into AGENTS.md or CLAUDE.md

Our summary of the project's own guidance. [1][4][7] Which file does your agent read?

## Langfuse (Python)
- Instrument with `get_client()` plus `start_as_current_observation` or `@observe`. Do not use the deprecated v2 calls `trace()`, `span()`, `generation()` or `api.trace.list`.
- Configure `LANGFUSE_PUBLIC_KEY`, `LANGFUSE_SECRET_KEY` and `LANGFUSE_BASE_URL`. Always set the base URL when self-hosting or using a non-EU region.
- Call `langfuse.flush()` before exit in short-lived scripts and jobs.
- Set `as_type` to `generation` for LLM calls and to `tool` for tool calls. Record one generation per model invocation, not one wrapper around a whole agent loop.
- Name observations verb-first and keep the names stable, e.g. `retrieve-context`. Keep IDs, retry counts and model names out of names; put run-specific values in metadata.
- Query traces through Observations API v2 (`GET /api/public/v2/observations`), not `GET /api/public/traces`. Real-time reads need `langfuse` >= 4.7.0.
Minimal code example: nested span and generation with context managers
# 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()

Code: MIT, © Langfuse, from the project README [1] · SDK quickstart

What Langfuse (Python) is

langfuse is the Python SDK for Langfuse, which its docs index describes as an "open-source AI engineering platform". The README says one package covers observability and tracing, datasets and experiments, LLM-as-a-judge and custom scores, prompt management, and a full REST API client. It is MIT licensed. The repository was created in July 2023.

You install it with pip install langfuse and set three environment variables: LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY and LANGFUSE_BASE_URL. You then wrap work in start_as_current_observation blocks or the @observe decorator. The SDK was rewritten in v4, released in March 2026, and is built on OpenTelemetry. The older v2 client calls are deprecated.

The docs say the same code runs against Langfuse Cloud or a self-hosted Langfuse server, and only the credentials and base URL change. The SDK is aimed at Python developers who want to trace LLM calls and agent runs, and who also want to version prompts and run evaluations from the same client. [1][4]

Why teams pick it

  • Tracing, prompts and evals share one client. The docs present the SDK as the recommended way to create traces and also to use prompt management and evaluation. You do not need a separate package for each feature. [4]
  • Spans are plain OpenTelemetry. The docs say the SDK is based on OpenTelemetry, so other OTEL-based instrumentation libraries can feed the same traces. [4]
  • Designed not to take your app down. The maintainers write that SDK errors are caught and logged rather than raised. They also say requests are fully async, so Langfuse "adds almost no latency". [4]
  • Regression checks can gate pull requests. The evaluation docs describe adding the langfuse/experiment-action GitHub Action to a pull_request workflow. Your experiment script raises RegressionError when a score misses its threshold, and the action fails the job. [6]
  • Docs built for coding agents. Every docs page can be fetched as Markdown by appending .md. A Docs MCP server lets AI editors search the documentation, GitHub issues and discussions. [5]

Know before you start

  • v4 is a rewrite; old code needs migrating. The README points to v2→v3 and v3→v4 upgrade guides. It marks the legacy trace(), span() and generation() API as deprecated, so older tutorials may not match current code. [1]
  • Most read APIs lag. The README says the only real-time path is OpenTelemetry ingestion with langfuse >= 4.7.0, combined with Observations API v2 and Metrics API v2. Any other GET API can trail by up to ten minutes. [1]
  • Self-hosted servers need a minimum version. Python SDK v3 and v4 need a self-hosted server at 3.63.0 or later. Observations API v2 and Metrics API v2 need Langfuse v4 on the server. [4]
  • Renaming an observation breaks things quietly. Evaluators, dashboards and saved filters target observations by name. The docs warn that when a name changes, anything pointing at the old name stops matching without an error. [7]
  • Legacy ingestion endpoint is closing. Custom integrations that post to the old ingestion endpoint have a deadline on Langfuse Cloud. After that date the endpoint accepts only scores. [4]

Built with Langfuse (Python)

Real uses, from the builders' own posts

How Merck serves 80+ AI teams on Langfuse

Merck

Central LLM observability for about 80 AI use cases

The question
Merck's Chief Data & AI Officer is quoted saying generative AI will only earn enterprise trust when teams can see what happens under the hood.
What they built
Merck's AI & Machine Learning team gives Langfuse to any internal team building an AI application. Access is provisioned through automated pipelines from Merck's own use case portal, and Langfuse is self-hosted to keep pharmaceutical data in-house.
Result
The case study on langfuse.com says about 80 use cases run on Langfuse, with over 200 people using it regularly. It claims development cycles dropped "from weeks to days".

Langfuse Source [8]

Tracing AI calls with agentgateway and Langfuse

Solo.io

Gateway-level LLM tracing into Langfuse

The question
The post says tracing inside application code only shows what the app reports, and cannot see gateway policies such as PII redaction or prompt injection blocking.
What they built
agentgateway emits OTLP traces to an OpenTelemetry Collector on Kubernetes. The collector forwards them to Langfuse's OTLP HTTP endpoint. No Langfuse SDK is involved.
Result
The post states every request is captured automatically with zero application code changes.

agentgateway OpenTelemetry Collector Kubernetes Gateway API Helm Source [9]

One-click open source RAG observability with Langfuse

Langfuse team (guest post on the LlamaIndex blog)

One-line Langfuse tracing for LlamaIndex RAG apps

The question
The post describes not knowing what context a LlamaIndex chat engine retrieves, how chat memory is managed, or which steps add latency.
What they built
The team built the <code>llama-index-callbacks-langfuse</code> package. It hooks into LlamaIndex's global callback manager through <code>set_global_handler("langfuse")</code>.
Result
The post says two lines of code produce detailed traces that include latency and usage/cost breakdowns.

LlamaIndex llama-index-callbacks-langfuse Source [10]

Who uses it, as listed by the maintainers

Merck

As listed by the source; we have not checked each one. [8]

Project facts

Latest versionv4.17.0, October 5, 2026 [3]
On GitHub sinceJuly 2023 [2]
LicenseMIT [2]

On AgentGid: All prompts, structured output and evals Pydantic python-dotenv FastAPI

Install

Packagepip install langfuse
Main stacksPython (231)
Example projectsMirix-AI/MIRIX, apconw/Aix-DB, TIGER-AI-Lab/TheoremExplainAgent, zstar1003/ragflow-plus, wanxingai/LightAgent

Alternatives to Langfuse (Python)

All prompts, structured output and evals

Tools that do the same job, so a project picks one or the other. Add-ons and libraries used alongside Langfuse (Python) are not listed here; they are in "Often used with".

Tool Gid Score Used in agent projectsDownloads / wk GitHub starsLicense
LangSmith pypi · no longer maintained
Platform client for monitoring, evaluating and debugging LLM applications.
62 20 (1.2%) 20.7M 1,081 MIT
Ragas pypi
Evaluate RAG and LLM applications with automated metrics and scoring.
54 3 (0.2%) 320K 16.1K Apache-2.0

More in Prompts, structured output and evals: Ultracite tiktoken (Python) tokenizers GPT Tokenizer TokenLens @graphql-codegen/typescript-operations tiktoken (JavaScript) partial-json

Sources

  1. Langfuse (Python) README (GitHub)
  2. GitHub repository
  3. GitHub releases
  4. Langfuse (Python) website
  5. llms.txt (docs index for language models)
  6. Docs: Choose where evaluations run
  7. Docs: What does a good trace look like?
  8. Merck: Enterprise-wide LLM platform serving 80+ AI teams, self-hosted on Langfuse with
  9. Solo.io (agentgateway): OpenTelemetry pipeline sending agentgateway LLM traces to Langfuse with zero app
  10. LlamaIndex: Shipped llama-index-callbacks-langfuse package adding one-click RAG tracing to L

Description written by AgentGid from these official pages, checked Oct 12, 2026. Usage numbers come from our own scan. Claims by the maintainers are quoted, not tested by us.

Is Langfuse (Python) right for your project? Ask AgentGid →