Langfuse
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.
Prerequisites
- An account in a Langfuse Cloud or Langfuse self-hosted instance
- A running Langflow server with a flow that you want to trace
If you need a flow to test the Langfuse integration, see the Langflow quickstart.
Set Langfuse credentials as environment variables
-
Create a set of Langfuse API keys.
-
Copy the following API key information:
- Secret key
- Public key
- Base URL
tipLangflow previously used
LANGFUSE_HOSTas the variable for the Langfuse base URL. This is still supported for backward compatibility, butLANGFUSE_BASE_URLis 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, andLANGFUSE_BASE_URLwith your API key details from Langfuse. Add the following entries to your.envfile:_10LANGFUSE_SECRET_KEY=sk-..._10LANGFUSE_PUBLIC_KEY=pk-..._10LANGFUSE_BASE_URL=https://us.cloud.langfuse.com -
Start Langflow with the configuration in the
.envfile:_10uv 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.
Disable Langfuse tracing
To disable the Langfuse integration, remove the Langfuse environment variables, and then restart Langflow.
Run Langfuse and Langflow with Docker Compose
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:
- Secret key
- Public key
- Base URL
tipLangflow previously used
LANGFUSE_HOSTas the variable for the Langfuse base URL.LANGFUSE_HOSTis still supported for backward compatibility, butLANGFUSE_BASE_URLis the preferred environment variable. If both values are set, thenLANGFLOW_BASE_URLis used. -
Add your Langflow credentials to your Langflow
docker-compose.ymlfile in theenvironmentsection.The following example is based on the example
docker-compose.yml._32services:_32langflow:_32image: langflowai/langflow:latest # or another version tag on https://hub.docker.com/r/langflowai/langflow_32pull_policy: always # set to 'always' when using 'latest' image_32ports:_32- "7860:7860"_32depends_on:_32- postgres_32environment:_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_BASE_URL=https://us.cloud.langfuse.com_32volumes:_32- langflow-data:/app/langflow_32_32postgres:_32image: postgres:16_32environment:_32POSTGRES_USER: langflow_32POSTGRES_PASSWORD: langflow_32POSTGRES_DB: langflow_32ports:_32- "5432:5432"_32volumes:_32- langflow-postgres:/var/lib/postgresql/data_32_32volumes:_32langflow-postgres:_32langflow-data: -
Start the Docker container:
_10docker-compose up -
To confirm Langfuse is connected to your Langflow container, run the following command:
_10docker 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_URLenvironment variable in yourdocker-compose.ymlfile.Output similar to the following indicates success:
_10https://us.cloud.langfuse.com_10200