Railway

Deploy Opik

Open-source LLM observability: evaluation, tracing and guardrails

Deploy Opik

Just deployed

/var/lib/mysql

Just deployed

Just deployed

Just deployed

/data

Just deployed

/var/lib/clickhouse

Just deployed

/var/lib/clickhouse

opik-attachments

Bucket

Just deployed

Opik logo

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

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

Opik trace log of nine support-agent conversations

Opik trace inspector showing the span tree and token usage

Opik project dashboard charting trace volume, latency and cost

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

VariableServicePurpose
OPIK_BASIC_AUTH_USER / OPIK_BASIC_AUTH_PASSWORDfrontendCredentials for the UI and API
OPIK_ENCRYPTION_KEYbackendEncrypts stored provider keys; 16, 24 or 32 chars, never change it
S3_BUCKET / S3_URL / IS_MINIObackendAttachment storage; IS_MINIO=true selects the right client
PYTHON_CODE_EXECUTOR_STRATEGYpython-backendMust stay process
CLICKHOUSE_PASSWORDclickhouseAnalytics password, referenced by the backend

Deployment Dependencies

Hardware Requirements for Self-Hosting Opik

ResourceMinimumRecommended
CPU2 vCPU4–8 vCPU
RAM4 GB8–16 GB
Storage5 GB volumes for ClickHouse, Keeper, MySQL, Redis20 GB+ for ClickHouse as volume grows
RuntimeJava 25, Python 3.12, ClickHouse 26.3, MySQL 9, Redis 8Same

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.


Template Content

More templates in this category

View Template
Chat Chat
Chat Chat, your own unified chat and search to AI platform.

okisdev
116
View Template
stella
Self-host stella with web, API, Postgres, Redis, and object storage.

Jan Kubica
5
View Template
Hermes Agent | OpenClaw Alternative with Dashboard
Self-Hosted Hermes AI Agent for Telegram, Discord & Slack

codestorm
64