---
title: "Deploy 9Router AI Gateway [Sep'26]"
description: "Self-hosted AI gateway for Claude Code, Cursor & 40+ LLM providers"
category: "AI/ML"
url: https://railway.com/deploy/9router-ai-gateway-aug26
---

# Deploy 9Router AI Gateway [Sep'26]

Self-hosted AI gateway for Claude Code, Cursor & 40+ LLM providers

**[Deploy 9Router AI Gateway [Sep'26] on Railway](https://railway.com/template/9router-ai-gateway-aug26)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/9router-ai-gateway-aug26/manifest.json

- **Creator:** Tasha
- **Category:** AI/ML
- **Total deploys:** 2

## Template content

### decolua/9router:0.5.55 https://raw.githubusercontent.com/decolua/9router/master/public/favicon.svg

- **Image:** decolua/9router:0.5.55
- **Health check:** /api/health
- **Public domain:** Yes

## Documentation

# Deploy and Host 9Router on Railway

9Router is an open-source, self-hosted AI gateway and LLM router. It puts a single OpenAI-compatible endpoint in front of 40+ AI providers — including OpenAI, Anthropic, Google Gemini, Mistral, Groq, DeepSeek, and OpenRouter — and 100+ models, so Claude Code, Cursor, Cline, Codex, Copilot, Windsurf, and Gemini CLI all authenticate against your own gateway instead of scattering provider API keys across every tool you use.

## About Hosting 9Router

Hosting 9Router means running one Node.js service with a persistent disk. There is no PostgreSQL, Redis, or external database to operate: providers, issued API keys, fallback chains, usage history, and settings all live in an embedded SQLite database under `/app/data`, alongside automatic backups. This template deploys the official `decolua/9router` image pinned to a known-good version, attaches the volume, serves the dashboard and the `/v1` API on an HTTPS domain, and generates the session and API-key signing secrets fresh for your deployment. You pick a dashboard password before deploying; everything else is pre-configured.

## Common Use Cases

- Give a team one OpenAI-compatible gateway URL for every AI coding tool, so provider keys for OpenAI, Anthropic, and Gemini live in one place instead of on each developer's laptop
- Ride out per-provider rate limits and quota exhaustion with automatic fallback chains, without editing any client configuration
- Track AI spend across providers: which model answered which request, and what it cost
- Run a private AI proxy for internal apps, autonomous agents, and any OpenAI-compatible SDK client

## Dependencies for 9Router Hosting

- A Railway volume mounted at `/app/data` for the SQLite database and its backups
- Accounts or API keys with the upstream AI providers you want to route to (OpenAI, Anthropic, Gemini, or any of the 40+ others 9Router supports); 9Router meters those calls but does not resell tokens
- A dashboard password, supplied as `INITIAL_PASSWORD` at deploy time

### Implementation Details

The image listens on port `20128`, so `PORT` is pinned to `20128` rather than a more common default, and the HTTP proxy is bound to that same port. Deploys are gated on `GET /api/health`, which returns `{"ok": true}` without authentication — verified against a live deployment of this template.

Security-relevant settings are hardened rather than left at their upstream defaults:

- `REQUIRE_API_KEY` is `true`, so `/v1/*` rejects unauthenticated calls with a `401`. Issue a key from the dashboard before pointing a client at the gateway. Left at its default, a public gateway is an open proxy to your provider credits.
- `AUTH_COOKIE_SECURE` is `true`, because Railway terminates TLS in front of the service.
- `JWT_SECRET`, `API_KEY_SECRET`, and `MACHINE_ID_SALT` are generated per deployment instead of falling back to shared upstream defaults.
- `INITIAL_PASSWORD` is required at deploy time. The upstream default is `123456`, which is not something to ship on a public domain.

After deploying, open `https://<your-domain>/dashboard` and sign in with your `INITIAL_PASSWORD` — the login screen's "Default password is 123456" notice is static copy shown on every fresh install, not a sign that your password wasn't applied; it works as set. Add your providers, build a fallback chain, and issue an API key. Then point any OpenAI-compatible tool at `https://<your-domain>/v1`, or for Anthropic-style clients:

```bash
export ANTHROPIC_BASE_URL="https://<your-domain>"
export ANTHROPIC_AUTH_TOKEN="<key from the dashboard>"
```

The dashboard's CLI Tools section shows the exact per-tool configuration for Claude Code, Cursor, Codex, Gemini CLI, Windsurf, and others.

## Why Deploy 9Router on Railway?

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 9Router on Railway, you are one step closer to supporting a complete AI development workflow with minimal operational burden. Host your gateway, APIs, databases, agents, and everything else your stack needs in one place.


## 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/9router-ai-gateway-aug26
