docs/versioned_docs/version-1.8.0/Develop/integrations-langfuse.mdx
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
Langfuse is an open-source platform for LLM observability. It provides tracing and monitoring capabilities for AI applications, helping developers debug, analyze, and optimize their AI systems. Langfuse integrates with various tools and frameworks, including workflow builders and runtimes like Langflow.
This guide explains how to configure Langflow to collect tracing data about your flow executions and automatically send the data to Langfuse.
<iframe width="760" height="415" src="https://www.youtube.com/embed/SA9gGbzwNGU?si=eDKvdtvhb3fJCSbl" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>:::tip If you need a flow to test the Langfuse integration, see the Langflow quickstart. :::
Create a set of Langfuse API keys.
Copy the following API key information:
:::tip
Langflow previously used LANGFUSE_HOST as the variable for the Langfuse base URL.
This is still supported for backward compatibility, but LANGFUSE_BASE_URL is now the preferred environment variable and will be used if both values are set.
:::
Set your Langfuse project credentials as environment variables.
In the following examples, replace SECRET_KEY, PUBLIC_KEY, and LANGFUSE_BASE_URL with your API key details from Langfuse.
Add the following entries to your .env file:
LANGFUSE_SECRET_KEY=sk-...
LANGFUSE_PUBLIC_KEY=pk-...
LANGFUSE_BASE_URL=https://us.cloud.langfuse.com
Start Langflow with the configuration in the .env file:
uv run langflow run --env-file .env
Run a flow.
Langflow automatically collects and sends tracing data about the flow execution to Langfuse.
View the collected data in your Langfuse dashboard.
Langfuse also provides a public live trace example dashboard.
To disable the Langfuse integration, remove the Langfuse environment variables, and then restart Langflow.
As an alternative to the previous setup, particularly for self-hosted Langfuse, you can run both services with Docker Compose.
Create a set of Langfuse API keys.
Copy the following API key information:
:::tip
Langflow previously used LANGFUSE_HOST as the variable for the Langfuse base URL.
LANGFUSE_HOST is still supported for backward compatibility, but LANGFUSE_BASE_URL is the preferred environment variable.
If both values are set, then LANGFLOW_BASE_URL is used.
:::
Add your Langflow credentials to your Langflow docker-compose.yml file in the environment section.
The following example is based on the example docker-compose.yml.
services:
langflow:
image: langflowai/langflow:latest # or another version tag on https://hub.docker.com/r/langflowai/langflow
pull_policy: always # set to 'always' when using 'latest' image
ports:
- "7860:7860"
depends_on:
- postgres
environment:
- LANGFLOW_DATABASE_URL=postgresql://langflow:langflow@postgres:5432/langflow
# This variable defines where the logs, file storage, monitor data and secret keys are stored.
- LANGFLOW_CONFIG_DIR=app/langflow
- LANGFUSE_SECRET_KEY=sk-...
- LANGFUSE_PUBLIC_KEY=pk-...
- LANGFUSE_BASE_URL=https://us.cloud.langfuse.com
volumes:
- langflow-data:/app/langflow
postgres:
image: postgres:16
environment:
POSTGRES_USER: langflow
POSTGRES_PASSWORD: langflow
POSTGRES_DB: langflow
ports:
- "5432:5432"
volumes:
- langflow-postgres:/var/lib/postgresql/data
volumes:
langflow-postgres:
langflow-data:
Start the Docker container:
docker-compose up
To confirm Langfuse is connected to your Langflow container, run the following command:
docker compose exec langflow python -c "import requests, os; addr = os.environ.get('LANGFUSE_BASE_URL'); print(addr); res = requests.get(addr, timeout=5); print(res.status_code)"
If there is an error, make sure you have set the LANGFUSE_BASE_URL environment variable in your docker-compose.yml file.
Output similar to the following indicates success:
https://us.cloud.langfuse.com
200