---
title: "Deploy Langfuse LlamaIndex"
description: "Trace LlamaIndex RAG pipelines in your own Langfuse"
category: "AI/ML"
url: https://railway.com/deploy/deploy-langfuse-for-llamaindex
---

# Deploy Langfuse LlamaIndex

Trace LlamaIndex RAG pipelines in your own Langfuse

**[Deploy Langfuse LlamaIndex on Railway](https://railway.com/template/deploy-langfuse-for-llamaindex)**

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

- **Creator:** onepush
- **Category:** AI/ML

## Template content

### langfuse-worker

- **Image:** langfuse/langfuse-worker:3

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

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

### Redis https://cdn.sanity.io/images/sy1jschh/production/0ce0bfdcfbdbf69662b1116671f97c2dd788b655-157x157.svg

- **Image:** redis:8.2
- **Start command:** `/bin/sh -c "rm -rf $RAILWAY_VOLUME_MOUNT_PATH/lost+found/ && exec docker-entrypoint.sh redis-server --requirepass $REDIS_PASSWORD --save 60 1 --dir $RAILWAY_VOLUME_MOUNT_PATH"`

### ClickHouse

- **Image:** clickhouse/clickhouse-server:24.8

### langfuse-web

- **Image:** langfuse/langfuse:3
- **Public domain:** Yes

## Buckets

- **langfuse-bucket**

## Documentation

# Deploy and Host self hosted Langfuse LlamaIndex (Open-Source Tracing for LlamaIndex RAG Apps) on Railway

This template runs a self-hosted Langfuse v3 stack that receives LlamaIndex traces from Python apps. It is built for teams running RAG apps on LlamaIndex.

## About Hosting Langfuse LlamaIndex open-source software on Railway (self hosted Langfuse for LlamaIndex tracing template)

Self hosting Langfuse keeps your LlamaIndex traces on infrastructure you control.

## Why Deploy Langfuse LlamaIndex, the LangSmith alternative on Railway (Railway Free Trial)

LangSmith sends your retrieved document text and prompts off your infrastructure, and its self-hosting is Enterprise-only. Railway's $5 trial covers a first look.

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

### Railway vs Other Hosting Providers and VPS for Langfuse LlamaIndex self hosting

Self-hosting Langfuse means six services, so your host choice matters. Here is how Railway compares.

| Provider | What You Get with Railway | What You Get with the Other Provider |
| --- | --- | --- |
| DigitalOcean | Template deploys with per-service secrets and an S3-compatible bucket included. | A Droplet where you write the Compose setup and manage firewall, storage and backups. |
| AWS | A running stack with no VPC or IAM design, and simple usage billing at low traffic. | Fine-grained networking and managed services, at the cost of much more configuration. |
| Hetzner | A managed platform with no OS or Docker daemon to maintain. | Low VM prices for the 4 cores and 16 GiB RAM Langfuse recommends, but you own every update and backup. |

For a small team that wants LlamaIndex traces flowing without a sysadmin job, Railway is the simpler path.

## Common Use Cases for hosted Langfuse LlamaIndex

- **Debugging wrong chunks:** Open the retrieval span for a bad answer and read the retrieved node text. You can see whether the right document was never fetched or was fetched and then ignored.
- **Comparing chunk sizes or top_k:** Run the same questions against two index configs tagged with different versions, then compare retrieval spans side by side.
- **Per-user cost for a chatbot:** Attach a user_id and session_id to each request, and token usage from LLM and embedding spans rolls up per user.
- **Tracing agents and tool calls:** Each tool call and the reasoning between calls appear as nested spans, so a looping or wrong-tool agent shows its exact decision point.
- **Building eval datasets:** Pull production traces with low scores or thumbs-down feedback and save their inputs as a dataset of real user questions.

## Dependencies for Langfuse LlamaIndex Docker hosted on Railway

This template runs the official Langfuse v3 stack as six Railway services in one project. Traces from your LlamaIndex app pass through the queue into ClickHouse, so a span can take a few seconds to appear.

### Deployment Dependencies for Managed Langfuse LlamaIndex Service (LLM Observability)

You need a Railway project with room for six services and a persistent volume for ClickHouse. langfuse-web runs the langfuse/langfuse:3 image on public port 3000, and langfuse-worker runs langfuse/langfuse-worker:3 on port 3030.

### Implementation Details for Langfuse LlamaIndex (Using Langfuse official docker image)

The services read DATABASE_URL, REDIS_CONNECTION_STRING (with ?family=0 for Railway private IPv6), CLICKHOUSE_URL, CLICKHOUSE_MIGRATION_URL, CLICKHOUSE_USER, CLICKHOUSE_PASSWORD and CLICKHOUSE_CLUSTER_ENABLED=false.

## How does Langfuse LlamaIndex compare against other ways to trace LlamaIndex apps

Langfuse suits teams that want LlamaIndex traces on their own infrastructure. The alternatives trade control for convenience, so pick based on how much you value hosting control and framework fit.

### Langfuse vs LangSmith (LangChain Tracing Alternative)

- **Hosting model:** Langfuse core is MIT licensed and runs on your Railway project with no usage limits. LangSmith is closed source, with self-hosting limited to Enterprise plans.
- **Framework fit:** LangSmith suits mostly-LangChain apps. Langfuse fits LlamaIndex through the OpenInference instrumentor.
- **Where LangSmith wins:** Its tooling is more mature and tightly tied to LangChain.

### Langfuse vs Arize Phoenix (OpenTelemetry Tracing Alternative)

- **Protocol:** Phoenix is OpenTelemetry based and maintains OpenInference, the same instrumentation Langfuse uses for LlamaIndex spans.
- **Licensing:** Phoenix is source available under the Elastic License 2.0, while Langfuse core is MIT.
- **Where Phoenix wins:** Its built-in evaluation tooling is strong, so it may fit better if evals are your main goal.

### Langfuse vs Helicone (Proxy-Based LLM Logging Alternative)

- **Architecture:** Helicone routes calls through its proxy, adding a hop in your request path. Langfuse uses SDK instrumentation instead.
- **Scope:** Helicone focuses on request logs and spend. Langfuse captures retrieved nodes, embeddings and agent tool calls as nested spans.
- **Where Helicone wins:** A proxy is simpler if you only need request logs and cost numbers.

### Langfuse vs LlamaTrace (Hosted Phoenix for LlamaIndex Alternative)

- **Hosting:** LlamaTrace is a hosted service run by Arize. Langfuse runs on your Railway project, keeping traces and document text with you.
- **Setup:** LlamaTrace needs no infrastructure. Langfuse needs several services, including ClickHouse and Redis, which you maintain.
- **Where LlamaTrace wins:** It's the fastest path to seeing LlamaIndex traces with no stack to run.

## How to use Langfuse LlamaIndex (the OSS LLM observability platform)?

Once the deploy is healthy, these steps send your first LlamaIndex trace to your own Langfuse.

1. Sign up at your Railway Langfuse domain and create a project.
2. Create an API key pair in project settings and copy both keys.
3. Install: `pip install langfuse openinference-instrumentation-llama-index llama-index llama-index-llms-openai -U`.
4. Export `LANGFUSE_PUBLIC_KEY`, `LANGFUSE_SECRET_KEY`, and `LANGFUSE_BASE_URL=https://your-langfuse-domain`.
5. Run the code below, then open Tracing in Langfuse.

```python
from langfuse import get_client
from openinference.instrumentation.llama_index import LlamaIndexInstrumentor
from llama_index.core import VectorStoreIndex, Document

langfuse = get_client()
print(langfuse.auth_check())  # True means keys and host are correct

LlamaIndexInstrumentor().instrument()
index = VectorStoreIndex.from_documents([Document(text="Railway deploys apps.")])
print(index.as_query_engine().query("What does Railway do?"))

langfuse.flush()  # send buffered spans before exit
```

If the trace is missing, confirm `auth_check()` returned True.

## How to self host Langfuse LlamaIndex on other VPS Services (Langfuse self hosting guide)

You can run this stack on a plain VM with Docker Compose. Treat it as a single-machine setup for testing or small teams.

### Clone the Repository

Clone the official Langfuse repository and move into it.

```bash
git clone https://github.com/langfuse/langfuse.git
cd langfuse
```

### Install Dependencies

Confirm Docker and the Compose plugin are installed on the VM.

```bash
docker --version
docker compose version
```

### Configure Environment Variables

Copy the example env file and set real values for the database, ClickHouse, Redis, S3 and auth.

```bash
cp .env.example .env
openssl rand -hex 32
```

### Start the Langfuse LlamaIndex Application

Bring the stack up, open https://your-domain and create a project. Point `LANGFUSE_BASE_URL` in your LlamaIndex app at that domain.

## Official Pricing of Langfuse LlamaIndex (Langfuse pricing)

Langfuse is MIT licensed for the core repository, and self-hosting the open-source version is free with no usage limits. Langfuse Cloud has its own paid tiers if you would rather not run the stack yourself.

## Langfuse LlamaIndex cloud vs self hosted comparison (Pricing, features, costs, and more)

Langfuse Cloud is the fastest start, while self hosting on Railway trades some setup for control over where your trace data lives.

### Monthly cost of self hosting Langfuse LlamaIndex on Railway

Self hosting the MIT-licensed Langfuse core is free, with no usage limits. The real cost is infrastructure: this six-service stack with ClickHouse runs roughly $15-40 per month on Railway at low traffic.

### System Requirements for Hosting Langfuse LlamaIndex on a VPS

The official guidance for a single VM is 4 cores, 16 GiB RAM and 100 GiB of disk, mostly because ClickHouse wants memory and fast storage. Budget for those specs before you move to a VPS.

## Frequently Asked Questions (FAQs)

### Do I need the old LlamaIndex callback handler anymore?

No, for new code you can skip it.

### Why are my traces missing from a script?

Short-lived scripts and notebooks often exit before buffered spans are sent.

### How do I attach user_id and session_id to LlamaIndex traces?

Wrap the request in `propagate_attributes(user_id=..., session_id=..., tags=[...], metadata={...})`.

### Does the trace capture the retrieved nodes?

Yes. The retrieval span shows the nodes that came back for a query, along with their text and scores, which is usually the fastest way to see why the right chunk did not make it into the prompt.

### Does it work with LlamaIndex agents and workflows?

It does for the operations the instrumentor covers, including agent tool calls and LLM steps. Wrap the top-level run in an observation so the whole agent run appears as one trace.

### Does Langfuse store my document text?

Yes, if you send it.


## 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/deploy-langfuse-for-llamaindex
