9Router is an AI gateway for coding tools. Instead of connecting Claude Code, Codex, Cursor, or Cline directly to a provider, you send their requests to a single address on your server. 9Router forwards them to the provider you choose: an existing subscription, a provider that uses an API key, or a free offering. If a provider goes down or you run out of quota, 9Router switches to the next model in your list. It also includes a dashboard with usage statistics and features that save tokens.
In this guide, we’ll show you two options: the easy way, as a One-Click App that’s ready to use with HTTPS and a password within minutes, and manual installation with Docker Compose. After that, you’ll connect providers and configure your coding tools.
9Router also runs on your own computer. Running it on a VPS makes sense if:
- You work on multiple computers. Your laptop, desktop, and build server can use the same address, provider accounts, and fallback rules.
- You want to keep accounts in one place. Store provider API keys and logins once in 9Router. Your devices only need their own 9Router key, which you can revoke at any time.
- You want to combine multiple providers. Start with a subscription, then use a lower-cost provider, and finally a free model—all without changing your tools’ settings.
- You want to keep track of usage. The dashboard shows requests, tokens, and quotas for each provider.
9Router is less useful if you only use one tool with one provider. In that case, routing requests through a server doesn’t offer much benefit. Also keep in mind: all requests—and therefore your code—pass through your server to the provider.
The quickest way to get started with 9Router is through your VPS’s One-Click Apps. The app is accessible over HTTPS using a domain, the dashboard is protected with a generated password from the moment it’s installed, and the API only accepts requests with a valid key.
- A Linux VPS (Debian or Ubuntu) with One-Click Apps set up. See Set Up One-Click Apps for instructions.
- At least 256 MB of free RAM and 1 GB of disk space; 1 GB of RAM and 5 GB of disk space are recommended. 9Router doesn’t run models itself; it only forwards requests.
- Open your VPS in the ZapX dashboard and go to the One-Click Apps tab.
- Search for 9Router in the app catalog and click Install app.
- Use a custom subdomain or zap.cloud is already selected. Leave this option enabled and enter a custom name if needed, for example,
ai-router. Your tools need a fixed address with HTTPS. - You don’t need to enter anything under App configuration. Click Queue installation.
The panel automatically generates four values: the dashboard password (SERVICE_PASSWORD_PASSWORD) and three internal keys for logins and API keys. After one or two minutes, the app card will show Online.
- Open the App environment tab using the gear icon on the app card. Your password appears under Automatically generated values as
SERVICE_PASSWORD_PASSWORD. Click the eye icon to show it, or the icon beside it to copy it. - Open 9Router using the Access link or by clicking Open login page in the Login notice on the app card.
- Enter the password under Password and click Login.
The 9Router login page always displays a notice about the default password 123456. It doesn’t work with the One-Click App; on our test VPS, 9Router rejected it. After five failed attempts, 9Router blocks logins from your IP address for 30 seconds. The block lasts longer if you continue to make failed attempts.
Until you’ve saved a custom password, the login page also displays “Security risk: no password set”. The generated password still protects the dashboard. To set a custom password:
- Open Settings in the left-hand menu.
- Under Security, enter your new password in New Password and Confirm New Password, then click Set Password.
After that, only the new password will work. The value shown under App environment will no longer be valid, so save your password in a password manager.
In Settings, there’s a Require login toggle. Under Endpoint & Key, there’s a Require API key toggle. Both are enabled. If you turn them off, anyone who knows your address can open the dashboard or send requests using your provider accounts, at your expense. You don’t need the Tunnel and Tailscale features under Endpoint & Key: the app is already accessible through its domain.
Update 9Router in the app settings (gear icon), under App update. Click Check for updates and install a new version with Apply update. If it says the app is up to date, there isn’t a newer version in the app catalog yet. The “New version available” notice and Update now button in the 9Router dashboard are for npm installations. Always use App update with the One-Click App.
Providers, keys, combos, and usage data are stored in a SQLite database on the app’s data volume and are preserved during updates. Back up the entire VPS from Backups in the dashboard. You can also download a copy of the database in 9Router under Settings by clicking Download Backup, and restore it when needed using Import Backup. This copy contains your provider credentials. Keep it as secure as you would a password.
The rest of this guide covers manual installation of 9Router with Docker Compose, for example, if you don’t use One-Click Apps on your server. We’ll use the same image as the One-Click App.
- A Linux VPS running Debian or Ubuntu, with SSH access. See First SSH Login.
- Docker and Docker Compose (Compose v2). See Install Docker.
- A domain or subdomain whose A record points to your VPS’s IP address (e.g.,
ai-router.example.com).
| Hardware | Minimum | Recommended |
|---|---|---|
| CPU | 1 vCPU core | 2 vCPU cores |
| RAM | 256 MB | 1 GB |
| Storage | 1 GB | 5 GB |
9Router listens on port 20128. In this guide, you’ll only access it through a reverse proxy. With ufw, only allow SSH and the ports for the reverse proxy:
ufw allow OpenSSH
ufw allow 80/tcp
ufw allow 443/tcp
ufw enable
Ports published by Docker with ports: are accessible from outside even if ufw blocks them. So, as shown below, bind 9Router only to 127.0.0.1. For more about firewalls, see Firewall Management on Linux.
Create a directory and write the secret values directly to the .env file:
mkdir -p /opt/9router && cd /opt/9router
echo "INITIAL_PASSWORD=$(openssl rand -base64 24)" > .env
echo "JWT_SECRET=$(openssl rand -hex 32)" >> .env
echo "API_KEY_SECRET=$(openssl rand -hex 32)" >> .env
echo "MACHINE_ID_SALT=$(openssl rand -hex 32)" >> .env
chmod 600 .env
Next, create the docker-compose.yml file (nano docker-compose.yml):
services:
9router:
image: decolua/9router:0.5.116
restart: unless-stopped
ports:
- "127.0.0.1:20128:20128"
volumes:
- ./data:/app/data
env_file: .env
environment:
DATA_DIR: /app/data
Here’s what the important lines do:
INITIAL_PASSWORD: The password for your first login. Always set this value; otherwise, the publicly known default password123456will be used.JWT_SECRET,API_KEY_SECRET,MACHINE_ID_SALT: Keys for login cookies and your API keys. Don’t change them later, or logins and keys will become invalid../data:/app/data: The databasedb/data.sqlitewith providers, keys, and settings is stored here.127.0.0.1:20128:20128: 9Router is only accessible from the server itself; from outside, it’s only accessible through the reverse proxy.
Start the container with docker compose up -d and check that it’s running with docker compose ps.
Create an SSH tunnel from your PC and open http://localhost:20128:
ssh -L 20128:127.0.0.1:20128 root@SERVER_IP
Log in using the value of INITIAL_PASSWORD. You can read it on the server with grep INITIAL_PASSWORD /opt/9router/.env. Then, as described above, set a custom password under Settings.
Your tools connect over HTTPS. For the basics, see Set Up a Reverse Proxy with nginx and Create an SSL Certificate (Let's Encrypt). Here’s a server block for nginx:
server {
listen 80;
server_name ai-router.example.com;
client_max_body_size 50M;
location / {
proxy_pass http://127.0.0.1:20128;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_buffering off;
proxy_read_timeout 600s;
}
}
Then get the certificate with certbot --nginx -d ai-router.example.com. client_max_body_size allows large requests, such as those with images or long context. proxy_buffering off immediately forwards streamed responses to your tool, while proxy_read_timeout allows long responses. 9Router detects HTTPS through X-Forwarded-Proto and sets the login cookie as secure.
All data is in the data directory. For a consistent backup, briefly stop the container:
cd /opt/9router
docker compose stop
tar czf 9router-$(date +%F).tar.gz data .env docker-compose.yml
docker compose start
Without .env, your API keys will be invalid after a restore. Don’t keep the archive only on the VPS.
Create a backup first, as described above. Then, update the version for the image in docker-compose.yml and restart:
docker compose pull
docker compose up -d
You can find the versions on the 9Router releases page. Don’t use the Update now button in the dashboard with the container.
Once setup is complete, choose where 9Router sends requests and connect your tools.
Under Providers, you’ll find four groups: OAuth Providers for subscriptions such as Claude Code, OpenAI Codex, or GitHub Copilot; Free Tier Providers for free offerings; API Key Providers such as Anthropic, DeepSeek, or OpenRouter; and Custom Providers. For providers that use a key, enter the API key from your provider account. For OAuth providers, sign in through your browser. Since 9Router isn’t running on your own computer, many providers will then ask for the address you’re redirected to. Copy it from your browser’s address bar and paste it in. Use Add OpenAI Compatible to connect your own endpoints, such as a custom model with Ollama.
Each model has an ID that includes an abbreviation for the provider, such as cc/… for a Claude Code subscription or oc/… for OpenCode Free. You can copy the IDs from the provider’s page. Under Combo & Vision Adapter, use Create Combo to group multiple models into a list that 9Router tries in order.
Open Endpoint & Key. Under API Endpoint at the top, you’ll find the address for your tools, for example, https://ai-router.example.com/v1. Below it, use Create Key to create a separate key for each device or tool. Without a valid key, the API responds with 401. Delete a key from the same list if it falls into the wrong hands.
Under CLI Tools, 9Router shows the right configuration for each tool. Since 9Router runs on a server, use Manual Config or Guide and copy the values to your computer. For Claude Code, the ~/.claude/settings.json file should look like this:
{
"env": {
"ANTHROPIC_BASE_URL": "https://ai-router.example.com/v1",
"ANTHROPIC_AUTH_TOKEN": "DEIN-9ROUTER-SCHLUESSEL"
}
}
For Codex, 9Router generates a section for ~/.codex/config.toml. For Cursor, Cline, and other tools with an OpenAI-compatible provider, use the address from API Endpoint as the base URL, your 9Router key as the key, and a model ID or combo name as the model.
- You’ll pay the providers: 9Router itself is free. The relevant provider charges your account for subscriptions and API usage. Dashboard costs are estimates.
- Free models vary: Free offerings change often. On our test VPS, a request to OpenCode Free went through, but the free models were temporarily unavailable.
- Check the terms of service: The provider determines whether you can use a subscription through a router.
With 9Router, you now connect your coding tools to many AI providers through a single address, including fallbacks and usage statistics. If you also want to use your own models without an external provider, the guide Set Up Ollama with Open WebUI on a Linux Server shows you how to host them yourself so you can then add them to 9Router as a custom endpoint.
If you have any other questions or need help, our support team is available every day! 🙂
