Self-hosted LLM gateway with Docker: a step-by-step guide
Routerly has come a long way since 0.2.0. With 0.6.0 you can go from the official Docker image to a working gateway with nothing but a terminal and a provider key, and this guide does exactly that: one container, one admin, one model, one router, and a first request in both OpenAI and Anthropic format.
Every command below was executed against inebrio/routerly:v0.6.0 with real OpenAI and Anthropic keys. The outputs quoted are the ones we observed.
What you need
- Docker (we tested 20.10.24).
- An API key from at least one provider (OpenAI or Anthropic in this guide).
- Port 3000 free on the host.
A word on the title: we measured the steps, not a stopwatch promise. Starting the gateway the first time took between seconds and a few minutes depending on how loaded the host was (we saw 246 seconds on a busy machine), and the image pull depends on your network. Plan for a few minutes of hands-on work plus the wait.
Start the container
docker run -d \
--name routerly \
-p 3000:3000 \
-v routerly_data:/data \
-e ROUTERLY_HOME=/data \
--restart unless-stopped \
inebrio/routerly:v0.6.0
The image tag carries the v prefix: v0.6.0 exists, 0.6.0 does not. Wait until the health endpoint answers:
until curl -sf http://localhost:3000/health; do sleep 5; done
On 0.6.0 it returns {"status":"ok","version":"0.6.0", ...}. The dashboard is at http://localhost:3000/dashboard/.
Create the admin
On a fresh volume the service waits for its first administrator. Create it with the setup endpoint:
curl -s -X POST http://localhost:3000/api/setup/first-admin \
-H 'Content-Type: application/json' \
-d '{"email":"[email protected]","password":"change-me-please-123"}'
Use your own email and a strong password. The CLI ships inside the image, so log it in from the container:
docker exec routerly routerly auth login \
--url http://localhost:3000 \
--email [email protected] --password 'change-me-please-123'
docker exec routerly routerly status should now show Version: 0.6.0 and your account with role admin.
Add your first model
Pass the key through the environment so it does not land in your shell history:
docker exec -e K="$OPENAI_API_KEY" routerly sh -c \
'routerly model add --id gpt-5-nano --provider openai --api-key "$K"'
Repeat with --provider anthropic for a Claude model if you want both. routerly model list shows what is registered. Cost columns stay empty until you set prices with --input-price and --output-price (USD per 1M tokens), so the usage report shows a cost of 0 until you do.
Create a router
A router is the endpoint your applications talk to. It owns a set of models and a token.
docker exec routerly routerly router create --name "My App"
docker exec routerly routerly router model add "My App" gpt-5-nano
router create prints the router token once. Copy it and export it as T. With a single model in the router, the answer comes from that model. With several, Routerly decides which one serves each request, which is the point of a router and also means the model named in the request is not a guarantee. Keep one model per router while you test.
First call, OpenAI format
curl http://localhost:3000/v1/chat/completions \
-H "Authorization: Bearer $T" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-5-nano","messages":[{"role":"user","content":"Say hello in five words."}]}'
We got a standard chat completion back, with the answer “Hello there, how are you?”. Reasoning models spend tokens thinking: with a very small max_tokens you can get an empty answer, so leave room (1024 worked for us).
First call, Anthropic format
The same router answers the Anthropic Messages API. Only the path and headers change:
curl http://localhost:3000/v1/messages \
-H "x-api-key: $T" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-5-nano","max_tokens":1024,"messages":[{"role":"user","content":"Say hello in five words."}]}'
In our run an OpenAI model answered an Anthropic-format request, and the reply came back as a normal Messages response. Your client keeps using its official SDK: change the base URL to http://localhost:3000/v1 and use the router token as the key.
See what happened
docker exec routerly routerly report usage
docker exec routerly routerly report calls --limit 3
Each call lists router, model, tokens, latency and outcome. The dashboard, at /dashboard/, is where you manage the same models and routers visually.
Persistence
All state lives in the /data volume. We removed the container and started a new one with the same docker run command and the same volume: models, router and token were all still there, and the existing token kept working. Back up the volume the way you back up any other Docker volume.
Update and release channels
Inside Docker the in-place updater is not available. To update, pull the new tag and recreate the container on the same volume:
docker pull inebrio/routerly:v0.6.0
docker rm -f routerly
# run the same docker run command with the new tag
docker exec routerly routerly update channel lists the channels (latest, current, next, stable, develop) and routerly update check tells you whether a newer release exists. The channel names map to Docker Hub tags such as latest, next and develop.
Troubleshooting
Port 3000 is already allocated
Docker reports Bind for 0.0.0.0:3000 failed: port is already allocated. Change the host side of the mapping, for example -p 3100:3000, and use that port everywhere.
The container is unhealthy right after start
The first start can take minutes on a loaded host. Watch docker logs -f routerly and poll /health before concluding something is broken.
401 Invalid router token
A request with a wrong or missing token returns {"error":{"message":"Invalid router token.","type":"invalid_request_error","param":null,"code":"invalid_api_key"}}. Check that you are sending the router token, not the admin password or the provider key.
Empty answer from a reasoning model
Raise max_tokens. The model may have used the whole budget on reasoning.
Cost shows 0
Set --input-price and --output-price when adding the model.
Known limits
- First start can be slow on loaded hosts.
- Costs need explicit model prices.
- A router with several models chooses the model itself.
routerly update rundoes not apply inside Docker.- We did not test the Docker Compose variant for this guide, so we do not publish one here.
Where to go next
- Installation covers the other install paths.
- Quick start is the short version of this guide.
- Routers and models explain the building blocks.
- Self-hosting covers running it for a team.
- CLI reference lists every command used above.
Routerly sits as the decision and control layer between your applications and whatever serves the models. That makes it a natural fit on top of other gateways and tools, and we are looking at how it can work with projects such as JEV and OmniRoute. More on that when there is something to show.
Sources
- inebrio/routerly on Docker Hub, consulted 2026-11-04.
- Routerly repository and v0.6.0 documentation, consulted 2026-11-04.