Deploy 9Router

Route coding tools to 40+ AI providers with auto fallback

Deploy 9Router

Just deployed

/app/data

Deploy and Host self hosted 9Router (Open-Source AI Router) on Railway

9Router is a self-hosted AI gateway that routes Claude Code, Cursor, Cline, and other coding tools to 40+ providers through one OpenAI-compatible API. This Railway template pins decolua/9router:0.5.95 by digest, mounts /app/data, and generates all secrets at deploy.

About Hosting 9Router open-source software on Railway (self hosted 9Router template)

The template runs one service with pinned digest decolua/9router:0.5.95, port 20128, health check /api/health, and volume /app/data. Dashboard is at /dashboard, API at /v1. It uses SQLite at $DATA_DIR/db/data.sqlite with auto backups in $DATA_DIR/db/backups/. No Postgres or Redis. Because the digest is pinned, a redeploy or restart pulls the exact same build, and updating is a deliberate tag change.

Why Deploy 9Router, the OpenRouter alternative on Railway (Railway Free Trial)

9Router is free and MIT-licensed. OpenRouter is SaaS, charges credit fees, and can't be self-hosted. 9Router brings your own provider accounts, mixes subscription, cheap, and free tiers with auto fallback, and keeps usage history on your volume. Railway gives a $5 trial; single-user 9Router usually costs $3-8/mo after.

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 full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.

Railway vs Other Hosting Providers and VPS for 9Router self hosting

Provider9Router hosting fitPersistent storageDeploy-time config
DigitalOceanWorks on Droplet/App Platform, but you manage Docker, volumes, TLS.Manual block storage.Set env vars, pin digest.
AWSECS/EC2 works, but IAM, load balancer, EFS add overhead.EFS or EBS required.More moving parts.
HetznerCheap VPS with Docker is fine, but you handle proxy, backups.Local disk or volume.Manual setup, secrets.

Railway collapses Docker run, volume mount, HTTPS, health check, and secret generation into one click.

Common Use Cases for hosted 9Router

  • Connect Claude Code, Codex, Cursor, Cline, GitHub Copilot, OpenCode, OpenClaw to 40+ providers via /v1.
  • Translate OpenAI <-> Claude formats.
  • Create combos that fall back across subscription, cheap, and free tiers.
  • Rotate multiple provider accounts with round robin.
  • Track usage per key and model; dashboard cost is tracking only.
  • Enable RTK token saver to compress tool_result content, claimed 20-40% savings.
  • Optionally sync settings to 9router.com cloud.

Dependencies for 9Router Docker hosted on Railway

9Router is a single Node/Next.js process. Hard dependencies are the pinned image, a writable /app/data volume, and outbound HTTPS to providers. No external database, cache, or queue. Railway supplies domain and TLS. The template generates secrets before start, so nothing is pasted. The only post-deploy step is reading INITIAL_PASSWORD and logging into /dashboard.

Deployment Dependencies for Managed 9Router Service (AI Router)

  • decolua/9router:0.5.95 pinned by digest.
  • Port 20128 exposed via Railway HTTPS.
  • Persistent volume at /app/data.
  • Health check /api/health returning 200.
  • Environment variables listed above, all secrets generated.
  • Public Railway domain for BASE_URL and NEXT_PUBLIC_BASE_URL.

Implementation Details for 9Router (Using 9Router official docker image)

The image starts Next.js with HOSTNAME=0.0.0.0 and PORT=20128. SQLite initializes at $DATA_DIR/db/data.sqlite. Dashboard auth uses JWT_SECRET; generated API keys are HMAC-signed with API_KEY_SECRET. /v1/* enforces REQUIRE_API_KEY=true, so tools send a Bearer key. ENABLE_REQUEST_LOGS is off. HEADROOM_URL enables external /v1/compress; SEARXNG_URL adds web search.

How does 9Router compare against other AI gateway platforms

9Router vs LiteLLM

  • Stack: 9Router is Node/Next.js; LiteLLM is Python.
  • State: 9Router uses SQLite with backups, no Redis/Postgres. LiteLLM often adds them.
  • Secrets: 9Router generates all auth secrets at deploy. LiteLLM needs master key and DB URL.
  • Focus: 9Router targets coding tools and RTK compression. LiteLLM targets teams, budgets.
  • License: Both MIT core; LiteLLM has paid enterprise features, 9Router has no paid tier.

9Router vs OpenRouter

  • Hosting: 9Router self-hosted on Railway. OpenRouter is hosted SaaS, not self-hostable.
  • Cost: 9Router free software; you pay providers. OpenRouter adds credit fees.
  • Data: 9Router keeps usage on your volume. OpenRouter stores it on their servers.
  • Fallback: 9Router combos pool your own accounts. OpenRouter fallback differs.
  • Control: 9Router lets you disable logs, enforce keys, pin digest. OpenRouter gives no infra control.

9Router vs Portkey

  • Architecture: Both gateways run as one service. Portkey pairs its open-source gateway with a hosted control plane for logs and guardrails.
  • Coding focus: 9Router includes format translation and RTK token saver. Portkey is general.
  • Cost: Both free cores; Portkey sells hosted observability, 9Router has no paid tier.

9Router vs OmniRoute

  • Scope: Both are open-source, self-hostable routers for coding tools with combos and fallback across many providers.
  • Footprint: Both run as one Next.js container with SQLite on a volume and port 20128 by default.
  • Pick by: Feature set and release cadence. Try both; config does not move between them.
  • Template: This one pins 9Router 0.5.95 by digest and generates every secret, so there is nothing to paste.

How to use 9Router (the OSS AI router)?

Open your Railway domain, go to /dashboard, log in with INITIAL_PASSWORD. The first login needs no other setup; secrets are already generated. Add a provider API key. Create a combo for fallback if desired. Create an API key and point your tool at https://your-service.up.railway.app/v1 with Bearer key.

How to self host 9Router on other VPS Services (9Router self hosting guide)

Clone the Repository

Run git clone https://github.com/decolua/9router.git for a source build, or skip it and use npm install -g 9router or the Docker image. Building from source needs about 2 GB memory; the README adds temporary swap on small VPS boxes.

Install Dependencies

Install Node.js and run npm install from the project root. With Docker, skip this because dependencies are baked into decolua/9router:0.5.95.

Configure Environment Variables

Set PORT=20128, HOSTNAME=0.0.0.0, DATA_DIR=/app/data or local path, BASE_URL and NEXT_PUBLIC_BASE_URL to your domain, CLOUD_URL to https://9router.com, AUTH_COOKIE_SECURE=true, REQUIRE_API_KEY=true. Generate INITIAL_PASSWORD, JWT_SECRET, API_KEY_SECRET, MACHINE_ID_SALT. Leave HEADROOM_URL and SEARXNG_URL empty.

Start the 9Router Application

Run npm run build then npm run start, or docker run -p 20128:20128 -v ~/.9router:/app/data -e DATA_DIR=/app/data decolua/9router:0.5.95. Dashboard listens on port 20128. Put Caddy or Nginx in front for TLS. Mount persistent disk at DATA_DIR so SQLite and backups survive. Log into /dashboard with INITIAL_PASSWORD.

Official Pricing of 9Router (9Router pricing)

9Router is MIT-licensed and free. No paid plan, per-seat fee, or token markup. You pay providers directly. Dashboard cost estimates are tracking only. Railway hosting costs $3-8/mo for one user after trial.

9Router cloud vs self hosted comparison (Pricing, features, costs, and more)

Self-hosted 9Router on Railway gives all features: combos, round robin, format translation, RTK token saver, usage analytics, auto backups. Cloud sync only copies settings to 9router.com; it does not run the router. Pricing is identical: zero software cost. Self-hosted keeps state on your volume and lets you enforce REQUIRE_API_KEY and disable logs.

Monthly cost of self hosting 9Router on Railway

A single-user service with 512 MB RAM and small volume costs about $3-8/mo after trial. One Node process with SQLite needs little CPU. For many concurrent sessions, bump RAM to 1 GB and expect the higher end. Railway bills only resources, not API tokens. Provider costs are separate.

System Requirements for Hosting 9Router on a VPS

  • 512 MB RAM for one user; source build may need 2 GB, so use Docker image.
  • 1 vCPU is enough; router does not run inference.
  • A few GB of disk covers SQLite, backups, and usage history.
  • Node.js for source builds, or Docker for the image.
  • Outbound HTTPS to provider APIs and optionally 9router.com.
  • Reverse proxy with TLS for non-Railway VPS.

Frequently Asked Questions (FAQs)

Does 9Router work with Claude Code and Cursor?

Yes. Create an API key in the dashboard, then set your Railway URL plus /v1 as the endpoint in each tool. The dashboard shows per-tool setup for Claude Code, Codex, Cursor, and Cline.

Is 9Router really free?

Yes. MIT-licensed, no paid plan. You pay providers directly. Railway hosting costs a few dollars per month.

Does 9Router store my prompts?

No. ENABLE_REQUEST_LOGS is off by default, so prompt contents are not stored. Usage metadata like token counts is kept.

Can I use multiple OpenAI or Anthropic accounts?

Yes. Add multiple provider accounts and create a combo with round robin to stay under per-account rate limits.

What happens if a provider fails?

With a combo, 9Router automatically tries the next provider. You can mix subscription, cheap, and free tiers.

Does routing subscription accounts violate provider terms?

It may. Some providers prohibit third-party routing of consumer subscriptions. Check each provider's ToS. Pay-as-you-go API keys are generally fine.


Template Content

More templates in this category

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

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

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

codestorm
86