LangfuseLangfuse Python SDK 4.15.4 · Python 3.10+
Dashboard
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
38 small wins to finish your pathNext lesson →

Langfuse logoLangfuse overview

Langfuse records what an LLM application did, step by step, and keeps its prompts, its scores and its test sets in one place.

Langfuse was started in 2023 by Marc Klingen, Max Deichmann and Clemens Rawert during Y Combinator's W23 batch, and is built mostly in Berlin; in January 2026 the company joined ClickHouse. The server is open source, with its core features under the MIT licence, and runs as Langfuse Cloud or on your own machines. The Python SDK below is version 4.15.4.

Traces, observations, prompts and scores

A trace is one request to your application, such as one customer ticket. It holds observations: the steps inside it, like a model call, a tool call or a lookup, nested by which step ran inside which. The SDK is built on OpenTelemetry, the open standard for tracing, and sends observations to the server in the background.

On top of traces, Langfuse keeps prompts with versions and labels, so a prompt can change without a deploy; scores, numbers or labels attached to a trace by your code, a person or a judge; and datasets of test inputs, which experiments run your application against.

Where an observation goes
Your code runsdecorator, with block, OpenAIObservation recordedtype, input, output, metadataQueued with otherssent every 5 s or on flushMasked on exportmask_otel_spans patchesSent to base_urlLangfuse Cloud, or 127.0.0.1
Hover or tap a piece to see what it is and which lesson built it.
Follow an observation

Pick one to watch it run, step by step.

A support desk you trace

The running example is a small online shop's support desk: order A17 shipped on 3 March, order B22 cannot be found, and refunds need a person's approval. It starts as a plain Python function. By the end it is traced step by step, calls a model, hides card numbers before anything is sent, takes its prompt from Langfuse, records what customers thought, and refuses to release a prompt that scores worse than the one it replaces.

What you build: the desk, traced, and its prompt released safely
the desk, one ticket at a timechanging its promptsupport-ticketone trace per ticketanswer-ticketprompt from Langfuselookup-orderWARNING when missingwrite-replytokens and costmask_cardsbefore anything is sentrecord_feedbacka score on the tracea candidate prompta version nobody fetchestwo experiment runsthe same test ticketsthe gatereleased, or blocked
Hover or tap a piece to see what it is and which lesson built it.
What you end up with

Pick one to watch it run, step by step.

Each piece is built on its own first, in the lesson the drawing names.

Everything in this course, and where it is going
Your first traceModel callsOrganising tracesWhat leaves your processPromptsScores and experimentsProjectsserver on your machine@observeobservation typesending observations by handa stand-in model, tracedOpenAI callserrors and log levelsusers, tags and metadatasessionsenvironments and releasestrace idsbatching and flushrecorded argumentsmasking before exportsamplingspans from other librariesprompts in Langfusechat prompts and configversions and labelscache and fallbacklinking prompts to tracesscorescustomer feedbackdatasetsexperimentscomparing promptsa regression gateLangfuse Cloud and a real modelthe traced support deska gated prompt release
Hover or tap a piece to see what it is and which lesson built it.

A Langfuse server on your machine

The hosted service needs an account and two API keys. You need neither. Lesson 2 starts local_langfuse.py, a small server on your own machine: it answers the requests the SDK makes, keeps what it receives so you can print it, and refuses any connection to another computer. Every output you will see came back from it. Lesson 29 shows the one change for Langfuse Cloud.

What you need to run the lessons

  • Python 3.10 or later, and pip.
  • Functions, decorators and dictionaries.
  • No account anywhere, and nothing leaves your machine.

The next lesson installs the SDK and shows what it does when no keys are set.

Back toAll frameworks

Every expert started right here.