---
title: "Deploy OmniRoute Claude Code"
description: "Run Claude Code through your own multi-provider gateway"
category: "AI/ML"
url: https://railway.com/deploy/deploy-omniroute-for-claude-code
---

# Deploy OmniRoute Claude Code

Run Claude Code through your own multi-provider gateway

**[Deploy OmniRoute Claude Code on Railway](https://railway.com/template/deploy-omniroute-for-claude-code)**

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

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

## Template content

### omniroute

- **Image:** diegosouzapw/omniroute:3.8.51@sha256:8bd462c9f60d8eda79329cfbb6ea7ea723505fe7721beb944f3d43835409e218
- **Start command:** `/bin/sh -c "mkdir -p /app/data && chown -R 1000:1000 /app/data && cd /app && if command -v setpriv >/dev/null 2>&1; then exec setpriv --reuid=1000 --regid=1000 --init-groups env HOME=/home/node /app/check-permissions.sh node dev/run-standalone.mjs; else exec /app/check-permissions.sh node dev/run-standalone.mjs; fi"`
- **Health check:** /healthz
- **Public domain:** Yes

## Documentation

# Deploy and Host self hosted OmniRoute Claude Code (Self-Hosted AI Gateway for Claude Code) on Railway

This template runs OmniRoute on Railway as your own multi-provider gateway for the Claude Code CLI. You point Claude Code at it with environment variables, not a flag, then pick any model in the /model picker.

## About Hosting OmniRoute Claude Code open-source software on Railway (self hosted OmniRoute Claude Code template)

Your provider keys, API keys, and usage history stay in SQLite on the attached volume at /app/data, encrypted and owned by you.

Railway handles the domain, TLS, restarts, and volume mounts, so the only thing you configure is the Claude Code side: ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN.

## Why Deploy OmniRoute Claude Code, the Claude Code Router alternative on Railway (Railway Free Trial)

Claude Code Router is a local proxy: free to run, but it lives on your machine and dies with it. OmniRoute is one Railway service with a public domain, so a whole team points Claude Code at it. The $5 trial covers light use; after that you pay Railway and your provider bills.

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 OmniRoute Claude Code 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 OmniRoute Claude Code self hosting

Claude Code only needs a reachable ANTHROPIC_BASE_URL; the real difference is how much server plumbing you own.

| Provider | What You Get with Railway | What You Get with the Other Provider |
| --- | --- | --- |
| DigitalOcean | Template deploy, TLS domain, data volume, generated secrets, health check | Droplet with Docker, Nginx and certbot to wire and patch yourself |
| AWS | Domain, restarts, volume, one service to watch | ECS or EC2 plus ALB, certificates, EBS and IAM setup |
| Hetzner | Usage billing, $5 trial, logs and metrics in one place | Cheap VM, but you own proxy, backups, TLS and upgrades |

Railway removes proxy and certificate work, not gateway configuration.

## Common Use Cases for hosted OmniRoute Claude Code

- **Keep coding when one account hits its limit:** Add a second provider account as fallback, so an exhausted Claude plan becomes a retry, not a dead session.
- **Try GLM or Kimi inside Claude Code:** Turn on discovery aliases so they appear as claude/... ids in /model, and set CLAUDE_CODE_AUTO_COMPACT_WINDOW below their real window.
- **One gateway for a small team:** Each person sets ANTHROPIC_AUTH_TOKEN to their own OmniRoute key, so you revoke one person without touching the rest.
- **Usage analytics per key:** See which teammate or agent burned tokens against which provider, then split keys before the next long agent run.
- **A fallback combo for long sessions:** Chain a primary model to two backups so a rate limit turns into a retry on the next model, not a crashed run.

## Dependencies for OmniRoute Claude Code Docker hosted on Railway

The template runs one container from diegosouzapw/omniroute:3.8.51, pinned by digest, on port 20128, health check at /healthz, volume at /app/data. No Postgres, no Redis: state is SQLite on the volume.

### Deployment Dependencies for Managed OmniRoute Claude Code Service (AI Gateway)

Five secrets are generated per deploy: INITIAL_PASSWORD, JWT_SECRET, API_KEY_SECRET, OMNIROUTE_WS_BRIDGE_SECRET and MACHINE_ID_SALT. Fixed vars cover PORT, HOSTNAME, DATA_DIR, NEXT_PUBLIC_BASE_URL, BASE_URL, AUTH_COOKIE_SECURE and OMNIROUTE_MEMORY_MB.

### Implementation Details for OmniRoute Claude Code (Using OmniRoute official docker image)

The image serves the dashboard at /dashboard and the API at /v1, with an Anthropic-compatible path that Claude Code uses. OMNIROUTE_MEMORY_MB defaults to 1024 for dashboard work. Long /v1/responses sessions want about 8192, so plan a bigger container.

## How does OmniRoute Claude Code compare against other ways to run Claude Code through a gateway

### OmniRoute vs Claude Code Router (Claude Code Router Alternative)

- **Where it wins:** hosted on Railway, so there is no separate proxy process running next to Claude Code.
- **Same env contract:** ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN, no flag, so switching back is two lines.
- **Where CCR wins:** it lives on your laptop, so you can change routing rules without a redeploy.

### OmniRoute vs 9Router (9Router Alternative)

- **Fallback depth:** 4-tier fallback, circuit breakers and key cooldowns, so a dead key does not end the session.
- **Model mirroring:** discovery aliases expose non-Claude models as claude/... ids, so /model lists them.
- **Where 9Router wins:** it leads with quota tracking, which is simpler if per-key quotas are the whole job.

### OmniRoute vs LiteLLM (LiteLLM Alternative)

- **One container:** Node and SQLite in one image, with no Postgres or Redis beside it.
- **Settings fragment:** the dashboard CLI Code card renders the env block with a copy button.
- **Where LiteLLM wins:** Python and YAML, so teams already in Python tooling can extend routing in code.

### OmniRoute vs OpenRouter (OpenRouter Alternative)

- **Key custody:** provider keys stay in your own SQLite volume, encrypted, instead of a hosted dashboard.
- **Fallback combo:** one combo id keeps long agent sessions moving when one upstream account hits its limit.
- **Where OpenRouter wins:** nothing to deploy or upgrade, and no gateway memory to size for /v1/responses.
- **Cost shape:** you pay Railway and your providers directly, so idle time still costs a few dollars.

## How to use OmniRoute Claude Code (the OSS AI gateway)?

1. Open /dashboard and log in with the generated INITIAL_PASSWORD.
2. Add a provider and its key on the Providers page.
3. Create an OmniRoute API key. REQUIRE_API_KEY is on, so every request needs one.
4. Copy the fragment from Dashboard > CLI Code, or paste this into ~/.claude/settings.json:

```json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://your-domain",
    "ANTHROPIC_AUTH_TOKEN": "your-omniroute-key",
    "CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY": "1"
  }
}
```

5. Restart Claude Code; env vars are read once at startup. Use the gateway root, no /v1 suffix, since Claude Code appends /v1/messages.
6. Run /model to pick a claude-prefixed id, then watch the request land in the dashboard.

## How to self host OmniRoute Claude Code on other VPS Services (OmniRoute self hosting guide)

The same image runs on any Docker host. These are the four steps, minus the Railway parts.

### Clone the Repository

Pull the repo for the compose file and env examples.

```
git clone https://github.com/diegosouzapw/omniroute.git
cd omniroute
```

### Install Dependencies

Install Docker with Compose, then pull the pinned image. There's no Postgres or Redis to add.

```
docker pull diegosouzapw/omniroute:3.8.51
```

### Configure Environment Variables

Write a .env file with generated secrets and the fixed port and data path.

```
INITIAL_PASSWORD=change-me-now
JWT_SECRET=long-random-string
REQUIRE_API_KEY=true
PORT=20128
DATA_DIR=/app/data
```

### Start the OmniRoute Claude Code Application

Mount a volume at /app/data, publish port 20128, then point Claude Code at the public root. No /v1 suffix.

```
ANTHROPIC_BASE_URL=https://your-domain
ANTHROPIC_AUTH_TOKEN=your-omniroute-key
```

Railway handles the volume, generated secrets, TLS domain and health checks so none of this is manual.

## Official Pricing of OmniRoute Claude Code (OmniRoute pricing)

OmniRoute itself is free. You pay for two things only: the Railway resources the container uses, and whatever your upstream providers charge for the tokens you actually send. Provider accounts are bring-your-own.

## OmniRoute Claude Code cloud vs self hosted comparison (Pricing, features, costs, and more)

Hosted gateways bill per token and set their own rate limits. Self hosting on Railway flips that: you pay for the container and your provider accounts, and the gateway in between is yours. Here is what each path actually costs you.

### Monthly cost of self hosting OmniRoute Claude Code on Railway

Light use at 1-2 GB runs about $5-15/mo, and the $5 trial covers the first stretch. Model spend goes straight to your providers, not to a reseller margin.

### System Requirements for Hosting OmniRoute Claude Code on a VPS

Any 2 vCPU box with 2 GB RAM and 10 GB of disk gets the dashboard and light chat going. Add RAM before you add agents.

## Frequently Asked Questions (FAQs)

### Why do I get a 404 when ANTHROPIC_BASE_URL ends in /v1?

Because Claude Code appends /v1/messages itself. Point it at the gateway root, https://your-domain, with no suffix, or you get /v1/v1/messages.

### Which variable carries the API key?

ANTHROPIC_AUTH_TOKEN, sent as a Bearer token. If ANTHROPIC_API_KEY is also set, the auth token wins. Create the key in the dashboard, since REQUIRE_API_KEY is on.

### Why don't my non-Claude models show up in /model?

Claude Code only lists ids starting with claude or anthropic. Enable discovery aliases on that model or provider so OmniRoute mirrors it as a claude/... id, and set CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1.

### Does Claude Code need a restart after I change settings.json?

Yes. The env block is read once at startup, so edits to ~/.claude/settings.json do nothing until you relaunch the CLI.

### Can several people share one gateway?

Yes, one API key each. One base URL, separate keys for usage analytics and revocation.

### Why does a long agent session crash the container?

Usually memory. Agent traffic on /v1/responses wants about 8192 MB of heap, so raise OMNIROUTE_MEMORY_MB above the 1024 default and give the service near 10 GB.


## 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-omniroute-for-claude-code
