RepositoryGo
yolorouter

yolorouter/yolorouter

A self-hosted, OpenAI-compatible LLM gateway with multi-provider failover, key rotation, and a built-in admin console.

404stars
6forks
0issues
4views

Featured achievements

The project's latest awards

1
TINIX TRENDING·Topic: openai-proxy

#1 Repository of the week

1
TINIX TRENDING·Topic: load-balancing

#1 Repository of the week

1
TINIX TRENDING·Topic: llm-gateway

#1 Repository of the week

Yolorouter

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.

License CI Go Report Card Release Go

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 — juggling provider accounts, rotating rate-limited keys, failing over when an account breaks, enforcing per-key budgets, and knowing what everything costs — live in one place instead of scattered across every codebase.

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. No Node runtime, no separate frontend deploy, no external services required — SQLite works out of the box, PostgreSQL when you want it.

Why Yolorouter

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 — transparently, without the caller ever seeing 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.
  • 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.

Screenshots

Dashboard Analytics

Quick start

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 | iex

On 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.com for gh.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).

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

Protocols

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 routeProtocolAccepted auth headers
POST /v1/chat/completionsOpenAI Chat CompletionsAuthorization: Bearer, X-Api-Key
POST /v1/responsesOpenAI ResponsesAuthorization: Bearer, X-Api-Key
POST /v1/messagesAnthropic MessagesAuthorization: Bearer, X-Api-Key
POST /v1beta/models/{model}:generateContent
POST /v1beta/models/{model}:streamGenerateContent
Geminix-goog-api-key, ?key=, Authorization: Bearer, X-Api-Key
GET /v1/models, GET /v1/models/{model}Model discoveryAuthorization: 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_image entries 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.

Point existing SDKs and tools at it

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

Cost optimization

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 every signal: failures, stack traces, and each distinct match are preserved. 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

Documentation

TopicLink
Installation (all platforms, from source)Installation
Every config.yaml field and the CLIConfiguration
Upgrading, rolling back, uninstallingUpdating
Layering, protocol IR, storageArchitecture
API reference and model catalogueDocs 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.

Build from source

Requires Go 1.25.7+ and Node.js 22.12+.

make build          # backend only -> ./bin/yolorouter
make build-embed    # full binary with the console embedded

Cross-compilation targets, the test commands and the local development workflow are documented in CONTRIBUTING.md.

Contributing

Issues and pull requests are welcome. Please read CONTRIBUTING.md and the Code of Conduct first. For security reports see SECURITY.md.

License

Licensed under the Apache License 2.0.

Similar Projects

Discover other similar projects and AI models.

RepositoryPython
mozilla-ai/otari

Open-source AI gateway you run yourself. One endpoint for 40+ providers, with virtual keys, budgets, and usage tracking.

986
Nov 30, 2026
RepositoryGo
maximhq/bifrost

Open-source, high-performance AI gateway that works as your LLM gateway, MCP gateway and agent gateway. One OpenAI-compatible API for 10,000+ models, with failover, load balancing, semantic caching, virtual keys, budgets and MCP Code Mode. Works with any SDK or agent and adds under 200µs of overhead at 5k RPS.

10.1k
Dec 1, 2026
RepositoryGo
yanstd888/9routerx

9RouterX (9R Next Go Generation): Single-binary Go AI router, LLM gateway & 20-40% token saver. Route Claude Code, Cursor & Codex across 155 providers, 28 OAuth & 248 free models (24 keyless) — OpenAI, Claude, Gemini, DeepSeek, Groq, Ollama & MCP.

279
Nov 28, 2026
RepositoryRust
respanai/respan-gateway

Open-source LLM gateway in Rust. One endpoint for OpenAI, Anthropic, Gemini and every other vendor. Any SDK, any model, any tool.

1.2k
Nov 30, 2026
RepositoryRust
ThinkWatchProject/ThinkWatch

Self-hosted AI API and MCP gateway for organizations: SSO and RBAC, per-user identity for MCP tool calls, PII redaction and tool-call guards, rate limits, budgets, cost accounting and audit logs.

818
Dec 1, 2026
RepositoryRust
nyroway/nyro

Self-hosted AI Gateway — connect Claude Code, Codex, Gemini CLI and any SDK to any model provider with protocol translation.

200
Oct 16, 2026
RepositoryHTML
cuihuan/awesome-ai-gateway

⚡ Awesome AI Gateway — pick an AI gateway from 240+ (LiteLLM, OpenRouter, Portkey, Kong, Higress, new-api, Bifrost) by cost, security & compliance, see what consolidated in 2026, learn how they actually work from an 8-chapter handbook, and verify every number yourself. Reproducible benchmarks, bilingual; stars & releases refreshed daily.

161
Nov 26, 2026
RepositoryPython
0xzr/freellmpool

Free LLM gateway: 22 LLM providers, 178 enabled chat routes, 431 cataloged chat models; keyless start when available.

159
Nov 20, 2026
RepositoryTypeScript
Inebrio/Routerly

Self-hosted LLM gateway that routes requests across AI providers (OpenAI, Anthropic, Gemini, Mistral, Ollama) using intelligent multi-policy scoring — including an LLM-native routing policy. Drop-in compatible: just swap the base URL. No database required, built-in cost tracking, budget enforcement and multi-tenant isolation.

111
Nov 12, 2026