IntegrationsOtherLibreChat
This is a Jupyter notebook

Trace LibreChat with Langfuse

This guide shows you how to integrate Langfuse tracing with LibreChat to get full observability into your AI conversations.

What is LibreChat? LibreChat is an open-source AI chat platform that brings together multiple AI providers (OpenAI, Anthropic, Google, Azure, and more) into a unified interface.

What is Langfuse? Langfuse is an open-source LLM observability platform that helps you trace, monitor, and debug your LLM applications.

Prerequisites

Before you begin, ensure you have:

  1. A running LibreChat instance (see LibreChat Installation Guide)
  2. A Langfuse account (sign up for free)
  3. Langfuse API keys from your project settings

Configure LibreChat Environment Variables

LibreChat uses environment variables for configuration. Add the following Langfuse-related variables to your .env file in your LibreChat installation directory:

# 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.com

Note: 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.

See traces in Langfuse

Once LibreChat is restarted with Langfuse configured, you can see a new trace for every chat message response in the Langfuse UI:

LibreChat example trace

Link to trace in the Langfuse UI

Was this page helpful?