---
title: "Deploy 9Router"
description: "9router AI router Pro Stack: API keys, backups and persistent SQLite."
category: "AI/ML"
url: https://railway.com/deploy/9router-7
---

# Deploy 9Router

9router AI router Pro Stack: API keys, backups and persistent SQLite.

**[Deploy 9Router on Railway](https://railway.com/template/9router-7)**

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

- **Creator:** Xav's Projects
- **Category:** AI/ML
- **Total deploys:** 1

## Template content

### 9Router https://raw.githubusercontent.com/decolua/9router/87a74e1bda3677193c6f71a7e2100c90311f0689/public/favicon.svg

- **Image:** decolua/9router@sha256:5fc7020f3cf1ca6831bffe80314ecab9dde915d27ee3c479a4bb66f45dabbc27
- **Health check:** /api/health
- **Public domain:** Yes

## Documentation

# Deploy and Host 9Router on Railway

## About Hosting 9Router

9Router (also searched as **9 Router**) is a self-hosted AI gateway for connecting OpenAI-compatible clients, Claude Code, Codex, Cursor and other tools to supported model providers. This Pro Stack deploys the official 9Router application with a persistent SQLite database, generated administrator password, secure session cookies, and Railway volume backups.

## Why Deploy 9Router on Railway?

- **No mandatory provider API key at deployment.** Open the dashboard first, then connect an authorized provider from its Providers page.
- **Protected dashboard from the first launch.** `INITIAL_PASSWORD`, `JWT_SECRET`, `API_KEY_SECRET` and `MACHINE_ID_SALT` are generated separately for every deployment. There is no shared default password.
- **Authenticated inference API.** Create an endpoint key in the dashboard before using `/v1` from an external client. Dashboard login and inference API keys serve different purposes.
- **Persistent configuration and SQLite data** on a Railway volume mounted at `/app/data`, including provider connections, endpoint keys and routing combinations.
- **Reproducible application image.** The template pins the official 9Router **0.5.104** image by immutable digest, rather than silently following `latest`.
- **Daily and weekly volume backup schedules**, configured in the template. Railway's backup retention and storage billing apply; confirm your schedule in the deployed volume's Backups tab.
- **Native readiness endpoint and restart policy.** Railway checks `/api/health` before routing traffic. The application starts through its official image entrypoint and custom server.
- **Request-content logging and observability recording disabled by default.** Enable the corresponding controls deliberately if you need to retain request contents.
- **One application service.** No separate Redis or PostgreSQL service is required by this SQLite-based deployment.

## Common Use Cases

- Connect your coding clients to one authenticated, self-hosted inference endpoint.
- Manage authorized model providers and routing combinations from a private dashboard.
- Keep provider connections, endpoint API keys and configuration on persistent storage.
- Test compatible provider integrations and streamed responses without maintaining a VPS.

## First use

1. Deploy the template and wait for the 9Router service to become healthy.
2. Open the generated HTTPS domain.
3. In Railway, open the service's Variables tab and copy `INITIAL_PASSWORD`. Use it on the 9Router login screen.
4. Open **Providers** and connect your chosen provider with your own authorized credentials.
5. Create an endpoint API key in 9Router. Copy the model ID shown in the dashboard.
6. Set your client's base URL to `https://YOUR-DOMAIN/v1`, use the endpoint key you just created, and select that model ID.

No model, provider account, subscription or inference credits are bundled. Successful application deployment does not mean an external provider is configured.

## Configuration

| Variable | Purpose |
| --- | --- |
| `INITIAL_PASSWORD` | Generated login password for a fresh installation. Once you set a password inside 9Router, its persisted password takes precedence. |
| `JWT_SECRET` | Generated secret signing dashboard sessions. Keep stable across redeployments. |
| `API_KEY_SECRET` / `MACHINE_ID_SALT` | Per-deployment application secrets. Keep stable with the volume. |
| `DATA_DIR` | `/app/data`; must match the persistent volume mount. |
| `PORT` / `HOSTNAME` | `20128` / `0.0.0.0`, matching Railway's HTTP proxy. |
| `BASE_URL` / `NEXT_PUBLIC_BASE_URL` | Generated HTTPS domain. Update both when attaching a custom domain. |
| `AUTH_COOKIE_SECURE` | `true`; dashboard cookies are sent over HTTPS. |
| `ENABLE_REQUEST_LOGS` / `OBSERVABILITY_ENABLED` | `false` by default. Application settings may also control observability. |

## Persistence, backups and upgrades

The official application stores its database under `/app/data/db/data.sqlite` and other durable state under `DATA_DIR`. Keep the volume attached when restarting or redeploying. Deleting the volume deletes that data.

Daily and weekly volume backups provide recovery points. The authenticated database export in the 9Router settings provides a separate portable configuration export; exports may include provider credentials and must be stored privately. Backups do not make two replicas of the same SQLite volume safe: use one replica.

The image is pinned to the tested digest. For upgrades, back up the volume, replace the image with a tested official release, redeploy and verify login, providers, endpoint keys and routing. Do not use the application's package updater to replace the running immutable Docker image. Review release notes before upgrading.

## Frequently asked questions

### Can I deploy 9Router without an OpenAI API key?

Yes. The application and private dashboard launch without a model-provider key. Connect a supported provider after deployment. The generated administrator password is already supplied by Railway.

### Is 9Router limited to OpenAI?

No. Upstream supports multiple providers and OpenAI-compatible or Anthropic-compatible endpoints. Availability, authentication, model names and provider terms depend on the provider. A third-party client integration does not confer access to that client's subscriptions or models.

### How is this different from a basic 9Router template?

This deployment explicitly supplies fresh secrets, secure cookies, correct persistent storage, scheduled volume backups, a pinned official image, native startup, and an authenticated API setup. These are concrete deployment choices, not a guarantee that every provider or future release will work.

### Are model routing and streaming supported?

Yes. 9Router supplies an OpenAI-compatible API and routing combinations. Use endpoint API keys and the model IDs from your dashboard. Provider support varies by API feature. Configure fallback models that you are authorized to use.

### Will my providers and API keys survive a Railway restart?

They are stored on the attached `/app/data` volume. Keep that volume and the generated application secrets. Backup recovery and image upgrades should be tested before relying on the service for critical workloads.

### Is this guaranteed to deploy successfully or rank first?

No universal guarantee is possible. Deployment depends on Railway capacity, plan limits, registry availability and user configuration. Search positions also change. The template uses explicit defaults and a tested, immutable image to reduce avoidable failures.

## Dependencies for 9Router Hosting

A Railway account with sufficient service and volume capacity. Provider credentials are optional for deployment and necessary when using a provider that requires authentication. One application replica uses the attached SQLite volume.

### Deployment Dependencies

- [Official 9Router source and license](https://github.com/decolua/9router)
- [Official Docker deployment guide](https://github.com/decolua/9router/blob/87a74e1bda3677193c6f71a7e2100c90311f0689/DOCKER.md)
- [Railway volume backups](https://docs.railway.com/volumes/backups)

Community-maintained Railway deployment configuration. Not an official endorsement by 9Router or any model provider.


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