Open documentation index
ModelMux documentation
Run one OpenAI-compatible endpoint in front of multiple LLM providers and API keys, with routing, failover, limits, logs, and terminal-first operations.
ModelMux is a lightweight reverse proxy that accepts OpenAI-compatible requests and routes them across configured providers, models, groups, and API keys.
What is ModelMux?
ModelMux sits between your application and upstream LLM APIs. Your application sends requests to one local or self-hosted endpoint. ModelMux then selects a model or group, chooses an eligible key, enforces limits, retries recoverable failures, and forwards the provider response back to the client.
It runs as a single Go binary. Redis, message queues, Postgres, and an external control plane are not required. Runtime state can remain in memory for local use or be persisted with embedded SQLite.
Request flow
- The client sends a request to
/v1/chat/completionsor another supported OpenAI-compatible route. - ModelMux resolves the requested model ID. A model group may select one member before key selection begins.
- Disabled, invalid, cooling-down, quota-exhausted, or concurrency-limited keys are excluded.
- The configured routing strategy selects an eligible key.
- ModelMux applies provider conversion when Anthropic or Gemini is used.
- Recoverable failures may trigger retry and failover according to the retry and cooldown configuration.
- The response is streamed or returned normally, while usage, latency, status, and request metadata are recorded.
When to use ModelMux
| Situation | How ModelMux helps |
|---|---|
| Multiple keys for one model | Distributes or fails over traffic across credentials. |
| Provider rate limits | Enforces local limits and temporarily cools down keys after upstream 429 responses. |
| Multiple LLM vendors | Presents one OpenAI-compatible endpoint while adapting supported provider formats. |
| Self-hosted applications | Keeps routing and credentials under your control without a hosted gateway dependency. |
| Terminal operations | Provides CLI commands and a TUI for configuration, logs, metrics, chat, and key health. |
Documentation map
Production checklist
- Bind to localhost unless remote access is required.
- Enable proxy authentication before exposing the service over a network.
- Keep
server.admin.require_authenabled. - Use environment variables or the encrypted secret store for provider credentials.
- Enable SQLite when quotas, cooldown state, and request history must survive restarts.
- Set realistic model and key-level RPM, token, and concurrency limits.
- Monitor
/metrics, request errors, cooldown counts, and active-key capacity. - Back up both the SQLite database and
secrets.encwhen encrypted secrets are used.