---
title: "Deploy Opik"
description: "Open-source LLM observability: evaluation, tracing and guardrails"
category: "AI/ML"
url: https://railway.com/deploy/opik
---

# Deploy Opik

Open-source LLM observability: evaluation, tracing and guardrails

**[Deploy Opik on Railway](https://railway.com/template/opik)**

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

## Template content

### backend https://raw.githubusercontent.com/comet-ml/opik/refs/heads/main/apps/opik-documentation/documentation/static/img/logo.svg

- **Image:** ghcr.io/comet-ml/opik/opik-backend:2.2.45
- **Start command:** `/bin/bash -c "./run_db_migrations.sh && ./provision_agent_insights_readonly_user.sh && ./entrypoint.sh"`
- **Health check:** /healthcheck

### MySQL https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/mysql.svg

- **Image:** mysql:9.4
- **Start command:** `docker-entrypoint.sh mysqld --innodb-use-native-aio=0 --disable-log-bin --performance_schema=0 --innodb-buffer-pool-size=1G`

### python-backend https://raw.githubusercontent.com/comet-ml/opik/refs/heads/main/apps/opik-documentation/documentation/static/img/logo.svg

- **Image:** ghcr.io/comet-ml/opik/opik-python-backend:2.2.45
- **Start command:** `tini -s -- /bin/sh -c "exec gunicorn --access-logfile - --workers 1 --threads 5 --worker-class gthread --bind [::]:8000 --chdir ./src 'opik_backend:create_app()'"`
- **Health check:** /healthcheck

### frontend https://raw.githubusercontent.com/comet-ml/opik/refs/heads/main/apps/opik-documentation/documentation/static/img/logo.svg

- **Source:** https://github.com/gridalpha/opik-railway
- **Public domain:** Yes

### Redis https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/redis.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"`

### keeper https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/clickhouse.svg

- **Source:** https://github.com/gridalpha/opik-railway

### clickhouse https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/clickhouse.svg

- **Source:** https://github.com/gridalpha/opik-railway

## Buckets

- **opik-attachments**

## Documentation

![Opik logo](https://raw.githubusercontent.com/comet-ml/opik/refs/heads/main/apps/opik-documentation/documentation/static/img/opik-logo.svg)

# Deploy and Host Opik on Railway

Opik is Comet's open-source platform for tracing, evaluating and optimising LLM applications. It records every prompt, model call, retrieval step and tool invocation your app makes, groups them into traces you can replay, and scores them with LLM-as-a-judge metrics, heuristic checks or your own Python code. Teams building RAG pipelines, assistants and agents use it to answer what logs cannot: which prompt version raised hallucination rate, which model is burning the token budget, and whether last night's change made answers better or only different. It is Apache-2.0 licensed, with integrations for OpenAI, Anthropic, LangChain, LlamaIndex, LiteLLM, CrewAI and OpenTelemetry.

Deploy Opik on Railway and you get the full production topology, not a single-container demo. This template runs seven services: an nginx **frontend** serving the React UI and proxying the API, the Java **backend** that owns ingestion and evaluation, a **python-backend** running code metrics and the prompt optimizer, **ClickHouse** for trace analytics with a **Keeper** node coordinating its replicated tables, and managed **MySQL** and **Redis**. A storage bucket holds attachments. Only the frontend is public; everything else talks over Railway's private network, and the whole surface sits behind HTTP basic auth, because open-source Opik has no login of its own.

![Diagram of the seven Opik services deployed on Railway](https://res.cloudinary.com/rroe4rtk/image/upload/v1788201459/opik-architecture.png)

## Getting Started with Opik on Railway

`OPIK_BASIC_AUTH_USER` and `OPIK_BASIC_AUTH_PASSWORD` on the frontend are the only values you must choose, and the frontend refuses to start without the password, so the deployment is never briefly open. Open the public URL, sign in at the browser prompt, and skip the welcome dialog. Every project starts empty, so the first useful action is to send a trace. Install the SDK with `pip install opik` and point it at your deployment — credentials go in the URL, because the auth gate covers the API too:

```
import opik

opik.configure(
    url="https://opik:YOUR_PASSWORD@your-app.up.railway.app/api/",
    use_local=False,
)

@opik.track
def answer(question: str) -> str:
    return "..."   # your LLM call goes here

answer("How do I reset my password?")
```

Refresh the UI and a project appears with your trace in it. Click the row to open the inspector: the span tree lists retrieval and model calls in order, and the right panel carries input, output, metadata and token usage. Dashboards charts volume, latency and cost, the Prompt library versions prompts outside your codebase, and Experiments replay a dataset against a new prompt to compare scores. If traces never appear, check the SDK URL ends in `/api/`.

![Opik project list showing trace counts and token averages](https://res.cloudinary.com/rroe4rtk/image/upload/v1788201461/opik-projects.png)

![Opik trace log of nine support-agent conversations](https://res.cloudinary.com/rroe4rtk/image/upload/v1788201463/opik-traces.png)

![Opik trace inspector showing the span tree and token usage](https://res.cloudinary.com/rroe4rtk/image/upload/v1788201465/opik-trace-detail.png)

![Opik project dashboard charting trace volume, latency and cost](https://res.cloudinary.com/rroe4rtk/image/upload/v1788201466/opik-dashboard.png)

## About Hosting Opik

Opik separates two things most logging tools conflate: the record of what your application did, and a judgement about whether it did it well. Traces land in ClickHouse, where a month of ingestion still answers aggregate queries in milliseconds, and evaluation runs on top of that record. Self-hosting matters because traces carry your users' prompts and your model outputs.

Key features:

- Tracing for OpenAI, Anthropic, Gemini, Bedrock, LangChain, LlamaIndex, LiteLLM, CrewAI and OpenTelemetry
- LLM-as-a-judge and code-based metrics, online against live traffic or offline against datasets
- Datasets, experiments and test suites for prompt and model regression testing
- A prompt library with version history, and an optimizer that tunes prompts for you
- Cost, latency and token dashboards per project

The services divide along those lines. The frontend serves the UI and proxies `/api`. The backend owns ingestion, evaluation and every database migration. The python-backend executes user-supplied metric code and optimizer jobs from a Redis queue. ClickHouse stores traces, spans and feedback scores, and Keeper coordinates the replicated tables and cluster-wide DDL that Opik's schema requires. MySQL holds projects, prompts, datasets and experiments, Redis carries locks and online-scoring streams, and the bucket holds attachments stripped from large traces.

## Why Deploy Opik on Railway

Railway removes the operational work self-hosting an observability stack normally brings.

- Seven services, four volumes and a storage bucket from one click
- Private networking between app, databases and ClickHouse, no exposed ports
- Managed MySQL and Redis with automatic backups
- HTTPS and a public domain issued automatically
- Vertical scaling without a migration as trace volume grows

## Common Use Cases

- **Debugging RAG pipelines** — see which chunks were retrieved for a bad answer, and how the prompt was assembled, before blaming the model
- **Prompt regression testing** — replay a dataset against a new prompt version and compare scores before shipping
- **Production monitoring for agents** — online evaluation rules score live traffic and alert when quality drops, and per-project dashboards show which model and route dominate spend

## Dependencies for Opik

- `ghcr.io/comet-ml/opik/opik-frontend` — nginx and the React UI
- `ghcr.io/comet-ml/opik/opik-backend` — API, ingestion, migrations
- `ghcr.io/comet-ml/opik/opik-python-backend` — metric execution and the optimizer
- `clickhouse/clickhouse-server:26.3` and `clickhouse/clickhouse-keeper:26.3` — trace analytics and its coordination node
- Managed MySQL 9 for state, managed Redis 8 for locks, streams and the job queue
- A Railway object-storage bucket — trace attachments

### Environment Variables Reference

| Variable | Service | Purpose |
|---|---|---|
| `OPIK_BASIC_AUTH_USER` / `OPIK_BASIC_AUTH_PASSWORD` | frontend | Credentials for the UI and API |
| `OPIK_ENCRYPTION_KEY` | backend | Encrypts stored provider keys; 16, 24 or 32 chars, never change it |
| `S3_BUCKET` / `S3_URL` / `IS_MINIO` | backend | Attachment storage; `IS_MINIO=true` selects the right client |
| `PYTHON_CODE_EXECUTOR_STRATEGY` | python-backend | Must stay `process` |
| `CLICKHOUSE_PASSWORD` | clickhouse | Analytics password, referenced by the backend |

### Deployment Dependencies

- Source: https://github.com/comet-ml/opik · Docs: https://www.comet.com/docs/opik/
- SDK: https://pypi.org/project/opik/ · Template sources: https://github.com/gridalpha/opik-railway

## Hardware Requirements for Self-Hosting Opik

| Resource | Minimum | Recommended |
|---|---|---|
| CPU | 2 vCPU | 4–8 vCPU |
| RAM | 4 GB | 8–16 GB |
| Storage | 5 GB volumes for ClickHouse, Keeper, MySQL, Redis | 20 GB+ for ClickHouse as volume grows |
| Runtime | Java 25, Python 3.12, ClickHouse 26.3, MySQL 9, Redis 8 | Same |

The backend sizes its heap from the container's memory limit and ClickHouse reads the CPU quota correctly, so both follow whatever you scale the services to.

## Self-Hosting Opik

Upstream ships a launcher that starts the whole stack with Docker Compose:

```
git clone https://github.com/comet-ml/opik.git
cd opik
./opik.sh
```

That brings up MySQL, Redis, ClickHouse, ZooKeeper, MinIO and the three application containers on http://localhost:5173. To pull the published images directly, keep the frontend and both backends on one tag:

```
docker pull ghcr.io/comet-ml/opik/opik-backend:latest
docker pull ghcr.io/comet-ml/opik/opik-python-backend:latest
docker pull ghcr.io/comet-ml/opik/opik-frontend:latest
```

Running it yourself means operating ClickHouse and its coordination node, keeping three images in step and providing S3-compatible storage. Railway provisions all of that for you.

## How Much Does Opik Cost to Self-Host?

Opik is free and open source under Apache-2.0, so self-hosting costs infrastructure only. Comet also runs Opik Cloud: a free tier at 25,000 spans per month with 60-day retention, and Pro at $19 per month for 100,000 spans. On Railway you pay for compute and volumes, not per trace, which makes self-hosting cheaper as volume grows.

## FAQ

**What is Opik?**
Opik is an open-source LLM evaluation and observability platform from Comet. It traces LLM and agent calls, scores them with automated metrics, and manages the prompts and datasets you test against.

**Is Opik free?**
Yes. Opik is Apache-2.0 with no feature gating in the self-hosted build, so you pay only for the infrastructure it runs on.

**Why does self-hosted Opik need both MySQL and ClickHouse?**
MySQL holds projects, prompts, datasets and experiments; ClickHouse holds traces and spans, where columnar storage keeps aggregate queries fast at millions of rows.

**How do I send traces to a self-hosted Opik?**
Install the `opik` package and call `opik.configure(url="https://user:password@your-app.up.railway.app/api/", use_local=False)`, or set `OPIK_URL_OVERRIDE`. Decorate functions with `@opik.track` and traces appear within seconds.

**Can I run LLM-as-a-judge metrics without an external API key?**
Judge metrics call a model, so they need a provider key added under Configuration → AI providers. Code-based metrics, dashboards and tracing work with no key.


## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [stella](https://railway.com/deploy/stella) — Self-host stella with web, API, Postgres, Redis, and object storage.
- [Hermes Agent | OpenClaw Alternative with Dashboard](https://railway.com/deploy/hermes-agent-or-openclaw-alternative-wit) — Self-Hosted Hermes AI Agent for Telegram, Discord & Slack

Open this page in a browser: https://railway.com/deploy/opik
