Integrate Langfuse with Langflow
Langfuse (GitHub) 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 such as workflows builders like Langflow.
This guide walks you through how to configure Langflow to collect tracing data about your flow executions and automatically send the data to Langfuse.
Prerequisites
- A project in Langflow with a runnable flow
- A Langfuse Cloud or self-hosted Langfuse account
Set Langfuse credentials as environment variables
-
In Langfuse, go to Project Settings, and then create a new set of API keys.
-
Copy the following API key information:
- Secret Key
- Public Key
- Host URL
- Set your Langfuse project credentials as environment variables in the same environment where you run Langflow.
The following examples set environment variables in a Linux or macOS terminal session or in a Windows command prompt session:
Replace SECRET_KEY
, PUBLIC_KEY
, and HOST_URL
with the API key information you copied from Langfuse.
- Linux or macOS
- Windows
_10export LANGFUSE_SECRET_KEY=SECRET_KEY_10export LANGFUSE_PUBLIC_KEY=PUBLIC_KEY_10export LANGFUSE_HOST=HOST_URL
_10set LANGFUSE_SECRET_KEY=SECRET_KEY_10set LANGFUSE_PUBLIC_KEY=PUBLIC_KEY_10set LANGFUSE_HOST=HOST_URL
Start Langflow and view traces in Langfuse
- Start Langflow in the same terminal or environment where you set the environment variables:
_10uv run langflow run
-
In Langflow, open an existing project, and then run a flow.
Langflow automatically collects and sends tracing data about the flow execution to Langfuse.
-
View the collected data in your Langfuse project dashboard.
For a live public example trace in a Langfuse dashboard, see Public example trace in Langfuse.
Disable Langfuse Tracing
To disable the Langfuse integration, remove the environment variables you set in the previous steps and restart Langflow.
Run Langfuse and Langflow with Docker Compose
If you prefer to self-host Langfuse, you can run both services with Docker Compose.
-
In Langfuse, go to Project Settings, and then create a new set of API keys.
-
Copy the following API key information:
- Secret Key
- Public Key
- Host URL
- Add your Langflow API keys to your
docker-compose.yml
file. An example docker-compose.yml file is available in the Langflow GitHub repo.
_32services:_32 langflow:_32 image: langflowai/langflow:latest # or another version tag on https://hub.docker.com/r/langflowai/langflow_32 pull_policy: always # set to 'always' when using 'latest' image_32 ports:_32 - "7860:7860"_32 depends_on:_32 - postgres_32 environment:_32 - LANGFLOW_DATABASE_URL=postgresql://langflow:langflow@postgres:5432/langflow_32 # This variable defines where the logs, file storage, monitor data and secret keys are stored._32 - LANGFLOW_CONFIG_DIR=app/langflow_32 - LANGFUSE_SECRET_KEY=sk-..._32 - LANGFUSE_PUBLIC_KEY=pk-..._32 - LANGFUSE_HOST=https://us.cloud.langfuse.com_32 volumes:_32 - langflow-data:/app/langflow_32_32 postgres:_32 image: postgres:16_32 environment:_32 POSTGRES_USER: langflow_32 POSTGRES_PASSWORD: langflow_32 POSTGRES_DB: langflow_32 ports:_32 - "5432:5432"_32 volumes:_32 - langflow-postgres:/var/lib/postgresql/data_32_32volumes:_32 langflow-postgres:_32 langflow-data:
- Start the Docker container.
_10docker-compose up
- To confirm Langfuse is connected to your Langflow container, run this command.
Ensure you've exported
LANGFLOW_HOST
as a variable in your terminal.
_10docker compose exec langflow python -c "import requests, os; addr = os.environ.get('LANGFUSE_HOST'); print(addr); res = requests.get(addr, timeout=5); print(res.status_code)"
An output similar to this indicates success:
_10https://us.cloud.langfuse.com_10200