9Router on Railway
An OpenAI-compatible AI router and gateway with fallback and usage tracking, self-hosted on Railway.
9Router is an open-source AI router and gateway. It gives coding tools and apps one OpenAI-compatible endpoint, plus Anthropic- and Gemini-style routes, and forwards each request to the provider accounts and API keys you connect. It translates between API formats, can fall back to another provider or model when one fails, and tracks usage.
It is used by people who run several AI clients, such as Claude Code, Codex CLI, Cursor, Cline or Continue, and want one base URL and one key instead of configuring each provider in each tool. It can also front self-hosted models served through Ollama or any OpenAI-compatible server. A comparable hosted service is OpenRouter; the difference here is that the router and its stored provider credentials run on your own server.
9Router is released under the MIT licence.
What 9Router can do
- One OpenAI-compatible endpoint plus Anthropic- and Gemini-style routes
- Request format translation between OpenAI, Anthropic and Gemini styles
- Fallback chains (combos) across providers and models
- Usage and cost tracking in a dashboard
- Password-protected dashboard and API key checks on /v1
- Custom providers for Ollama or any OpenAI-compatible server
What people use it for
- One base URL and key for several coding assistants
- Automatic fallback when a provider rate-limits or fails
- A shared AI gateway for internal tools and agents
- Mixing hosted APIs with self-hosted models
- Tracking AI usage across tools in one place
Videos
Running 9Router on Railway
The Railway template deploys a single 9Router service, pinned to a specific upstream image version, with a volume for its SQLite database. A dashboard password and an API key are generated at deploy time, and the /v1 API rejects requests without a valid key. Other services in the same Railway project can call it over the private network. The template documents about 0.1 GB of RAM at idle and near-zero CPU, so cost is mostly the small always-on service and the volume; the AI provider usage is billed by those providers.
9Router templates on Railway
Tracklayer templates are listed first. Other 9Router templates follow, ordered by total deployments on Railway. How this works.
Deployment numbers as of 2026-11-20.
Questions about 9Router
Do I need my own provider accounts?
Yes. 9Router routes requests to the providers and API keys you add in its dashboard after deploy. It does not supply model access itself.
How do I log in and get the API key?
The dashboard password is in the INITIAL_PASSWORD variable and the API key is in NINEROUTER_API_KEY, both on the service's Variables tab. Change the password under Settings after the first login.
Is my data kept across redeploys?
Yes. Providers, keys, combos, settings and usage are stored in SQLite on a Railway volume. Treat the volume and its backups as secrets, because they hold provider credentials.
Can I run more than one replica?
No. The SQLite database lives on a single volume, so keep one replica.
How do I use it with Claude Code?
Set ANTHROPIC_BASE_URL to your service's public domain and ANTHROPIC_AUTH_TOKEN to the generated API key, as described in the template documentation.
Guides
Similar apps
Tracklayer maintains the templates marked as such; 9Router is a trademark of its owners and this site is not affiliated with them.