
Deploy 9Router Claude Code
Route Claude Code through 40+ providers with fallback
9router
Just deployed
/app/data
Deploy and Host self hosted 9Router Claude Code (Open-Source AI Router) on Railway
Point Claude Code at this Railway template and you get the same 9Router stack for coding sessions: OpenAI-compatible /v1, 3-tier fallback across your provider accounts, and RTK compression on tool_result content. Image decolua/9router:0.5.95 is digest-pinned, /app/data is mounted, and secrets are generated at deploy.
About Hosting 9Router Claude Code open-source software on Railway (self hosted 9Router template)
One service runs decolua/9router:0.5.95 pinned by digest, port 20128, health /api/health, volume /app/data. Dashboard at /dashboard, API at /v1. State is SQLite at $DATA_DIR/db/data.sqlite with auto backups under $DATA_DIR/db/backups/. No Postgres or Redis. Generated secrets: INITIAL_PASSWORD (replaces upstream default 123456), JWT_SECRET, API_KEY_SECRET, MACHINE_ID_SALT. Fixed vars: PORT=20128, HOSTNAME=0.0.0.0, DATA_DIR=/app/data, BASE_URL and NEXT_PUBLIC_BASE_URL from the public domain, CLOUD_URL for optional 9router.com sync, AUTH_COOKIE_SECURE=true, ENABLE_REQUEST_LOGS off by default, REQUIRE_API_KEY=true. Optional empty HEADROOM_URL and SEARXNG_URL.
Why Deploy 9Router Claude Code, the OpenRouter alternative on Railway (Railway Free Trial)
OpenRouter is hosted SaaS with credit fees and no self-host path. This template keeps Claude Code traffic on your volume and your own provider keys. Combos fall back subscription -> cheap -> free when quota resets. Railway's $5 trial is enough to deploy, read INITIAL_PASSWORD, and point Claude Code at /v1 before monthly compute.
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 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 9Router Claude Code self hosting
| Provider | What you manage | Persistent storage | Claude Code friction |
|---|---|---|---|
| DigitalOcean | Droplet, Docker, TLS, reverse proxy | Block volume you attach | Manual HTTPS before IDEs trust the base URL |
| AWS | ECS/EC2, IAM, LB, EBS | EBS or EFS | Many moving parts for one router |
| Hetzner | Cheap VPS, Docker, firewall, backups | Local disk or volume | You own DNS, TLS, and restart policy |
Railway collapses digest pin, volume, HTTPS, health checks, and secret generation into one service. For a single Claude Code operator that usually beats babysitting a VPS.
Common Use Cases for hosted 9Router Claude Code
Point Claude Code at https://YOUR-DOMAIN/v1 with a dashboard API key so format translation (OpenAI to Claude and back) and combos sit under the CLI you already use. Build a combo that tries subscription accounts first, then cheap API keys, then free tiers you are eligible for. Round-robin multiple logins per provider when one account hits rate limits. Turn on RTK so large tool_result blobs shrink before the model sees them; upstream claims about 20-40% token savings on tool-heavy turns. Track usage in the dashboard (cost numbers are tracking only).
Dependencies for 9Router Claude Code Docker hosted on Railway
Hard dependencies are the pinned image, a writable /app/data volume, outbound HTTPS to providers, and at least one provider account or API key you add after login. No external database, cache, or queue. Railway supplies the public domain and TLS. Secrets are generated before start. Post-deploy: log into /dashboard and create a router API key for Claude Code.
Deployment Dependencies for Managed 9Router Claude Code Service (AI Router)
- decolua/9router:0.5.95 pinned by digest
- Port 20128 with health /api/health
- Volume mounted at /app/data
- Generated INITIAL_PASSWORD, JWT_SECRET, API_KEY_SECRET, MACHINE_ID_SALT
- BASE_URL / NEXT_PUBLIC_BASE_URL set to the Railway public domain
- REQUIRE_API_KEY=true so internet-exposed /v1 needs a Bearer key
Implementation Details for 9Router Claude Code (Using 9Router official docker image)
Next.js listens on HOSTNAME=0.0.0.0 and PORT=20128. First boot creates SQLite tables for providers, combos, aliases, API keys, settings, and usage history. Dashboard cookies use JWT_SECRET; generated API keys are HMAC-signed with API_KEY_SECRET. Claude Code should send the router key, not a raw provider key, because /v1/* enforces REQUIRE_API_KEY. ENABLE_REQUEST_LOGS stays off unless you want request bodies on disk. HEADROOM_URL can point at an external /v1/compress service; SEARXNG_URL adds SearXNG when needed.
How does 9Router Claude Code compare against other AI gateway platforms
9Router Claude Code vs LiteLLM
- Stack: 9Router is Node/Next.js with SQLite. LiteLLM is a Python proxy that often adds Postgres for keys and budgets.
- Coding tools: 9Router ships format translation and RTK aimed at Claude Code and similar CLIs. LiteLLM is stronger for team budgets.
- License: Both MIT core; LiteLLM has paid enterprise features, 9Router has no paid tier.
9Router Claude Code vs OpenRouter
- Hosting: Self-hosted on Railway vs hosted SaaS only.
- Billing: You pay providers plus Railway. OpenRouter adds credit fees.
- Data: Usage history stays on your volume. OpenRouter stores traffic on their side.
9Router Claude Code vs Portkey
- Architecture: Portkey pairs an open-source gateway with a hosted control plane. 9Router is one SQLite-backed container.
- Focus: Portkey leans observability and guardrails. 9Router leans coding-tool routing and RTK.
- Cost: Both free cores; Portkey sells hosted features, 9Router has none.
9Router Claude Code vs OmniRoute
- Scope: Both MIT self-hosted routers on port 20128 with SQLite and RTK. OmniRoute adds a larger catalog, MCP, A2A, and more routing strategies.
- Weight: 9Router is lighter for a single Claude Code user. OmniRoute wants more RAM under heavy /v1/responses load.
- Fit: Pick 9Router for a small Claude Code proxy. Pick OmniRoute when you need MCP control of the gateway.
How to use 9Router Claude Code (the OSS AI router)?
Deploy and wait for /api/health. Open /dashboard, log in with INITIAL_PASSWORD, and change it. Connect providers, build a combo if you want fallback, then create an API key. Point Claude Code at the public /v1 URL with that key (README path: anthropic_api_base / equivalent base URL settings). Restart Claude Code and send a tool-heavy prompt to confirm RTK and fallback. Respect provider terms: routing some subscription accounts through a third-party router can violate ToS; pay-as-you-go keys are the safer default.
How to self host 9Router Claude Code on other VPS Services (9Router Claude Code self hosting guide)
Clone the Repository
git clone https://github.com/decolua/9router.git or skip source and pull decolua/9router:0.5.95. The Railway template already pins that image by digest.
Install Dependencies
Docker is enough.
Configure Environment Variables
Set PORT=20128, HOSTNAME=0.0.0.0, DATA_DIR=/app/data, BASE_URL and NEXT_PUBLIC_BASE_URL to your HTTPS domain, AUTH_COOKIE_SECURE=true, REQUIRE_API_KEY=true, plus strong INITIAL_PASSWORD, JWT_SECRET, API_KEY_SECRET, and MACHINE_ID_SALT.
Start the 9Router Claude Code Application
docker run or Compose with /app/data mounted and 20128 published. Put TLS in front. Open /dashboard, add providers, create a key, point Claude Code at /v1.
Official Pricing of 9Router Claude Code (9Router Claude Code pricing)
9Router is MIT and free. There is no paid 9Router plan. You pay Railway compute and whatever your providers charge.
9Router Claude Code cloud vs self hosted comparison (Pricing, features, costs, and more)
There is no separate managed 9Router cloud product required for Claude Code. Optional CLOUD_URL sync is settings backup; the router still runs where you host it. Railway is managed self-hosting with HTTPS and volumes.
Monthly cost of self hosting 9Router Claude Code on Railway
About $3-8/mo for a single-user router at roughly 512 MB RAM, plus a little volume storage. Railway's $5 trial covers early testing. Provider spend is separate and depends on how hard Claude Code hits the models.
System Requirements for Hosting 9Router Claude Code on a VPS
Minimum guidance: 1 vCPU, 512 MB RAM, a few GB disk, Docker. No GPU. Place the box near you and your main providers to keep Claude Code latency low.
Frequently Asked Questions (FAQs)
How do I point Claude Code at this router on Railway?
After deploy, create a key in /dashboard. Set Claude Code's Anthropic/base URL settings to https://YOUR-DOMAIN/v1 and use the router API key. Restart Claude Code so it picks up the new base URL.
Where does the Claude Code API key come from?
From 9Router's dashboard, not from Anthropic directly. REQUIRE_API_KEY is on because /v1 is internet-exposed. Provider keys stay inside the router.
Does RTK help Claude Code specifically?
Yes. Claude Code sends large tool_result payloads. RTK compresses that content before the model call. Upstream claims roughly 20-40% savings on eligible turns; treat it as a project claim, not a guarantee.
Can routing subscription accounts break provider terms?
It can. Some providers restrict using subscription logins through third-party proxies or shared automation. Read each provider's terms. API keys you own are usually the cleaner path.
Will Cursor or Codex work on the same deploy?
Yes. Point any OpenAI-compatible client at the same /v1 with the same router key. Combos and RTK apply across tools.
Is 9Router free?
The software is MIT and has no paid plan. You still pay Railway and your model providers. Keep the volume attached; it holds all state.
Template Content
9router
decolua/9router:0.5.95