Every request is classified (trivial / easy / medium / hard) and routed to one of four tiers: everyday, moderate, high, very_high. Each tier is an ordered pool of interchangeable candidates across your Kimi, Anthropic, Meta Muse, Windsurf, OpenAI, Copilot, xAI, Cursor, and Z.ai subscriptions. Same model on two subscriptions? List it twice: the router burns the wallet you prefer and rotates when one cools down. OAuth login only. No API keys anywhere: not stored, not accepted, not even as a fallback. Fail closed, always.
Monti is a standalone local service, not a plugin or a fork. It works with opencode (first-class, via a 10-line config) and any OpenAI-compatible client, and it ships its own minimal terminal agent for quick tasks.
Features
Free Classification
Difficulty classification runs on a free-first pool, so routing itself costs about nothing. Only short task excerpts are sent to the classifier.
Wallet Rotation
Each tier lists candidates in your preference order. A 429 or quota refusal cools that wallet down and the next wallet serves. Same quality band, different subscription.
Session Escalation
In weak-first-escalate mode, sessions start at the routed
tier and climb one rung after repeated tool errors or an explicit
"this isn't working".
Live Model Catalogs
monti models lists the live catalog of every logged-in
subscription, so pinning a model never means guessing IDs.
Token Safety
Subscription tokens live in mode 0600 files with atomic writes,
per-provider refresh locks, and one-retry-on-401, then a clear
RELOGIN_REQUIRED. Tokens are never logged.
Config Guardrails
Config containing anything key-shaped is rejected at load time, and a source-scan test fails the build on key-shaped strings or env reads.
Provider support
Narrow, documented exception: plans with no portable OAuth flow (currently Z.ai)
accept the plan key interactively via monti login zai only, never
from config or environment. See SPEC.md.
Quickstart
Requires Python 3.11+ on macOS or Linux.
As a CLI tool (recommended)
uv tool install git+https://github.com/mmorri/monti # or: pipx install git+https://github.com/mmorri/monti
monti setup # connect subscriptions, auto-picks models, saves config
monti models # live catalogs + pool status
monti # interactive session (/help for commands)
monti setup walks you through each provider login (skip what you
don't have), probes the live catalog of everything connected, and builds the
tier pools plus the free-first classifier from what actually exists on your
accounts.
From a checkout (for development)
git clone https://github.com/mmorri/monti && cd monti
uv venv && uv pip install -e . # or: python3 -m venv .venv && .venv/bin/pip install -e .
source .venv/bin/activate # without this, `monti` is not on PATH
monti login kimi
Use with opencode
monti serve # or: model-router serve --config <path>
{
"provider": {
"model-router": {
"npm": "@ai-sdk/openai-compatible",
"options": { "baseURL": "http://127.0.0.1:8787/v1" },
"models": {
"router-auto": { "name": "Router · auto" },
"router-everyday": { "name": "Router · everyday" },
"router-moderate": { "name": "Router · moderate" },
"router-high": { "name": "Router · high" },
"router-very-high": { "name": "Router · very high" }
}
}
}
}
Pick a router model in opencode's model picker, or send an
X-Router-Mode header from any client.
Modes
Security model
- Subscription OAuth tokens are the only credentials, stored mode 0600 and never logged; errors are status-only.
- Config containing anything key-shaped is rejected at load time.
- The terminal agent's file tools are workspace-confined; writes, edits, and
shell commands require interactive approval (or explicit
--yes).
Documentation
- SPEC.md, design spec, including the plan-key exception.
- docs/TRANSPORTS.md, per-provider transport status and the Cursor decision record.
- THIRD_PARTY.md, attributions for the MIT-licensed OAuth flows this project ports.
Disclaimer. Monti authenticates with your personal subscriptions the same way the providers' own CLI clients do. Some providers' terms of service may not contemplate third-party clients using subscription tokens; you are responsible for how you use your own accounts. This project is not affiliated with or endorsed by any provider.