Home Knowledge Base Langfuse

Langfuse is an open-source LLM engineering platform for tracing, evaluating, and monitoring AI applications — providing end-to-end visibility into complex LangChain, LlamaIndex, and custom LLM pipelines through structured traces that capture every component's input, output, latency, and cost, enabling teams to debug production issues, run evaluations, and iteratively improve their AI systems.

What Is Langfuse?

Why Langfuse Matters

Integration Examples

OpenAI SDK (Python):

from langfuse.openai import openai

client = openai.OpenAI()  # Langfuse-wrapped client
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Explain RAG."}],
    name="explain-rag",          # Trace name in Langfuse
    metadata={"user_id": "123"}  # Custom metadata
)

LangChain Callback:

from langfuse.callback import CallbackHandler

handler = CallbackHandler(public_key="pk-...", secret_key="sk-...")
chain.invoke({"input": "user query"}, config={"callbacks": [handler]})

Custom Tracing (Decorator):

from langfuse.decorators import observe, langfuse_context

@observe()
def retrieve_documents(query: str) -> list:
    docs = vector_store.similarity_search(query, k=5)
    langfuse_context.update_current_observation(metadata={"doc_count": len(docs)})
    return docs

@observe(name="rag-pipeline")
def answer_question(question: str) -> str:
    docs = retrieve_documents(question)
    return generate_answer(question, docs)

Evaluation Workflow

Human Annotation:

LLM-as-Judge:

Dataset Experiments:

Prompt Management

from langfuse import Langfuse

lf = Langfuse()
prompt = lf.get_prompt("customer-support-v3")  # Fetches from registry
messages = prompt.compile(customer_name="Alice", issue="billing")

Langfuse vs Alternatives

FeatureLangfuseHeliconePhoenix (Arize)LangSmith
Open sourceYes (Apache 2.0)YesYesNo
Trace modelHierarchicalFlat request logsHierarchicalHierarchical
Evaluation systemStrongBasicStrongStrong
Prompt managementYesNoNoYes
Self-hostableYes (simple)YesYesNo
LangChain integrationExcellentGoodGoodNative

Self-Hosting

git clone https://github.com/langfuse/langfuse.git
cd langfuse
docker compose up -d
# Access at http://localhost:3000

Langfuse is the open-source LLM observability platform that gives engineering teams the visibility and evaluation infrastructure needed to confidently ship and continuously improve AI applications — by combining structured tracing, automated evaluation, and prompt management in a single self-hostable platform, Langfuse provides the observability foundation that production LLM applications require without vendor lock-in.

langfusetracingopen source

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.