langfuse
开源 LLM 与 Agent 可观测性平台,集中记录调用链、开展评测,并帮助改进 AI 应用表现。
中文简介经编辑校订 · analytics / autogen / evaluation / langchain / large-language-models / llama-index
README / 项目原文
Langfuse is an open source LLM engineering platform. It helps teams collaboratively develop, monitor, evaluate, and debug AI applications. Langfuse can be self-hosted in minutes and is battle-tested. Proudly made with ClickHouse open source database.
🧑💻 We're hiring
Langfuse is growing fast (we doubled the team in the last 6 months) - since January 2026 we're part of ClickHouse, we're hiring engineering hybrid across the EU. We hire engineers who love open source and great developer experiences. See open roles →
✨ Core Features
LLM Application Observability: Instrument your app and start ingesting traces to Langfuse, thereby tracking LLM calls and other relevant logic in your app such as retrieval, embedding, or agent actions. Inspect and debug complex logs and user sessions. Try the interactive demo to see this in action.
Prompt Management helps you centrally manage, version control, and collaboratively iterate on your prompts. Thanks to strong caching on server and client side, you can iterate on prompts without adding latency to your application.
Evaluations are key to the LLM application development workflow, and Langfuse adapts to your needs. It supports LLM-as-a-judge, Code evaluators, user feedback collection, manual labeling, and custom evaluation pipelines via APIs/SDKs.
Datasets enable test sets and benchmarks for evaluating your LLM application. They support continuous improvement, pre-deployment testing, structured experiments, flexible evaluation, and seamless integration with frameworks like LangChain and LlamaIndex.
LLM Playground is a tool for testing and iterating on your prompts and model configurations, shortening the feedback loop and accelerating development. When you see a bad result in tracing, you can directly jump to the playground to iterate on it.
Comprehensive API: Langfuse is frequently used to power bespoke LLMOps workflows while using the building blocks provided by Langfuse via the API. OpenAPI spec, Postman collection, and typed SDKs for Python, JS/TS are available.
📦 Deploy Langfuse
Langfuse Cloud
Managed deployment by the Langfuse team, generous free-tier, no credit card required.
Self-Host Langfuse
Run Langfuse on your own infrastructure:
Local (docker compose): Run Langfuse on your own machine in 5 minutes using Docker Compose.
# Get a copy of the latest Langfuse repository git clone --depth=1 https://github.com/langfuse/langfuse.git cd langfuse # Run the langfuse docker compose docker compose upVM: Run Langfuse on a single Virtual Machine using Docker Compose.
Kubernetes (Helm): Run Langfuse on a Kubernetes cluster using Helm. This is the preferred production deployment.
See self-hosting documentation to learn more about architecture and configuration options.
Docker log rotation
The default docker-compose.yml inherits the Docker daemon's logging configuration. Docker's default json-file driver does not rotate logs unless configured, which can exhaust disk space. Set its max-size and max-file options, or keep your chosen logging backend and configure retention there. Do not rotate or truncate Docker-managed JSON log files with external tools.
After changing daemon logging defaults, restart Docker and recreate existing containers to apply them; restarting containers alone is insufficient. Plan for interruption and preserve data volumes. These settings cover container stdout/stderr, not database data volumes or ClickHouse's internal log files.
[!TIP] Self-hosting Langfuse? Subscribe to the self-hosting update list to get an email about important features and new releases for open source Langfuse — self-hosting updates only, no marketing.
🔌 Integrations
Main Integrations:
| Integration | Supports | Description |
|---|---|---|
| SDK | Python, JS/TS | Manual instrumentation using the SDKs for full flexibility. |
| OpenAI | Python, JS/TS | Automated instrumentation using drop-in replacement of OpenAI SDK. |
| Langchain | Python, JS/TS | Automated instrumentation by passing callback handler to Langchain application. |
| LlamaIndex | Python | Automated instrumentation via LlamaIndex callback system. |
| Haystack | Python | Automated instrumentation via Haystack content tracing system. |
| LiteLLM | Python, JS/TS (proxy only) | Use any LLM as a drop in replacement for GPT. Use Azure, OpenAI, Cohere, Anthropic, Ollama, VLLM, Sagemaker, HuggingFace, Replicate (100+ LLMs). |
| Vercel AI SDK | JS/TS | TypeScript toolkit designed to help developers build AI-powered applications with React, Next.js, Vue, Svelte, Node.js. |
| Mastra | JS/TS | Open source framework for building AI agents and multi-agent systems. |
| API | Directly call the public API. OpenAPI spec available. |
Packages integrated with Langfuse:
| Name | Type | Description |
|---|---|---|
| Instructor | Library | Library to get structured LLM outputs (JSON, Pydantic) |
| DSPy | Library | Framework that systematically optimizes language model prompts and weights |
| Mirascope | Library | Python toolkit for building LLM applications. |
| Ollama | Model (local) | Easily run open source LLMs on your own machine. |
| Amazon Bedrock | Model | Run foundation and fine-tuned models on AWS. |
| AutoGen | Agent Framework | Open source LLM platform for building distributed agents. |
| Flowise | Chat/Agent UI | JS/TS no-code builder for customized LLM flows. |
| Langflow | Chat/Agent UI | Python-based UI for LangChain, designed with react-flow to provide an effortless way to experiment and prototype flows. |
| Dify | Chat/Agent UI | Open source LLM app development platform with no-code builder. |
| OpenWebUI | Chat/Agent UI | Self-hosted LLM Chat web ui supporting various LLM runners including self-hosted and local models. |
| Promptfoo | Tool | Open source LLM testing platform. |
| LobeChat | Chat/Agent UI | Open source chatbot platform. |
| Vapi | Platform | Open source voice AI platform. |
| Inferable | Agents | Open source LLM platform for building distributed agents. |
| Gradio | Chat/Agent UI | Open source Python library to build web interfaces like Chat UI. |
| Goose | Agents | Open source LLM platform for building distributed agents. |
| smolagents | Agents | Open source AI agents framework. |
| CrewAI | Agents | Multi agent framework for agent collaboration and tool use. |
🚀 Quickstart
Instrument your app and start ingesting traces to Langfuse, thereby tracking LLM calls and other relevant logic in your app such as retrieval, embedding, or agent actions. Inspect and debug complex logs and user sessions.
1️⃣ Create new project
- Create Langfuse account or self-host
- Create a new project
- Create new API credentials in the project settings
2️⃣ Log your first LLM call
The @observe() decorator makes it easy to trace any Python LLM application. In this quickstart we also use the Langfuse OpenAI integration to automatically capture all model parameters.
[!TIP] Not using OpenAI? Visit our documentation to learn how to log other models and frameworks.
pip install langfuse openai
LANGFUSE_SECRET_KEY="sk-lf-..."
LANGFUSE_PUBLIC_KEY="pk-lf-..."
LANGFUSE_BASE_URL="https://cloud.langfuse.com" # 🇪🇺 EU region
# LANGFUSE_BASE_URL="https://us.cloud.langfuse.com" # 🇺🇸 US region
from langfuse import observe
from langfuse.openai import openai # OpenAI integration
@observe()
def story():
return openai.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "What is Langfuse?"}],
).choices[0].message.content
@observe()
def main():
return story()
main()
3️⃣ See traces in Langfuse
See your language model calls and other application logic in Langfuse.
Public example trace in Langfuse
💭 Support
Finding an answer to your question:
- Our documentation is the best place to start looking for answers. It is comprehensive, and we invest significant time into maintaining it. You can also suggest edits to the docs via GitHub.
- Langfuse FAQs where the most common questions are answered.
- Use "Ask AI" to get instant answers to your questions.
Support Channels:
- Ask any question in our public Q&A on GitHub Discussions. Please include as much detail as possible (e.g. code snippets, screenshots, background information) to help us understand your question.
- Request a feature on GitHub Discussions.
- Report a Bug on GitHub Issues.
- For time-sensitive queries, ping us via the in-app chat widget.
🤝 Contributing
Your contributions are welcome!
- Vote on Ideas in GitHub Discussions.
- Raise and comment on Issues.
- Open a PR - see CONTRIBUTING.md for details on how to setup a development environment.
🥇 License
This repository is MIT licensed, except for the ee folders. See LICENSE and docs for more details.
Dependencies
We deploy this code base in Docker containers based on the Linux Alpine Image (source). You may find the Dockerfiles in web/Dockerfile and worker/Dockerfile.
⭐️ Star History
❤️ Open Source Projects Using Langfuse
Top open-source Python projects that use Langfuse, ranked by stars (Source):
🔒 Security & Privacy
We take data security and privacy seriously. Please refer to our Security and Privacy page for more information.
Telemetry
By default, Langfuse automatically reports basic usage statistics of self-hosted instances to a centralized server (PostHog).
This helps us to:
- Understand how Langfuse is used and improve the most relevant features.
- Track overall usage for internal and external (e.g. fundraising) reporting.
The telemetry does not include raw traces, prompts, observations, scores, or dataset contents. We document the exact fields that are collected, where they are sent, and the implementation reference in our telemetry docs.
For Langfuse OSS, you can opt out by setting TELEMETRY_ENABLED=false.

🇨🇳 🤝 🪢 · Langfuse Cloud · 自托管 · 演示
Langfuse 使用 GitHub Discussions 作为支持和功能请求的平台。
我们正在招聘。 加入我们,从事产品工程和技术市场职位。
Langfuse 是一个 开源 LLM 工程 平台。它帮助团队协作 开发、监控、评估 以及 调试 AI 应用。Langfuse 可在几分钟内 自托管,并且经过 实战考验。
✨ 核心特性

LLM 应用可观察性:为你的应用插入仪表代码,并开始将追踪数据传送到 Langfuse,从而追踪 LLM 调用及应用中其他相关逻辑(如检索、嵌入或代理操作)。检查并调试复杂日志及用户会话。试试互动的 演示 看看效果。
提示管理 帮助你集中管理、版本控制并协作迭代提示。得益于服务器和客户端的高效缓存,你可以在不增加延迟的情况下反复迭代提示。
评估 是 LLM 应用开发流程的关键组成部分,Langfuse 能够满足你的多样需求。它支持 LLM 作为"裁判"、用户反馈收集、手动标注以及通过 API/SDK 实现自定义评估流程。
数据集 为评估你的 LLM 应用提供测试集和基准。它们支持持续改进、部署前测试、结构化实验、灵活评估,并能与 LangChain、LlamaIndex 等框架无缝整合。
LLM 试玩平台 是用于测试和迭代提示及模型配置的工具,缩短反馈周期,加速开发。当你在追踪中发现异常结果时,可以直接跳转至试玩平台进行调整。
综合 API:Langfuse 常用于驱动定制化的 LLMOps 工作流程,同时利用 Langfuse 提供的构建模块和 API。我们提供 OpenAPI 规格、Postman 集合以及针对 Python 和 JS/TS 的类型化 SDK。
📦 部署 Langfuse

Langfuse Cloud
由 Langfuse 团队管理的部署,提供慷慨的免费额度(爱好者计划),无需信用卡。
自托管 Langfuse
在你自己的基础设施上运行 Langfuse:
本地(docker compose):使用 Docker Compose 在你的机器上于 5 分钟内运行 Langfuse。
# 获取最新的 Langfuse 仓库副本 git clone https://github.com/langfuse/langfuse.git cd langfuse # 运行 Langfuse 的 docker compose docker compose upKubernetes(Helm):使用 Helm 在 Kubernetes 集群上部署 Langfuse。这是推荐的生产环境部署方式。
虚拟机:使用 Docker Compose 在单台虚拟机上部署 Langfuse。
请参阅 自托管文档 了解更多关于架构和配置选项的信息。
🔌 集成

主要集成:
| 集成 | 支持语言/平台 | 描述 |
|---|---|---|
| SDK | Python, JS/TS | 使用 SDK 进行手动仪表化,实现全面灵活性。 |
| OpenAI | Python, JS/TS | 通过直接替换 OpenAI SDK 实现自动仪表化。 |
| Langchain | Python, JS/TS | 通过传入回调处理器至 Langchain 应用实现自动仪表化。 |
| LlamaIndex | Python | 通过 LlamaIndex 回调系统实现自动仪表化。 |
| Haystack | Python | 通过 Haystack 内容追踪系统实现自动仪表化。 |
| LiteLLM | Python, JS/TS (仅代理) | 允许使用任何 LLM 替代 GPT。支持 Azure、OpenAI、Cohere、Anthropic、Ollama、VLLM、Sagemaker、HuggingFace、Replicate(100+ LLMs)。 |
| Vercel AI SDK | JS/TS | 基于 TypeScript 的工具包,帮助开发者使用 React、Next.js、Vue、Svelte 和 Node.js 构建 AI 驱动的应用。 |
| API | 直接调用公共 API。提供 OpenAPI 规格。 | |
| Google VertexAI 和 Gemini | 模型 | 在 Google 上运行基础模型和微调模型。 |
与 Langfuse 集成的软件包:
| 名称 | 类型 | 描述 |
|---|---|---|
| Instructor | 库 | 用于获取结构化 LLM 输出(JSON、Pydantic)的库。 |
| DSPy | 库 | 一个系统性优化语言模型提示和权重的框架。 |
| Amazon Bedrock | 模型 | 在 AWS 上运行基础模型和微调模型。 |
| Mirascope | 库 | 构建 LLM 应用的 Python 工具包。 |
| Ollama | 模型(本地) | 在你的机器上轻松运行开源 LLM。 |
| AutoGen | 代理框架 | 用于构建分布式代理的开源 LLM 平台。 |
| Flowise | 聊天/代理界面 | 基于 JS/TS 的无代码构建器,用于定制化 LLM 流程。 |
| Langflow | 聊天/代理界面 | 基于 Python 的 LangChain 用户界面,采用 react-flow 设计,提供便捷的实验与原型构建体验。 |
| Dify | 聊天/代理界面 | 带有无代码构建器的开源 LLM 应用开发平台。 |
| OpenWebUI | 聊天/代理界面 | 自托管的 LLM 聊天网页界面,支持包括自托管和本地模型在内的多种 LLM 运行器。 |
| Promptfoo | 工具 | 开源 LLM 测试平台。 |
| LobeChat | 聊天/代理界面 | 开源聊天机器人平台。 |
| Vapi | 平台 | 开源语音 AI 平台。 |
| Inferable | 代理 | 构建分布式代理的开源 LLM 平台。 |
| Gradio | 聊天/代理界面 | 开源 Python 库,可用于构建类似聊天 UI 的网页界面。 |
| Goose | 代理 | 构建分布式代理的开源 LLM 平台。 |
| smolagents | 代理 | 开源 AI 代理框架。 |
| CrewAI | 代理 | 多代理框架,用于实现代理之间的协作与工具调用。 |
🚀 快速入门
为你的应用增加仪表代码,并开始将追踪数据上传到 Langfuse,从而记录 LLM 调用及应用中其他相关逻辑(如检索、嵌入或代理操作)。
1️⃣ 创建新项目
- 创建 Langfuse 账户 或 自托管
- 创建一个新项目
- 在项目设置中创建新的 API 凭证
2️⃣ 记录你的第一个 LLM 调用
使用 @observe() 装饰器 可轻松跟踪任何 Python LLM 应用。在本快速入门中,我们还使用了 Langfuse 的 OpenAI 集成 来自动捕获所有模型参数。
[!提示] 不使用 OpenAI?请访问 我们的文档 了解如何记录其他模型和框架。
安装依赖:
pip install langfuse openai
配置环境变量(创建名为 .env 的文件):
LANGFUSE_SECRET_KEY="sk-lf-..."
LANGFUSE_PUBLIC_KEY="pk-lf-..."
LANGFUSE_BASE_URL="https://cloud.langfuse.com" # 🇪🇺 欧盟区域
# LANGFUSE_BASE_URL="https://us.cloud.langfuse.com" # 🇺🇸 美洲区域
创建示例代码(文件名:main.py):
from langfuse import observe
from langfuse.openai import openai # OpenAI 集成
@observe()
def story():
return openai.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "What is Langfuse?"}],
).choices[0].message.content
@observe()
def main():
return story()
main()
3️⃣ 在 Langfuse 中查看追踪记录
在 Langfuse 中查看你的语言模型调用及其他应用逻辑。

[!提示]
⭐️ 给我们加星
💭 支持
查找问题答案:
- 我们的 文档 是查找答案的最佳起点。内容全面,我们投入大量时间进行维护。你也可以通过 GitHub 提出文档修改建议。
- Langfuse 常见问题 解答了最常见的问题。
- 使用 "Ask AI" 立即获取问题答案。
支持渠道:
- 在 GitHub Discussions 的 公共问答 中提出任何问题。 请尽量提供详细信息(如代码片段、截图、背景信息)以帮助我们理解你的问题。
- 在 GitHub Discussions 中 提出功能请求。
- 在 GitHub Issues 中 报告 Bug。
- 对于时效性较强的问题,请通过应用内聊天小部件联系我们。
🤝 贡献
欢迎你的贡献!
- 在 GitHub Discussions 中为 想法投票。
- 提出并评论 问题。
- 提交 PR —— 详情请参见 CONTRIBUTING.md,了解如何搭建开发环境。
🥇 许可证
除 ee 文件夹外,本仓库采用 MIT 许可证。详情请参见 LICENSE 以及 文档。
⭐️ 星标历史
❤️ 使用 Langfuse 的开源项目
以下是使用 Langfuse 的顶级开源 Python 项目,按星标数排名(来源):
🔒 安全与隐私
我们非常重视数据安全和隐私。更多信息请参阅我们的 安全与隐私 页面。
遥测
默认情况下,Langfuse 会自动将自托管实例的基础使用统计数据上传至集中服务器(PostHog)。
这有助于我们:
- 了解 Langfuse 的使用情况,并改进最关键的功能。
- 跟踪整体使用数据,以便内部及外部(例如筹款)报告。
遥测数据不包括原始 traces、prompts、observations、scores 或数据集内容。我们在遥测文档中记录了收集的确切字段、这些数据会被发送到哪里,以及相关实现说明。
对于 Langfuse OSS,你可以通过设置 TELEMETRY_ENABLED=false 来选择退出。