---
title: "Deploy Langfuse v4 + LiteLLM"
description: "LiteLLM gateway: every LLM call traced in Langfuse v4, no code changes"
category: "AI/ML"
url: https://railway.com/deploy/langfuse-v4-litellm
---

# Deploy Langfuse v4 + LiteLLM

LiteLLM gateway: every LLM call traced in Langfuse v4, no code changes

**[Deploy Langfuse v4 + LiteLLM on Railway](https://railway.com/template/langfuse-v4-litellm)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/langfuse-v4-litellm/manifest.json

- **Creator:** My Projects
- **Category:** AI/ML

## Template content

### litellm-postgres https://devicons.railway.app/i/postgresql.svg

- **Image:** ghcr.io/railwayapp-templates/postgres-ssl:18

### ClickHouse https://devicons.railway.app/ClickHouse?variant=light

- **Source:** nick0lay/railway-templates
- **Health check:** /ping

### langfuse-worker https://langfuse.com/icon.svg

- **Image:** langfuse/langfuse-worker:4.72
- **Health check:** /api/health

### litellm https://cdn.jsdelivr.net/gh/selfhst/icons/svg/litellm.svg

- **Image:** litellm/litellm-database:v1.106.6
- **Start command:** `/bin/sh -c "echo '{litellm_settings: {callbacks: [langfuse_otel]}}' > /tmp/litellm.yaml && exec docker/prod_entrypoint.sh --config /tmp/litellm.yaml --port $PORT"`
- **Health check:** /health/liveliness
- **Public domain:** Yes

### Postgres https://devicons.railway.app/i/postgresql.svg

- **Image:** ghcr.io/railwayapp-templates/postgres-ssl:18

### langfuse-web https://langfuse.com/icon.svg

- **Image:** langfuse/langfuse:4.72
- **Health check:** /api/public/health
- **Public domain:** Yes

### Redis https://devicons.railway.app/i/redis.svg

- **Image:** redis:8.10
- **Start command:** `/bin/sh -c "rm -rf $RAILWAY_VOLUME_MOUNT_PATH/lost+found/ && exec docker-entrypoint.sh redis-server --requirepass $REDIS_PASSWORD --maxmemory-policy noeviction --appendonly yes --dir $RAILWAY_VOLUME_MOUNT_PATH"`

## Buckets

- **Bucket**

## Documentation

# Deploy and Host Langfuse v4 + LiteLLM on Railway

LiteLLM is an open-source AI gateway: one OpenAI-compatible API for OpenAI, Anthropic, Gemini, Bedrock, Azure and 100+ other LLM providers, with virtual keys, budgets and spend tracking. Langfuse is the open-source LLM observability platform for tracing, prompt management and evaluations. This template connects them, so every LLM call through the gateway is traced in Langfuse.

## About Hosting Langfuse v4 + LiteLLM

The stack has eight parts: the LiteLLM proxy with its own PostgreSQL, and the full Langfuse v4 platform (web app, worker, PostgreSQL, ClickHouse, Redis and a Railway Bucket for storage). They talk over Railway's private network, and every database has a persistent volume.

LiteLLM starts with Langfuse's OpenTelemetry integration enabled and the keys of the Langfuse project created on first boot. Your apps keep using the OpenAI SDK they already have; only the base URL changes, and every request shows up in Langfuse with prompt, response, tokens, cost and latency.

## Common Use Cases

- Trace every LLM call from all your apps and agents without adding an SDK to each one
- Give each app or team its own virtual key with a budget, and see their cost and usage in both LiteLLM and Langfuse
- Switch or mix providers (OpenAI, Anthropic, Gemini, open models) behind one API, and compare their quality and latency in Langfuse
- Debug agents and RAG pipelines step by step, and run evaluations on real traffic
- Keep prompts, responses and keys in your own infrastructure

## Dependencies for Langfuse v4 + LiteLLM Hosting

- PostgreSQL 18 for LiteLLM, and a second one for Langfuse
- ClickHouse 26.8 LTS
- Redis 8 (with `noeviction`, as Langfuse's queues require)
- Railway Bucket (S3-compatible storage)

### Deployment Dependencies

- LiteLLM: https://github.com/BerriAI/litellm
- Langfuse: https://github.com/langfuse/langfuse
- LiteLLM proxy docs: https://docs.litellm.ai/docs/simple_proxy

### Implementation Details

**What you set:** only `LANGFUSE_INIT_USER_EMAIL`, your Langfuse admin login. Provider keys are optional at deploy time; you can add them in the LiteLLM UI.

**After deploy:**

1. LiteLLM UI: open `https:///ui`, log in as `admin` with the generated `UI_PASSWORD`, and add a model with your provider key.
2. Call the gateway with the generated `LITELLM_MASTER_KEY` or a virtual key:

```bash
curl https:///v1/chat/completions \
  -H "Authorization: Bearer $LITELLM_MASTER_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "gpt-4o-mini", "messages": [{"role": "user", "content": "Hello"}]}'
```

3. Langfuse: open the `langfuse-web` URL, log in with your email and the generated `LANGFUSE_INIT_USER_PASSWORD`, and find the request under Tracing.

**This template:**

- Enables LiteLLM's `langfuse_otel` callback, which works with Langfuse v4's OpenTelemetry ingestion, and sends traces over the private network
- Gives LiteLLM its own PostgreSQL, so its schema updates can never touch Langfuse's tables
- Generates the LiteLLM master key, salt key and UI password
- Includes everything from our Langfuse v4 template: admin account and API keys created on first boot, closed sign-up, pinned versions, Redis with `noeviction`, lean ClickHouse, Railway Bucket

**Notes:** don't change `LITELLM_SALT_KEY`, `SALT` or `ENCRYPTION_KEY` after the first deploy; stored keys depend on them. Use the `litellm/litellm-database` image when upgrading LiteLLM.

## Why Deploy Langfuse v4 + LiteLLM on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying Langfuse v4 + LiteLLM on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [Weaviate](https://railway.com/deploy/weaviate-1) — Vector database with hybrid search and an API key-protected API
- [Möbius v0.1 Personal AI OS](https://railway.com/deploy/mobius-v01-personal-ai-os) — Self-hosted AI agent that builds and runs apps for you, with memory.

Open this page in a browser: https://railway.com/deploy/langfuse-v4-litellm
