Multi-key, multi-model routing for OpenCode with OpenRouter.
Never hit a rate limit again. Mux automatically switches between your API keys and models to keep you coding.
English | 简体中文 | 繁體中文 | 한국어 | Deutsch | Español | Français | Italiano | Dansk | 日本語 | Polski | Русский | Bosanski | العربية | Norsk | Português (Brasil) | ไทย | Türkçe | Українська | বাংলা | Ελληνικά | Tiếng Việt
Mux is a smart routing layer built on top of OpenCode that works with OpenRouter API keys. It automatically manages multiple API keys and models to:
- Avoid rate limits — when one key runs out of credits, Mux switches to another
- Optimize costs — route prompts across your selected models based on availability
- Stay productive — no manual key switching needed
- Multi-key management — add multiple OpenRouter API keys and let Mux pick the best one
- Model selection — choose which models Mux can use from your OpenRouter catalog
- Auto-switching — when a key's credits run low, Mux automatically switches to a key with more credits
- Model availability view — see at a glance which models are usable with each key
- Key status monitoring — check token usage and remaining credits for all keys
# Windows (PowerShell)
irm https://raw.githubusercontent.com/hacimertgokhan/opencode-mux/main/install-mux.ps1 | iex
# Linux/macOS
curl -fsSL https://raw.githubusercontent.com/hacimertgokhan/opencode-mux/main/install | bash- Clone this repository
- Run
bun installin the project root - Run
bun run buildinpackages/opencode - Copy the built binary to your PATH
After installation, run:
muxThis launches OpenCode with Mux routing enabled. You can also run opencode-mux directly.
mux installs to ~/.opencode-mux/bin (or %LOCALAPPDATA%\opencode-mux\bin on Windows), so it does not overwrite your existing opencode command.
Inside the TUI, use /mux (or /mu) to open the Mux router menu:
| Command | Description |
|---|---|
/mux |
Open the Mux router menu |
/mu |
Alias for /mux |
/mux status |
Show key usage and credit status |
/mux keys |
Manage API keys (add, remove, activate, test) |
/mux models |
Select which models Mux can use |
/mux switch |
Switch to the key with the most remaining credits |
/mux about |
Show project information |
Legacy dash commands still work (/mux-status, /mux-keys, /mux-models, /mux-switch, /mux-about).
Keyboard shortcut: Press Tab with an empty prompt to toggle Mux mode on/off.
Mux stores its configuration in ~/.opencode-router-manager/config.json. You can manage everything through the TUI dialogs — no manual config editing needed.
- Add your OpenRouter API keys using
/mux keys→ Add Key - Select your preferred models using
/mux models - Enable Mux mode by pressing
Tabin the prompt or via/mux→ Enable - Start coding — Mux automatically routes your prompts to the best available key and model
When you send a message, Mux checks:
- Can the current key afford the selected model? If yes, use it.
- If not, is there another key with enough credits? If yes, switch.
- If the current model is unavailable, try other selected models.
packages/
├── opencode/ # Forked OpenCode with Mux integration
│ └── src/
│ ├── router-manager/ # Core Mux routing logic
│ └── cli/cmd/tui/
│ └── component/
│ └── dialog-router-manager.tsx # Mux TUI dialogs
└── ...
This project incorporates OpenCode (licensed under the Apache License 2.0) with additional Mux functionality. See LICENSE for details.
Built with ❤️ by hacimertgokhan