---
title: "Deploy 9Router Zed"
description: "Point Zed editor AI at your own self-hosted router"
category: "AI/ML"
url: https://railway.com/deploy/deploy-9router-for-zed-editor
---

# Deploy 9Router Zed

Point Zed editor AI at your own self-hosted router

**[Deploy 9Router Zed on Railway](https://railway.com/template/deploy-9router-for-zed-editor)**

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

- **Creator:** onepush
- **Category:** AI/ML

## Template content

### 9router

- **Image:** decolua/9router:0.5.95@sha256:4316fefb95ea642d57db885d906b1227b1768b15ac5def314621fd781da7b3f1
- **Health check:** /api/health
- **Public domain:** Yes

## Documentation

# Deploy and Host self hosted 9Router Zed (Self-Hosted AI Router for Zed Editor) on Railway

Want one endpoint for every model instead of five provider keys? Zed's openai_compatible provider can use its router key directly. It suits solo developers and small teams who want their own router.

## About Hosting 9Router Zed open-source software on Railway (self hosted 9Router for the Zed editor template)

This template runs one decolua/9router service on port 20128, with a volume mounted at /app/data where the SQLite database lives at db/data.sqlite.

## Why Deploy 9Router Zed, the Zed hosted models alternative on Railway (Railway Free Trial)

Routing Zed through your own router keeps keys and traffic on infrastructure you control. The tradeoff is that you own uptime and upkeep, which Zed hosted models handles for you.

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 Zed 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 Zed self hosting

Here is how Railway compares with a plain VPS for a single router endpoint your Zed setup depends on.

| Provider | What You Get with Railway | What You Get with the Other Provider |
| --- | --- | --- |
| DigitalOcean | A managed domain, HTTPS, and a persistent volume for SQLite, with no nginx or certificates to manage. | Root access and a cheap droplet, but you own the proxy, TLS renewal, and volume backups. |
| AWS | One service with no VPC, security groups, or IAM setup just to run a single container. | Fine-grained control and many adjacent services, with a steeper setup for one small container. |
| Hetzner | Automatic domain and certificate handling, and a volume that survives redeploys. | Low raw capacity cost, but you maintain the OS, Docker, firewall, and backups yourself. |

For one developer pointing Zed at one router key, the managed route means much less upkeep.

## Common Use Cases for hosted 9Router Zed

- **One router key across several machines:** Put the same `api_url` and key in Zed on your laptop and desktop, so you manage one key in the dashboard instead of rotating keys per box.
- **Switching models without new keys:** Connect a model once in the 9Router dashboard, then pick it from the Zed agent panel. Adding a new model means a dashboard change, not another `settings.json` edit.
- **Sharing a team router:** Give a small group a single endpoint with separate API keys, so you can see who is calling what and revoke one person without touching the rest.
- **Routing Zed through subscription-backed providers:** If you already pay for a coding subscription, connect it to the router and point Zed at the router instead of wiring the subscription's own tooling into the editor.
- **A fallback when a provider rate-limits:** Set up a combo with a backup provider, so when your main model hits a limit, requests fall through to the next one and your agent session keeps moving.

## Dependencies for 9Router Zed Docker hosted on Railway

This template runs as one service, so there is no separate database or cache to wire up. Zed only needs the router base URL and a router API key, which you create inside the dashboard after the first login.

### Deployment Dependencies for Managed 9Router Zed Service (AI Router)

The template provisions a single decolua/9router:0.5.95 service that listens on port 20128 and reports health at /api/health.

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

State lives in SQLite at $DATA_DIR/db/data.sqlite, with DATA_DIR set to /app/data, and backups land in $DATA_DIR/db/backups/.

## How does 9Router Zed compare against other ways to give Zed editor AI models

### 9Router Zed vs Zed hosted models (Zed hosted models Alternative)

- **Who holds the keys:** Zed hosted models bill you through Zed, while 9Router Zed keeps your provider keys on your own Railway service.
- **Setup effort:** Zed hosted models need only a sign-in, which is a real win if you don't want to run anything yourself.
- **Model range:** 9Router Zed fans one router key out to 40+ providers, so you can switch models in the agent panel without new keys.

### 9Router Zed vs OpenRouter (OpenRouter Alternative)

- **Hosting:** OpenRouter is a hosted gateway you don't run, while 9Router Zed is a container you deploy on your own domain.
- **Config:** Zed's OpenRouter provider uses OPENROUTER_API_KEY, whereas 9Router Zed uses an openai_compatible block pointed at your own /v1 URL.
- **Where OpenRouter wins:** OpenRouter needs no server, no volume, and no dashboard password to manage.

### 9Router Zed vs LiteLLM (LiteLLM Alternative)

- **Focus:** LiteLLM is a general open-source proxy, while 9Router Zed is built around subscription-backed accounts plus combo fallback.
- **State:** 9Router Zed keeps everything in one SQLite file on a volume, so there's no Postgres or Redis to run beside it.
- **Where LiteLLM wins:** LiteLLM is more mature for large teams, with broader admin and spend controls.

### 9Router Zed vs Ollama (Ollama Alternative)

- **Location:** Ollama runs models on your own machine, while 9Router Zed forwards requests to remote providers from a server you host.
- **Zed config:** Ollama is its own provider in Zed, so you don't use openai_compatible for it.
- **Where Ollama wins:** Ollama keeps prompts fully local and works offline, which 9Router Zed cannot do.

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

1. Log into the 9Router dashboard at `/dashboard` with INITIAL_PASSWORD.
2. Connect a provider, then create and copy an API key.
3. Open Zed's `settings.json` and add an `openai_compatible` provider under `language_models`, with `https://your-domain/v1` as `api_url` and your model IDs in `available_models`.
4. When Zed prompts for the key, paste the router key. Zed stores it in the system keychain, not in `settings.json`.
5. Pick the model from the 9Router provider in the agent panel.

```json
{
  "language_models": {
    "openai_compatible": {
      "9router": {
        "api_url": "https://your-domain/v1",
        "available_models": [
          {
            "name": "cc/claude-opus-4-7",
            "display_name": "Claude Opus via 9Router",
            "max_tokens": 200000
          }
        ]
      }
    }
  }
}
```

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

A plain VPS works fine if you want full control of the box. These steps assume Linux with Docker and a domain pointing at the host.

### Clone the Repository

Pull the source so you can read the compose file and keep your config beside it.

```bash
git clone https://github.com/decolua/9router.git
cd 9router
```

### Install Dependencies

You need Docker and a reverse proxy that terminates TLS in front of port 20128.

```bash
docker --version
docker pull decolua/9router:0.5.95
```

### Configure Environment Variables

Set the public domain and secrets before the first start. Keep AUTH_COOKIE_SECURE and REQUIRE_API_KEY on.

```bash
export BASE_URL=https://your-domain
export NEXT_PUBLIC_BASE_URL=https://your-domain
export DATA_DIR=/app/data
export REQUIRE_API_KEY=true
export INITIAL_PASSWORD=change-this-first-login
```

### Start the 9Router Zed Application

Mount a volume on /app/data so your SQLite database survives restarts. Then open https://your-domain/dashboard, log in, and create the API key Zed will use.

```bash
docker run -d -p 20128:20128 -v 9router-data:/app/data --env-file .env decolua/9router:0.5.95
```

Railway handles the TLS certificate, the volume, and restarts for you, which is most of what you give up on a VPS.

## Official Pricing of 9Router Zed (9Router pricing)

9Router Zed is free and open source under the MIT license, so there is no paid 9Router plan to buy. The router itself adds no per-token fee on top of those.

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

Running 9Router Zed yourself trades a small monthly bill for control over where your keys and traffic live.

### Monthly cost of self hosting 9Router Zed on Railway

On Railway, one 9Router service with a volume usually lands around $3 to $8 a month, depending on usage and the RAM it draws. The $5 Railway trial covers early testing.

### System Requirements for Hosting 9Router Zed on a VPS

About 512 MB of RAM is enough for a single user, and SQLite state lives on a persistent volume at /app/data.

## Frequently Asked Questions (FAQs)

### Where does Zed store the 9Router API key?

Keys entered in the Zed UI go to your system keychain, not settings.json.

### Why do my 9Router models not show up?

Usually the model ID in available_models does not match the ID connected in the 9Router dashboard, or Zed was not restarted after editing settings.json.

### Does edit prediction use the 9Router provider?

Not by default. The openai_compatible provider powers the agent panel and inline assistant, so edit prediction keeps its own setup unless you point it at this provider.

### Can I use Anthropic-compatible mode with Zed?

Zed's documented path here is the OpenAI-compatible block, with api_url set to https://your-domain/v1. Keep the Anthropic-style base URL for tools like Claude Code.

### What context window values should I use?

Set max_tokens to the model's real context window, since Zed requires it for custom models. Check the provider's documented limit before you set it.

### How much latency does the extra hop add?

The router adds one network hop, so expect a small overhead on top of the model's own response time. Deploying the Railway service in a region close to you keeps that overhead low.


## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [Weaviate](https://railway.com/deploy/weaviate-1) — Vector database with hybrid search and an API key-protected API
- [Möbius v0.1 Personal AI OS](https://railway.com/deploy/mobius-v01-personal-ai-os) — Self-hosted AI agent that builds and runs apps for you, with memory.

Open this page in a browser: https://railway.com/deploy/deploy-9router-for-zed-editor
