English
Get started

← All templates · AI and agents

Deploy Langfuse in one click

Tracing, evals and prompt management for LLM apps

A self-hosted alternative to LangSmith and Braintrust.

What is Langfuse?

Langfuse is an open-source LLM observability platform, often run in place of LangSmith. Each request your app or agent makes becomes a trace: the exact prompt, the model's answer, the tool calls and retrieval steps in between, with tokens, cost and latency. Traces filter by user, session or cost. Prompts live outside your code in versions, and the SDK serves the one labelled production, so a rollback is moving that label. Evaluations score answers with an LLM as a judge, code checks or manual labels, and datasets hold test sets for experiments before a release.

People self-host Langfuse to keep prompts and user conversations on a server they control. The MIT-licensed version is the whole product with no usage limits, so nothing is paid per trace or per seat. One catch: the Forgot password link works only once transactional email is set up, and without it a lost password means editing the database.

Hosting Langfuse on Pethost

  1. You sign in to Pethost with a passkey, GitHub or Google. No machine yet? You pick a plan, and the link waits until it is ready.
  2. New project opens at Langfuse. You fill in what it asks for and click Create project: Email, Admin password.
  3. In a minute or two Langfuse is live at its own address with HTTPS. Its secrets are made at random, and its data is in the nightly backup.
  4. It is a project like any other: you or your agent can change it, roll it back or restore it.

Questions about Langfuse

Is Langfuse free and open source?

Yes. Everything outside its ee folders is MIT-licensed. Self-hosted, it needs a license key only for enterprise features such as audit logs, SCIM, data retention policies and project-level RBAC roles.

Langfuse vs LangSmith: what is the difference?

Both trace and evaluate LLM apps. LangSmith, made by the LangChain team, is proprietary and can be self-hosted only on its Enterprise plan; Langfuse is MIT-licensed and free to self-host.

Does Langfuse support OpenTelemetry?

Yes. Its Python and TypeScript SDKs are thin layers over OpenTelemetry, and other languages can send spans to its OTLP endpoint over HTTP. Integrations cover LangChain, LlamaIndex, the Vercel AI SDK and many more.

How does Langfuse track LLM cost?

It records token usage on each generation and takes the cost your app sends, or works it out from built-in prices for OpenAI, Anthropic and Google models. Any other model gets its price in Project Settings > Models.

How do I send traces to a self-hosted Langfuse?

Create API keys in the project's settings, then set LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY and LANGFUSE_BASE_URL, your instance's address, for the SDK. Without LANGFUSE_BASE_URL it sends to Langfuse's EU cloud.

How much memory and disk does Langfuse need?

Langfuse is demanding: its ClickHouse and five other services want several gigabytes of memory, and traces pile up. On Pethost the Scale plan is enough for it, with room for other apps beside it.

Langfuse Docker Compose file

The template is this compose.yaml and the variables written into the project’s .env as it is created. Pethost runs the file as it is written.

Containers: langfuse-web (langfuse/langfuse:4.59.0), langfuse-worker (langfuse/langfuse-worker:4.59.0), clickhouse (clickhouse/clickhouse-server:25.12), minio (cgr.dev/chainguard/minio@sha256:2136d593beacf4461187035eca949fe49abd589d5079735025c711ca58fee0c8), redis (redis:7.4), postgres (postgres:17).

Volumes, in the nightly backup: clickhouse, minio, redis, postgres.

x-env: &env
  NEXTAUTH_URL: ${URL}
  DATABASE_URL: postgresql://postgres:${POSTGRES_PASSWORD}@postgres:5432/postgres
  SALT: ${SALT}
  ENCRYPTION_KEY: ${ENCRYPTION_KEY}
  CLICKHOUSE_MIGRATION_URL: clickhouse://clickhouse:9000
  CLICKHOUSE_URL: http://clickhouse:8123
  CLICKHOUSE_USER: clickhouse
  CLICKHOUSE_PASSWORD: ${CLICKHOUSE_PASSWORD}
  CLICKHOUSE_CLUSTER_ENABLED: "false"
  LANGFUSE_S3_EVENT_UPLOAD_BUCKET: langfuse
  LANGFUSE_S3_EVENT_UPLOAD_REGION: auto
  LANGFUSE_S3_EVENT_UPLOAD_ACCESS_KEY_ID: minio
  LANGFUSE_S3_EVENT_UPLOAD_SECRET_ACCESS_KEY: ${MINIO_PASSWORD}
  LANGFUSE_S3_EVENT_UPLOAD_ENDPOINT: http://minio:9000
  LANGFUSE_S3_EVENT_UPLOAD_FORCE_PATH_STYLE: "true"
  LANGFUSE_S3_EVENT_UPLOAD_PREFIX: events/
  LANGFUSE_S3_MEDIA_UPLOAD_BUCKET: langfuse
  LANGFUSE_S3_MEDIA_UPLOAD_REGION: auto
  LANGFUSE_S3_MEDIA_UPLOAD_ACCESS_KEY_ID: minio
  LANGFUSE_S3_MEDIA_UPLOAD_SECRET_ACCESS_KEY: ${MINIO_PASSWORD}
  LANGFUSE_S3_MEDIA_UPLOAD_ENDPOINT: http://minio:9000
  LANGFUSE_S3_MEDIA_UPLOAD_FORCE_PATH_STYLE: "true"
  LANGFUSE_S3_MEDIA_UPLOAD_PREFIX: media/
  REDIS_HOST: redis
  REDIS_PORT: "6379"
  REDIS_AUTH: ${REDIS_PASSWORD}

x-depends: &depends
  postgres:
    condition: service_healthy
  minio:
    condition: service_healthy
  redis:
    condition: service_healthy
  clickhouse:
    condition: service_healthy

services:
  langfuse-web:
    image: langfuse/langfuse:4.59.0
    restart: unless-stopped
    depends_on: *depends
    environment:
      <<: *env
      NEXTAUTH_SECRET: ${NEXTAUTH_SECRET}
      # Node sizes its heap by the machine's memory; a bound keeps the six services within 4 GB.
      # The web server needs about 500 MB of heap just to start.
      NODE_OPTIONS: --max-old-space-size=1024
      AUTH_DISABLE_SIGNUP: "true"
      # The first start makes this organization, its project and its owner: nobody has to sign up.
      LANGFUSE_INIT_ORG_ID: default
      LANGFUSE_INIT_ORG_NAME: Default
      LANGFUSE_INIT_PROJECT_ID: default
      LANGFUSE_INIT_PROJECT_NAME: Default
      LANGFUSE_INIT_USER_EMAIL: ${ADMIN_EMAIL}
      LANGFUSE_INIT_USER_NAME: Admin
      LANGFUSE_INIT_USER_PASSWORD: ${ADMIN_PASSWORD}

  langfuse-worker:
    image: langfuse/langfuse-worker:4.59.0
    restart: unless-stopped
    depends_on: *depends
    environment:
      <<: *env
      NODE_OPTIONS: --max-old-space-size=512

  clickhouse:
    image: clickhouse/clickhouse-server:25.12
    restart: unless-stopped
    environment:
      CLICKHOUSE_DB: default
      CLICKHOUSE_USER: clickhouse
      CLICKHOUSE_PASSWORD: ${CLICKHOUSE_PASSWORD}
    # The stock config logs at trace level into ten files of 1000 MB and keeps its query, metric and
    # trace tables for ever: on a small machine they would fill the disk over months. This keeps the
    # server's log under 300 MB and those tables a week.
    entrypoint:
      - sh
      - -c
      - |
        cat > /etc/clickhouse-server/config.d/small-machine.xml <<'XML'
        <clickhouse>
          <logger><level>information</level><size>100M</size><count>3</count></logger>
          <query_log><ttl>event_date + INTERVAL 7 DAY DELETE</ttl></query_log>
          <metric_log><ttl>event_date + INTERVAL 7 DAY DELETE</ttl></metric_log>
          <asynchronous_metric_log><ttl>event_date + INTERVAL 7 DAY DELETE</ttl></asynchronous_metric_log>
          <trace_log><ttl>event_date + INTERVAL 7 DAY DELETE</ttl></trace_log>
          <text_log><ttl>event_date + INTERVAL 7 DAY DELETE</ttl></text_log>
          <part_log><ttl>event_date + INTERVAL 7 DAY DELETE</ttl></part_log>
          <error_log><ttl>event_date + INTERVAL 7 DAY DELETE</ttl></error_log>
        </clickhouse>
        XML
        exec /entrypoint.sh
    volumes:
      - clickhouse:/var/lib/clickhouse
    healthcheck:
      test: wget --no-verbose --tries=1 --spider http://localhost:8123/ping || exit 1
      interval: 5s
      timeout: 5s
      retries: 10
      start_period: 10s

  # Langfuse's own compose file runs this image, as MinIO publishes no images of its own any more;
  # the digest pins one build of it.
  minio:
    image: cgr.dev/chainguard/minio@sha256:2136d593beacf4461187035eca949fe49abd589d5079735025c711ca58fee0c8
    restart: unless-stopped
    entrypoint:
      - sh
      - -c
      - mkdir -p /data/langfuse && exec minio server --address :9000 /data
    environment:
      MINIO_ROOT_USER: minio
      MINIO_ROOT_PASSWORD: ${MINIO_PASSWORD}
    volumes:
      - minio:/data
    healthcheck:
      test: ["CMD", "mc", "ready", "local"]
      interval: 2s
      timeout: 5s
      retries: 15
      start_period: 5s

  redis:
    image: redis:7.4
    restart: unless-stopped
    command:
      - --requirepass
      - ${REDIS_PASSWORD}
      - --maxmemory-policy
      - noeviction
    volumes:
      - redis:/data
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 3s
      timeout: 10s
      retries: 10

  postgres:
    image: postgres:17
    restart: unless-stopped
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: postgres
      TZ: UTC
      PGTZ: UTC
    volumes:
      - postgres:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 3s
      timeout: 3s
      retries: 10

volumes:
  clickhouse:
  minio:
  redis:
  postgres:

More in AI and agents