---
title: "Deploy OmniRoute Codex CLI"
description: "Run OpenAI Codex CLI through your own AI gateway"
category: "AI/ML"
url: https://railway.com/deploy/deploy-omniroute-for-codex-cli
---

# Deploy OmniRoute Codex CLI

Run OpenAI Codex CLI through your own AI gateway

**[Deploy OmniRoute Codex CLI on Railway](https://railway.com/template/deploy-omniroute-for-codex-cli)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/deploy-omniroute-for-codex-cli/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 Codex CLI (Self-Hosted AI Gateway for OpenAI Codex CLI) on Railway

This template deploys OmniRoute as one Railway service so you can point OpenAI Codex CLI at your own gateway.

## About Hosting OmniRoute Codex CLI open-source software on Railway (self hosted OmniRoute for OpenAI Codex CLI template)

This template runs one OmniRoute container from the official diegosouzapw/omniroute image, pinned to a digest, with a volume at /app/data.

## Why Deploy OmniRoute Codex CLI, the OpenRouter alternative on Railway (Railway Free Trial)

OpenRouter is the easy hosted route if you want one bill and no infrastructure.

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 Codex CLI 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 Codex CLI self hosting

Railway gives you the OmniRoute container, a persistent volume and a public HTTPS domain without server setup.

| Provider | What You Get with Railway | What You Get with the Other Provider |
| --- | --- | --- |
| DigitalOcean | One-click template, managed domain and TLS, and memory you can raise in the dashboard | Cheaper droplets, but you set up Docker, proxy, TLS and backups yourself |
| AWS | One service with no VPC or load balancer to configure before Codex CLI can reach /v1 | Deep networking control, with more moving parts to reach a working gateway |
| Hetzner | Managed deploys, a public URL on first boot and rollbacks without SSH | Low-cost servers with generous RAM, but you own the OS, updates and firewall |

If you already run Docker on a VPS, Hetzner or DigitalOcean will cost less per gigabyte once coding agents push the heap toward 8 GB.

## Common Use Cases for hosted OmniRoute Codex CLI

- **Codex CLI on non-OpenAI models:** Point Codex at your gateway with a custom provider table in ~/.codex/config.toml, then route requests to Claude, Gemini or open models while keeping the Codex workflow you already know.
- **Fallback when a plan is rate limited:** When one provider starts returning 429s, OmniRoute's fallback chain and key cooldowns move the next request to another provider, so a long refactor doesn't stop halfway through.
- **One gateway for a team using Codex:** Each teammate sets OMNIROUTE_API_KEY in their shell and points Codex at the same base URL, so provider keys stay on the server and nobody pastes them into laptops.
- **Usage tracking per key:** Issue a separate API key for each developer or project and check the dashboard's usage and quota analytics to see who is spending what across providers.
- **Testing models with profiles:** Keep a profile for OmniRoute and another for direct OpenAI in ~/.codex, then run codex --profile to compare answers from different models on the same coding task before you commit to one.

## Dependencies for OmniRoute Codex CLI Docker hosted on Railway

This section lists what the template deploys and what you need before it runs.

### Deployment Dependencies for Managed OmniRoute Codex CLI Service (AI Gateway)

The template runs one service from the pinned image diegosouzapw/omniroute:3.8.51, listening on port 20128 with a health check at /healthz.

The template generates INITIAL_PASSWORD, JWT_SECRET, API_KEY_SECRET, OMNIROUTE_WS_BRIDGE_SECRET and MACHINE_ID_SALT.

### Implementation Details for OmniRoute Codex CLI (Using OmniRoute official docker image)

The official image is pinned by digest, so you get the same build every time and upgrades happen on purpose.

Codex CLI talks to OmniRoute through the Responses API, and upstream notes that coding agents on /v1/responses need about 8192 MB of heap and a container near 10 GB.

## How does OmniRoute Codex CLI compare against other ways to run Codex CLI on other models

### OmniRoute vs OpenRouter (OpenRouter Alternative)

- **Hosting model:** OpenRouter is a hosted router you sign up for, while OmniRoute runs as one container in your own Railway project, so your keys and logs stay under your control.
- **Pricing:** OmniRoute is MIT licensed and free to run; you pay Railway and the upstream providers. OpenRouter wins on zero infrastructure work.
- **Codex fit:** Both give Codex CLI an OpenAI-compatible endpoint, but OmniRoute lets you point base_url at your own domain.

### OmniRoute vs LiteLLM (LiteLLM Alternative)

- **Runtime:** LiteLLM is a Python proxy configured in YAML, while OmniRoute is a Node service with a web dashboard for adding providers.
- **Storage:** OmniRoute keeps state in SQLite with encrypted provider keys, so there is no Postgres or Redis to run. LiteLLM's full feature set usually expects a database.
- **Where LiteLLM wins:** If your team already runs Python infrastructure and wants proxy config as code, LiteLLM fits better.

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

- **Scope:** Both are self-hosted routers between Codex CLI and upstream providers, so the choice depends on which dashboard and feature set you prefer.
- **Fallback:** OmniRoute documents four-tier fallback with circuit breakers and key cooldowns, so a rate-limited provider hands off to the next tier without Codex config changes.
- **Honest caveat:** Compare both on the routing strategies and providers you need, since the feature sets overlap and change between releases.

### OmniRoute vs direct OpenAI API (Direct OpenAI Alternative)

- **Simplicity:** Codex CLI talks to the OpenAI API with one key and no extra service, which is the fewest moving parts.
- **Model reach:** Direct use limits you to OpenAI models, while OmniRoute reaches other providers through the same config file.
- **Trade-off:** A direct key has no fallback when it hits a limit, whereas OmniRoute can route elsewhere, at the cost of one more container and roughly 8 GB of heap for coding agents on /v1/responses.

## How to use OmniRoute Codex CLI (the OSS AI gateway)?

1. Open https://your-domain/dashboard and log in with your INITIAL_PASSWORD.
2. Connect at least one provider account. Free tiers work well here.
3. Create an API key and copy it now, since you won't see it again.
4. If you'll run coding agents, set OMNIROUTE_MEMORY_MB to 8192 and give the service about 10 GB of memory. The 1024 default is too small for /v1/responses traffic.
5. Export the key in your shell:

```bash
export OMNIROUTE_API_KEY=your-key
```

6. Add this to ~/.codex/config.toml:

```toml
model = "auto"
model_provider = "omniroute"

[model_providers.omniroute]
name = "OmniRoute"
base_url = "https://your-domain/v1"
env_key = "OMNIROUTE_API_KEY"
wire_api = "responses"
```

7. Run codex in a project folder and send a short prompt to confirm the gateway answers.
8. Check the request in the OmniRoute dashboard to see which provider served it.

## How to self host OmniRoute Codex CLI on other VPS Services (OmniRoute self hosting guide)

Running OmniRoute on your own VPS gives you the same gateway the template deploys, with you handling the server.

### Clone the Repository

Clone the OmniRoute source and move into the project folder.

```bash
git clone https://github.com/diegosouzapw/OmniRoute.git
cd OmniRoute
```

### Install Dependencies

Install the packages the project needs.

```bash
npm install
```

### Configure Environment Variables

Create a `.env` file with the public base URL and the key requirement.

```bash
PORT=20128
DATA_DIR=/app/data
BASE_URL=https://your-domain
REQUIRE_API_KEY=true
OMNIROUTE_MEMORY_MB=8192
```

Use 8192 for OMNIROUTE_MEMORY_MB if you run Codex CLI, because coding agents on /v1/responses need more heap than the 1024 default.

### Start the OmniRoute Codex CLI Application

Start the gateway, then confirm https://your-domain/healthz responds before you send traffic.

```bash
npm run start
```

Put a TLS reverse proxy in front of port 20128 so Codex CLI can reach https://your-domain/v1. Railway handles TLS, the public domain, and persistent storage for you.

## Official Pricing of OmniRoute Codex CLI (OmniRoute pricing)

OmniRoute is free and open source under the MIT license, so there is no subscription or per-request fee for the gateway itself.

## OmniRoute Codex CLI cloud vs self hosted comparison (Pricing, features, costs, and more)

Self hosting OmniRoute means you own the gateway, the data and the bill.

### Monthly cost of self hosting OmniRoute Codex CLI on Railway

On Railway, a light setup at 1 to 2 GB of memory runs about $5 to $15 per month. Railway's $5 trial lets you test it first.

### System Requirements for Hosting OmniRoute Codex CLI on a VPS

Match your RAM to your memory setting, since the default 1024 MB only covers the dashboard and light chat. Keep port 20128 behind HTTPS and set REQUIRE_API_KEY=true.

## Frequently Asked Questions (FAQs)

### Does Codex CLI need the Responses API?

Codex CLI uses the Responses API, so set wire_api = "responses" in your OmniRoute provider table.

### Why does the gateway restart when I run Codex?

Coding agents that hit /v1/responses need about 8192 MB of heap, and the default OMNIROUTE_MEMORY_MB=1024 is too small for that.

### Can I keep my ChatGPT login for some projects?

Yes.

### Why does my project config ignore my provider?

Project-scoped .codex/config.toml files cannot set openai_base_url, model_provider, model_providers or profiles, so Codex skips those keys and prints a warning.

### Which models work through OmniRoute?

Any model your connected providers serve works, and you can use model "auto" to let OmniRoute pick one.

### How do I switch back to OpenAI?

Run codex without the OmniRoute profile or remove the model_provider line from ~/.codex/config.toml. Codex then goes straight to the built-in openai provider again.


## 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-codex-cli
