Skip to main content
Version: 1.10.x (Next)

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

tip

If you need a flow to test the Langfuse integration, see the Langflow quickstart.

Set Langfuse credentials as environment variables

  1. Create a set of Langfuse API keys.

  2. Copy the following API key information:

    • Secret key
    • Public key
    • Base URL
    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.

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


    _10
    LANGFUSE_SECRET_KEY=sk-...
    _10
    LANGFUSE_PUBLIC_KEY=pk-...
    _10
    LANGFUSE_BASE_URL=https://us.cloud.langfuse.com

  4. Start Langflow with the configuration in the .env file:


    _10
    uv run langflow run --env-file .env

  5. Run a flow.

    Langflow automatically collects and sends tracing data about the flow execution to Langfuse.

  6. 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.

  1. Create a set of Langfuse API keys.

  2. Copy the following API key information:

    • Secret key
    • Public key
    • Base URL
    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.

  3. 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.


    _35
    services:
    _35
    langflow:
    _35
    image: langflowai/langflow:latest # or another version tag on https://hub.docker.com/r/langflowai/langflow
    _35
    pull_policy: always # set to 'always' when using 'latest' image
    _35
    ports:
    _35
    - "7860:7860"
    _35
    depends_on:
    _35
    - postgres
    _35
    environment:
    _35
    - LANGFLOW_DATABASE_URL=postgresql://langflow:langflow@postgres:5432/langflow
    _35
    # This variable defines where the logs, file storage, monitor data and secret keys are stored.
    _35
    - LANGFLOW_CONFIG_DIR=app/langflow
    _35
    - LANGFUSE_SECRET_KEY=sk-...
    _35
    - LANGFUSE_PUBLIC_KEY=pk-...
    _35
    - LANGFUSE_BASE_URL=https://us.cloud.langfuse.com
    _35
    volumes:
    _35
    - langflow-data:/app/langflow
    _35
    _35
    postgres:
    _35
    # Pinned to a specific Debian base (trixie) so the postgres:16 tag does
    _35
    # not silently roll its OS, which triggers a glibc collation mismatch
    _35
    # warning on existing volumes. See https://github.com/langflow-ai/langflow/issues/9608
    _35
    image: postgres:16-trixie
    _35
    environment:
    _35
    POSTGRES_USER: langflow
    _35
    POSTGRES_PASSWORD: langflow
    _35
    POSTGRES_DB: langflow
    _35
    ports:
    _35
    - "5432:5432"
    _35
    volumes:
    _35
    - langflow-postgres:/var/lib/postgresql/data
    _35
    _35
    volumes:
    _35
    langflow-postgres:
    _35
    langflow-data:

  4. Start the Docker container:


    _10
    docker-compose up

  5. To confirm Langfuse is connected to your Langflow container, run the following command:


    _10
    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:


    _10
    https://us.cloud.langfuse.com
    _10
    200

See also

Search