https://github.com/hacimertgokhan/mux
Never hit a rate limit again. Mux automatically switches between your API keys and models to keep you coding.
https://github.com/hacimertgokhan/mux
mcp opencode openrouter skills
Last synced: about 2 months ago
JSON representation
Never hit a rate limit again. Mux automatically switches between your API keys and models to keep you coding.
- Host: GitHub
- URL: https://github.com/hacimertgokhan/mux
- Owner: hacimertgokhan
- License: mit
- Created: 2026-04-03T11:48:38.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2026-04-05T09:26:27.000Z (about 2 months ago)
- Last Synced: 2026-04-06T10:10:49.493Z (about 2 months ago)
- Topics: mcp, opencode, openrouter, skills
- Language: TypeScript
- Homepage: https://mux.codes
- Size: 292 MB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
- Agents: AGENTS.md
Awesome Lists containing this project
README
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
---
## What is Mux?
Mux is a smart routing layer built on top of [OpenCode](https://opencode.ai) that works with [OpenRouter](https://openrouter.ai) 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
## Features
- **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
## Installation
### Quick Install (recommended)
```bash
# 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
```
### Manual Install
1. Clone this repository
2. Run `bun install` in the project root
3. Run `bun run build` in `packages/opencode`
4. Copy the built binary to your PATH
### Usage
After installation, run:
```bash
mux
```
This 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.
### Mux Commands
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.
## Configuration
Mux stores its configuration in `~/.opencode-router-manager/config.json`. You can manage everything through the TUI dialogs — no manual config editing needed.
## How It Works
1. **Add your OpenRouter API keys** using `/mux keys` → Add Key
2. **Select your preferred models** using `/mux models`
3. **Enable Mux mode** by pressing `Tab` in the prompt or via `/mux` → Enable
4. **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.
## Project Structure
```
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
└── ...
```
## License
This project incorporates OpenCode (licensed under the Apache License 2.0) with additional Mux functionality. See [LICENSE](LICENSE) for details.
---
**Built with ❤️ by** [hacimertgokhan](https://github.com/hacimertgokhan)
**Join the community** [Discord](https://discord.gg/opencode) | [X.com](https://x.com/opencode)