Langfuse Tracing
This document explains how to integrate Langfuse tracing with LibreChat to get full observability into your AI conversations.
Langfuse is an open-source LLM observability platform that helps you trace, monitor, and debug your LLM applications. By integrating Langfuse with LibreChat, you get full visibility into your AI conversations.
Prerequisites
Before you begin, ensure you have:
- A running LibreChat instance (see Quick Start)
- A Langfuse account (sign up for free)
- Langfuse API keys from your project settings
Setup
Add the following Langfuse-related environment variables to your .env file in your LibreChat installation directory:
| Key | Type | Description | Example |
|---|---|---|---|
| LANGFUSE_PUBLIC_KEY | string | Your Langfuse public key. | LANGFUSE_PUBLIC_KEY=pk-lf-*** |
| LANGFUSE_SECRET_KEY | string | Your Langfuse secret key. | LANGFUSE_SECRET_KEY=sk-lf-*** |
| LANGFUSE_BASE_URL | string | The Langfuse API base URL. | LANGFUSE_BASE_URL=https://cloud.langfuse.com |
Example Configuration
# Langfuse Configuration
LANGFUSE_PUBLIC_KEY=pk-lf-***
LANGFUSE_SECRET_KEY=sk-lf-***
# πͺπΊ EU Data Region
LANGFUSE_BASE_URL=https://cloud.langfuse.com
# πΊπΈ US Data Region
# LANGFUSE_BASE_URL=https://us.cloud.langfuse.comSelf-Hosted Langfuse
For self-hosted Langfuse instances, set LANGFUSE_BASE_URL to your custom URL (e.g.,
http://localhost:3000 for local development).
Restart LibreChat
After adding the environment variables, restart your LibreChat instance to apply the changes:
docker compose down
docker compose up -dSee Traces in Langfuse
Once LibreChat is restarted with Langfuse configured, you will see a new trace for every chat message response in the Langfuse UI:

Link to trace in the Langfuse UI
Message Feedback Scores
When Langfuse tracing is configured, LibreChat also sends message feedback to Langfuse as a user-feedback BOOLEAN score on the matching trace. A thumbs-up rating is sent as 1, a thumbs-down rating is sent as 0, and any selected feedback tag or comment is included on the score. Clearing feedback deletes the score.
Feedback scores include message context metadata when available, including the message ID, parent message ID, conversation/session ID, user ID, endpoint, sender, isCreatedByUser, token count, rating, and feedback tag. Empty metadata values are omitted before the score is sent.
Feedback scores use the same Langfuse credentials and base URL as tracing. They also respect LANGFUSE_TRACING_ENABLED=false, LANGFUSE_SAMPLE_RATE=0, and LANGFUSE_TRACING_ENVIRONMENT. Score delivery is best-effort, so the feedback UI does not block if Langfuse is temporarily unavailable.
How is this guide?
Automated Moderation
Configuration of the Automated Moderation System. This uses a scoring mechanism to track user violations. As users commit actions like excessive logins, registrations, or messaging, they accumulate violation scores. Upon reaching a set threshold, the user and their IP are temporarily banned. This system ensures platform security by monitoring and penalizing rapid or suspicious activities.
Logging System
This doc explains how to use the logging feature of LibreChat, which saves error and debug logs in the `/api/logs` folder. You can use these logs to troubleshoot issues, monitor your server, and report bugs. You can also disable debug logs if you want to save space.