# Langfuse Tracing (/docs/configuration/langfuse)

[Langfuse](https://langfuse.com) 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:

1. A running LibreChat instance (see [Quick Start](/docs/quick_start))
2. A Langfuse account ([sign up for free](https://cloud.langfuse.com))
3. Langfuse API keys from your project settings

## Setup

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

<OptionTable
  options={[
    ['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

```sh filename=".env"
# 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
```

<Callout type="note" title="Self-Hosted Langfuse">
For self-hosted Langfuse instances, set `LANGFUSE_BASE_URL` to your custom URL (e.g., `http://localhost:3000` for local development).
</Callout>

## Restart LibreChat

After adding the environment variables, restart your LibreChat instance to apply the changes:

```sh
docker compose down
docker compose up -d
```

## See 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:

![LibreChat example trace](https://langfuse.com/images/cookbook/integration_librechat/librechat-example-trace.png)

[Link to trace in the Langfuse UI](https://cloud.langfuse.com/project/cloramnkj0002jz088vzn1ja4/traces/57b4aa20a258a2e9e2d1ce2e4eacb21c?observation=06f5341a68d723b1&timestamp=2026-02-04T13%3A02%3A54.248Z&traceId=57b4aa20a258a2e9e2d1ce2e4eacb21c)
