In this guide you'll set up OmniRoute, a small server that sits between your AI tools and the AI providers. Instead of configuring OpenAI, Anthropic, Google and the rest separately in every tool, you point every tool at one address and OmniRoute forwards each request to a provider you've connected, switching to another one if the first fails.
I run OmniRoute in Docker on my homelab. OpenCode, Continue and a handful of scripts all send their requests to it, and it decides where they go.
What you need
- A Linux machine with Docker installed. Any small server or VM works; OmniRoute doesn't run AI models itself, it only forwards requests. The README sizes the default container at 2 GB of RAM or more for the dashboard and light chat. Coding agents with long conversations need much more (see Troubleshooting).
- About 1 GB of disk for the image and its data.
- At least one AI provider account or API key. OpenAI, Anthropic, Google, Mistral, Groq and OpenRouter all work. If you have none, start with OpenRouter (see the tips at the end).
- A browser to reach the dashboard, and a terminal with
sudoor Docker access.
A few words first
- AI provider: a company that runs AI models and sells access to them, such as OpenAI or Anthropic.
- Model: one specific AI, like
gpt-4oor a Claude model. Each provider has its own list and its own names. - API key: a secret string that proves you're allowed to use a provider (and gets you billed). Treat it like a password.
- API endpoint: the web address a program sends its requests to. OmniRoute's is
http://localhost:20128/v1. - OpenAI-compatible: a request format copied from OpenAI's API. Most AI tools speak it, which is why one router can serve all of them.
- Router / gateway: a middleman. Your tools talk to it, it talks to the providers.
- Fallback: when one provider fails or runs out of quota, the router retries with the next one.
What OmniRoute is
| Platform | OmniRoute (AI model router/gateway) |
| Purpose | One API endpoint for many AI providers |
| License | MIT |
| Protocol | OpenAI-compatible API |
| Port | 20128 (dashboard and API) |
| Repository | github.com/diegosouzapw/OmniRoute |
| Feature | Details |
|---|---|
| Unified API | One /v1/chat/completions endpoint for every connected provider |
| Automatic routing | auto models pick a provider from the ones you've connected |
| Fallback | Moves to the next healthy model when a provider fails or runs out of quota |
| Combos | Your own ordered chains of models, with strategies like priority, round-robin and cost-optimized |
| Key Management | Provider keys stay on the server; tools only get an OmniRoute key |
| Web Dashboard | Providers, keys, routing and usage on port 20128 |
Why bother
Without a router, every tool needs its own provider settings:
- Before OmniRoute
- After OmniRoute
You still have accounts with each provider. The difference is that your tools only know about one address and one key. When you add a provider or rotate a key, you change it in one place.
Step 1: Run OmniRoute in Docker
This is the command from the project's README:
docker run -d --name omniroute --restart unless-stopped --stop-timeout 40 \
-p 127.0.0.1:20128:20128 -v omniroute-data:/app/data diegosouzapw/omniroute:latest
What each part does:
-druns it in the background.--restart unless-stoppedbrings it back after a reboot.-p 127.0.0.1:20128:20128publishes port 20128, but only to the machine itself. That's the safe default. Step 6 shows how to open it to your network.-v omniroute-data:/app/datastores the database, your provider settings and the server's generated secrets in a Docker volume. Don't skip this. Without it you lose everything when the container is replaced.
Check it worked:
docker ps --filter name=omniroute
curl http://localhost:20128/healthz
docker ps should show the container as Up. The health check reports whether the server is ok or still starting. If it's starting, wait a few seconds and try again.
Prefer not to use Docker? The README also offers
npm install -g omniroutefollowed byomniroute. It needs Node.js 22 or 24.
Step 2: Open the dashboard and set a password
On the server, open http://localhost:20128. If the server has no desktop, use an SSH tunnel from your own computer:
ssh -L 20128:localhost:20128 you@YOUR_SERVER_IP
Then open http://localhost:20128 in your local browser.
On first visit the onboarding wizard asks you to create the dashboard password. The Docker image starts without one, so there's no default to look up.
If you install with npm or from source instead, the setup copies
.env.example, which containsINITIAL_PASSWORD=CHANGEME. That placeholder is public. Change it before the first start.
Step 3: Connect a provider
- In the dashboard, go to Providers.
- Pick a provider and paste its API key, or complete its sign-in flow.
- Repeat for any other providers you want.
You can connect the same provider more than once with different keys. That gives OmniRoute something to fall back to when one key hits its rate limit.
Step 4: Get your OmniRoute key and test it
Your tools won't use the provider keys. They use an OmniRoute key instead.
- Go to Endpoints in the dashboard.
- Copy your OmniRoute API key.
Check it worked. List the models OmniRoute can now reach:
curl http://localhost:20128/v1/models -H "Authorization: Bearer YOUR_OMNIROUTE_KEY"
You should see the models from the providers you connected. Then send a real request:
curl http://localhost:20128/v1/chat/completions \
-H "Authorization: Bearer YOUR_OMNIROUTE_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"auto","messages":[{"role":"user","content":"Hello!"}]}'
A JSON reply with an answer in choices[0].message.content means the whole chain works: your request, OmniRoute, a provider, and back.
Step 5: Choose how requests are routed
The model field in each request decides where it goes.
Let OmniRoute choose
Use one of the auto models and OmniRoute picks from your connected providers:
| Model | Optimizes for |
|---|---|
auto |
Balanced default; sticks with the last provider that worked |
auto/coding |
Quality first, tuned for code |
auto/fast |
Lowest latency |
auto/cheap |
Lowest price per token |
The README lists more variants. auto can only use providers you've connected and that are eligible, so a fresh install with no providers has nothing to route to.
Pick a specific model
Use the provider/model format:
curl http://localhost:20128/v1/chat/completions \
-H "Authorization: Bearer YOUR_OMNIROUTE_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/MODEL_ID",
"messages": [{"role": "user", "content": "Hello"}]
}'
Replace openai/MODEL_ID with an exact ID from the /v1/models list in Step 4. Copying it from there avoids typos and model names your providers don't offer.
Build a combo
A combo is your own ordered list of models. If the first one fails, runs out of quota or gets too expensive, OmniRoute moves to the next. You create combos in the dashboard, then use the combo's name as the model value.
Step 6: Connect your tools
Every tool gets the same three things:
Base URL: http://YOUR_SERVER_IP:20128/v1
API Key: your OmniRoute key from Dashboard → Endpoints
Model: auto (or a provider/model ID, or a combo name)
If your tools run on the same machine as OmniRoute, use localhost instead of the IP. If they run on other machines, first open OmniRoute to the network. Stop the container and start it again with two changes:
docker rm -f omniroute
docker run -d --name omniroute --restart unless-stopped --stop-timeout 40 \
-e REQUIRE_API_KEY=true \
-p 20128:20128 -v omniroute-data:/app/data diegosouzapw/omniroute:latest
-p 20128:20128 listens on all network interfaces. REQUIRE_API_KEY=true makes every /v1 request present a valid OmniRoute key. It's off by default, which is fine on 127.0.0.1 but not on a network. Your settings survive because they live in the omniroute-data volume.
Check it worked. From another machine, run the /v1/models curl from Step 4 with the server's IP. Then try it without the Authorization header on a chat request; it should be refused.
OpenCode
Edit ~/.config/opencode/opencode.json (or opencode.jsonc):
{
"$schema": "https://opencode.ai/config.json",
"model": "omniroute/auto",
"provider": {
"omniroute": {
"npm": "@ai-sdk/openai-compatible",
"name": "OmniRoute",
"options": {
"baseURL": "http://YOUR_SERVER_IP:20128/v1",
"apiKey": "your-omniroute-api-key"
},
"models": {
"auto": { "name": "auto" }
}
}
}
}
The base URL ends in /v1 exactly once. A doubled /v1/v1 is the most common cause of 404 errors, according to OmniRoute's OpenCode guide. Quit and restart OpenCode, then check that omniroute/auto appears in its model list.
Continue (VS Code extension)
Continue now uses ~/.continue/config.yaml:
name: My Config
version: 0.0.1
schema: v1
models:
- name: OmniRoute
provider: openai
model: auto
apiBase: http://YOUR_SERVER_IP:20128/v1
apiKey: your-omniroute-api-key
provider: openai here means "speaks the OpenAI format", not "sends to OpenAI".
Python (OpenAI SDK)
from openai import OpenAI
client = OpenAI(
base_url="http://YOUR_SERVER_IP:20128/v1",
api_key="your-omniroute-api-key"
)
response = client.chat.completions.create(
model="auto/coding",
messages=[{"role": "user", "content": "Hello"}]
)
print(response.choices[0].message.content)
curl with streaming
curl http://YOUR_SERVER_IP:20128/v1/chat/completions \
-H "Authorization: Bearer your-omniroute-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "auto/coding",
"messages": [{"role": "user", "content": "Write a Python hello world"}],
"stream": true
}'
Step 7: Lock it down
OmniRoute holds every provider key you own, so treat it like a password manager.
- Never expose it to the internet without authentication. Keep
REQUIRE_API_KEY=truewhenever it listens beyond127.0.0.1. - Give each tool its own OmniRoute key so you can revoke one without breaking the rest.
- Rotate keys now and then, both OmniRoute keys and provider keys.
- Back up the
omniroute-datavolume. The server generates its signing and encryption secrets on first run and saves them there. Lose the volume and your stored keys go with it.
Firewall
Allow only your own network to reach port 20128. Adjust the range to match your LAN:
# Only allow your local network
sudo ufw allow from 192.168.1.0/24 to any port 20128
# Or a single machine
sudo ufw allow from 192.168.1.100 to any port 20128
One catch: Docker publishes ports through its own firewall rules, and those can bypass ufw. Binding to 127.0.0.1 (Step 1) and putting a reverse proxy in front is the safer pattern.
HTTPS with a reverse proxy
A reverse proxy is a web server that takes HTTPS traffic from outside and passes it to OmniRoute on 127.0.0.1. Keep OmniRoute bound to 127.0.0.1:20128 and use something like this in Nginx:
# /etc/nginx/sites-available/omniroute
server {
listen 443 ssl;
server_name omniroute.yourdomain.com;
ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
location / {
proxy_pass http://127.0.0.1:20128;
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 $scheme;
# Pass streamed answers through as they arrive
proxy_buffering off;
# Allow WebSocket upgrades
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
OmniRoute's Docker guide also has a ready-made Caddy setup that gets certificates automatically.
Step 8: Keep an eye on it
Follow the logs:
docker logs -f omniroute
Quick health checks:
# Is the server up?
curl http://localhost:20128/healthz
# Can it see your models?
curl http://localhost:20128/v1/models -H "Authorization: Bearer YOUR_OMNIROUTE_KEY" | python3 -m json.tool | head -20
The dashboard tracks requests and token usage per provider, which is the easiest place to spot a runaway script before the bill arrives.
To update, pull the new image and recreate the container with the same docker run command. Your data stays in the volume:
docker pull diegosouzapw/omniroute:latest
docker rm -f omniroute
# then run the docker run command from Step 1 (or Step 6) again
Troubleshooting
curl to port 20128 is refused from another machine. The container is bound to 127.0.0.1. Recreate it with -p 20128:20128 as in Step 6, and check your firewall.
401 Invalid API key. REQUIRE_API_KEY=true is on and the key is wrong or missing. Copy it again from Dashboard → Endpoints and send it as Authorization: Bearer ....
404 errors from a tool. The base URL is wrong. It should end in /v1 exactly once: http://YOUR_SERVER_IP:20128/v1. Watch out for /v1/v1 and for old guides that use /api/v1.
Requests with auto fail even though the server is up. No eligible provider is connected yet, or every connected one is out of quota. Add a provider in the dashboard and check that its models show up in /v1/models.
The model list is empty in OpenCode. Add "auto" (or the exact IDs you want) under models in the OmniRoute provider block, as in the example above.
Streamed answers arrive all at once or time out behind Nginx. Nginx is buffering the response. Add proxy_buffering off; to the location block and reload Nginx.
The container crashes with a memory error when a coding agent runs. The image caps OmniRoute's memory at 1 GB by default, which is too little for agents with long conversations. Recreate the container with a bigger limit, for example -e OMNIROUTE_MEMORY_MB=8192 --memory=10g, as the README describes.
You forgot the dashboard password. Change it in Settings → Security if you're still logged in. Otherwise the project documents an omniroute reset-password command.
What I'd tell anyone building one
-
Start with OpenRouter if you have no provider keys. One OpenRouter key gives you access to many models, some of them free. Connect it to OmniRoute and you can be running in a few minutes.
-
Use
autoorauto/codingas your default. OmniRoute picks from the providers you've connected, so you don't have to chase model names. Pin a specificprovider/modelonly when you need exactly that model. -
Protect the data volume. It holds your provider keys and the secrets that encrypt them. Back it up, and keep it out of anything you share.
-
Watch out for proxy buffering. If you put OmniRoute behind Nginx and streaming feels broken, buffering is the usual cause.
-
Check usage in the dashboard every week. It's the fastest way to catch unusual spending before it becomes a problem.
-
More keys means more redundancy. Connect the same provider twice with different keys. When one hits its rate limit, OmniRoute falls back to the other.
Next steps
- Build a combo with a free model first and a paid one as backup.
- Give each tool its own OmniRoute key so you can see which one uses the most.
- Read the Free Tiers Guide before relying on free providers. Some need sign-up or approval.
Links
- OmniRoute: github.com/diegosouzapw/OmniRoute
- Docker Image:
diegosouzapw/omniroute:latest - OpenCode: opencode.ai
- Continue: continue.dev
Last updated: 2026-10-24. Commands checked against the OmniRoute README and docs (v3.8.x), Docker 27.x.