A free, self-hosted LLM gateway that speaks four wire protocols, fails over across providers, rotates upstream keys, and ships with an admin console in one binary.
English · 简体中文
Quick start · Protocols · Cost optimization · Documentation · Contributing
⚡ Low-overhead streaming proxy · 🔀 Any protocol in, any protocol out · 🆓 Free & open-source · 📦 Single binary, zero external deps · 🔁 Automatic failover + key rotation · 💰 Cost analytics & optimization
Point your application at one endpoint and one API key. Yolorouter sits between your apps and your upstream providers, so the messy parts live in one place instead of scattered across every codebase: juggling provider accounts, rotating rate-limited keys, failing over when an account breaks, enforcing per-key budgets, and knowing what everything costs.
It accepts four wire protocols (OpenAI Chat Completions, OpenAI Responses,
Anthropic Messages, and Gemini generateContent) and can translate any of
them to any other on the way out. An OpenAI-only provider can serve Claude
Code; an Anthropic-only provider can serve the OpenAI SDK. Streaming, tool
calling, and reasoning/thinking blocks all survive the trip, as does image
content on every ingress except Responses (see Protocols).
Everything ships as a single binary with the web console embedded. There is no Node runtime to install and no separate frontend deploy. SQLite works out of the box; switch to PostgreSQL when you want it.
Routing
- Multi-provider failover. Map one public model name (e.g.
smart) to an ordered list of provider candidates. When one is down, requests fail over to the next; the caller never sees a different model name. - Upstream key rotation. Give each provider a pool of upstream keys. Rate-limited, unauthorized, or quota-exhausted keys are skipped automatically.
- Model aliasing. Callers request a stable public name; each provider candidate maps it to whatever model id that provider actually expects. Candidate mappings are probed against the real upstream when you save them, so a typo is caught at configuration time, not at 3 a.m.
- Vision fallback. Let text-only models "see". Mark a model as unable to read images and pick a vision model in the console; images in incoming requests are described by the vision model and forwarded as text, transparently to the caller, on every ingress protocol. With no vision model configured, images degrade to a clear placeholder instead of an upstream error.
- Streaming done right. Key rotation and failover happen before the first byte reaches the client; once streaming starts, the provider is locked in. Content from two providers is never stitched into one response.
- Timeouts tuned for reasoning models. Seven independent, configurable phases instead of one wall clock, so a model that thinks for eight minutes before emitting a token isn't killed mid-thought.
Control & cost
- Per-key access control. Model allowlists, rate and concurrency limits, cumulative budget caps, optional expiry, instant revocation.
- Cost optimization. Inject a custom system prompt globally or per key; compress bulky tool output before it reaches the upstream. The console reports what each actually saved.
- Built-in observability. Token and cost KPIs, usage by model / provider / time / caller, and request logs with the full per-attempt routing chain. Any view exports to CSV.
- Bilingual console. English and 简体中文, switchable anywhere; timezone follows the browser.
- Self-update. The binary can check for and apply new releases.
docker run -d --name yolorouter --restart unless-stopped \
-p 8080:8080 -v "$PWD/yolorouter:/yolorouter" \
ghcr.io/yolorouter/yolorouter:latestOr grab docker-compose.yml and run docker compose up -d.
Images are published for amd64 and arm64 with every release.
Everything the container writes lives in the one mounted folder: the generated
configs/config.yaml (including the key that encrypts your upstream keys) and
the SQLite database. Back up that folder and you have backed up the deployment.
Upgrade with docker compose pull && docker compose up -d; with plain
docker run, pull the image, remove the container, and run the same command
again — the mounted folder carries everything over.
No Docker, or want the built-in self-updater? Install as a background service that starts on boot: systemd on Linux, launchd on macOS, a scheduled task on Windows.
# Linux / macOS
curl -fsSL https://get.yolorouter.com/install.sh | bash# Windows, PowerShell 5.1+
irm https://get.yolorouter.com/install.ps1 | iexOn Windows, an elevated PowerShell installs a system-wide service that starts at boot; a normal one installs under your account and starts at logon.
🇨🇳 China mirror: if GitHub is slow or unreachable from your network, swap
get.yolorouter.comforgh.yolorouter.com. Same installers, routed through a Cloudflare proxy, and auto-updates keep using the mirror afterwards.
Re-run the same command to upgrade; configuration and database are preserved and
the database is backed up first. Prefer a plain binary? Grab a
release and run
./yolorouter serve (.\yolorouter.exe serve on Windows).
Whichever way you start it, the first run generates configs/config.yaml,
applies migrations and starts the console on port 8080. Create the first admin
account, then follow the guided flow: add providers and upstream keys, create
models with their provider candidates, and issue API keys.
→ Full installation guide for every platform, including building from source: yolorouter.com/help?p=self-hosted/installation
Every ingress below authenticates with the same Yolorouter API key, supports streaming, and can be served by any configured provider, no matter which protocol that provider natively speaks.
| Ingress route | Protocol | Accepted auth headers |
|---|---|---|
POST /v1/chat/completions |
OpenAI Chat Completions | Authorization: Bearer, X-Api-Key |
POST /v1/responses |
OpenAI Responses | Authorization: Bearer, X-Api-Key |
POST /v1/messages |
Anthropic Messages | Authorization: Bearer, X-Api-Key |
POST /v1beta/models/{model}:generateContentPOST /v1beta/models/{model}:streamGenerateContent |
Gemini | x-goog-api-key, ?key=, Authorization: Bearer, X-Api-Key |
GET /v1/models, GET /v1/models/{model} |
Model discovery | Authorization: Bearer, X-Api-Key |
The model in every request is the public name you configured. Yolorouter picks
a provider candidate, swaps in the real upstream model id, and keeps your public
name in the response.
Known limitation:
input_imageentries on the Responses ingress are dropped when the request has to be translated to a different egress protocol; only text is forwarded. Same-protocol passthrough is unaffected, and image content translates correctly on the other three ingresses.
Because the ingresses are the real native protocols, official SDKs and agent tools need two settings changed and no adapter layer:
# OpenAI Python SDK
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8080/v1", api_key="sk-yr-your-key")
print(client.chat.completions.create(
model="smart",
messages=[{"role": "user", "content": "Hello!"}],
).choices[0].message.content)# Claude Code — routed through Yolorouter to whichever provider you configured
export ANTHROPIC_BASE_URL=http://localhost:8080
export ANTHROPIC_AUTH_TOKEN=sk-yr-your-key
claude→ Per-protocol request examples and setup guides for 19 agent tools (Claude Code, Cursor, Codex CLI, Cherry Studio, Gemini CLI, opencode …): yolorouter.com/help
Both features are off by default, configured globally in the console, and overridable per API key.
Custom system prompt injection. Append house rules to every request's system prompt without touching client code. The injection follows the caller's own protocol shape and is deterministic, so repeated requests produce byte-identical system content and still hit upstream prompt caches.
Input compression. Coding agents send back huge, highly redundant tool output.
Yolorouter recognizes what each content block is (go test output, git diffs,
grep results, plain logs) and strips the noise while keeping the signal: failures,
stack traces, and each distinct match all survive. It never touches the active edit
region at the tail of the conversation, and only replaces a block when the compressed
form is actually shorter.
Cache-read and cache-write tokens are metered and priced separately throughout the dashboard, so prompt-cache savings are a number you can see rather than a feeling.
→ Details and tuning: yolorouter.com/help?p=self-hosted/configuration
| Topic | Link |
|---|---|
| Installation (all platforms, from source) | Installation |
Every config.yaml field and the CLI |
Configuration |
| Upgrading, rolling back, uninstalling | Updating |
| Layering, protocol IR, storage | Architecture |
| API reference and model catalogue | Docs home |
Self-hosting means bringing your own upstream API keys. If you would rather not sign up with every provider separately, YoloRouter Cloud ships in the console's provider preset list as one more upstream you can select; see the hosted option.
Requires Go 1.25.7+ and Node.js 22.12+.
make build # backend only -> ./bin/yolorouter
make build-embed # full binary with the console embeddedOne script rebuilds everything, runs migrations, and restarts a local server:
./scripts/dev.sh # full rebuild + restart on http://localhost:8080
./scripts/dev.sh --backend # Go changes only; --frontend for console changes
tail -f logs/server.log # server log — the first place to look when debuggingConfiguration lives in configs/config.yaml and the SQLite database in
data/yolorouter.db, both created on first run. For request-level debugging,
the console's request-log detail page shows every relay's full client and
upstream bodies plus the per-attempt routing chain.
For frontend work, skip the rebuild loop entirely. Vite serves the console
with hot reload on port 5173 and proxies /api and /v1 to the backend:
cd frontend && npm run devmake test runs the Go tests, make gates the structural checks that CI
enforces. Windows scripts (scripts/dev.ps1), lint, and cross-compilation
targets are documented in
CONTRIBUTING.md.
Issues and pull requests are welcome. Please read CONTRIBUTING.md and the Code of Conduct first. For security reports see SECURITY.md.
Licensed under the Apache License 2.0.


