cheaplane
<p align="center">
<img src="assets/hero-banner.png" alt="Cheaplane β keep your premium model on the main thread, offload the grunt work to cheap models with billing that can't cross" width="880">
</p>
# millen-cheaplane π£οΈ
> **Keep your premium subscription on the main thread. Offload the grunt work to cheap models β Cheaplane even picks the right one for you. Stop burning premium tokens on boilerplate.**
[](https://pypi.org/project/cheaplane/)





<!-- mcp-name: io.github.millennialdreamer/cheaplane -->
Cheaplane is a tiny single-file MCP server (~370 lines, stdlib + `mcp` only) that gives your main agent β e.g. **Claude Code on a Max subscription** β one extra tool: **`delegate`**. Your agent keeps doing the thinking (planning, architecture, final review) and hands *replaceable grunt work* β boilerplate code, formatting, translation, summarizing long docs β to cheap models behind a local [LiteLLM](https://github.com/BerriAI/litellm) proxy (DeepSeek, Kimi, Qwen, β¦). Think of it as **a cheap intern for your premium agent** β it churns out the boring parts while you keep thinking.
The trick that makes it *safe*: **the delegated calls and your subscription live in physically separate processes and never share credentials.** ([why that matters β¬οΈ](#billing-isolation-the-whole-point))
The trick that makes it *effortless*: **auto-routing.** `delegate(task)` picks the right cheap model from the task itself β in the example setup, code β DeepSeek, long docs β Kimi, Chinese β Qwen. The rules and the models are yours to change, no code edits. ([how β¬οΈ](#make-it-yours))
The trick that makes it *stick*: **a per-turn reminder hook so your agent doesn't forget the tool exists** β [the part most "delegate" tools skip](#make-your-agent-actually-use-it). And a **savings ledger** shows you [what it kept off your quota](#see-what-you-saved).
**See it in action** β your agent hands a chore over; auto-routing sends it to the cheap code model:
```text
delegate("convert to a TypeScript interface: {id, name, email, isAdmin, roles[]}")
```
```ts
interface User {
id: number;
name: string;
email: string;
isAdmin: boolean;
roles: string[];
}
```
<sub>β a real call's output β not a mockup, and no model picked by hand. That token cost **over 15Γ less** than your premium model, and your subscription quota never moved.</sub>
## The problem
Premium models earn their price on hard problems β but every token counts against your plan, and you burn through quota on *churn*: reformatting JSON, translating UI strings, summarizing a doc you'll read once. The usual "just use a cheap model" setups force an ugly choice:
- **Downgrade the whole agent** β you lose main-thread quality on the work that actually matters.
- **Route everything through an API key** β you stop using the subscription you're already paying for.
Cheaplane keeps the sweet spot: **premium main thread for judgment + cheap models for the churn + billing that physically can't cross.**
## How Cheaplane compares
The popular 2026 move is to swap your *whole* agent onto a cheap model (DeepClaude-style). Great for raw cost β but it downgrades the thread you actually think with, **breaks your other MCP tools**, and doesn't even apply if you're on a Pro/Max subscription. Cheaplane takes the opposite bet:
| | Swap whole agent β cheap model *(DeepClaude-style)* | Everything via one API key | **Cheaplane** |
|---|:---:|:---:|:---:|
| Main thread | β¬οΈ downgraded | β¬οΈ no more subscription | β
stays premium |
| Your other MCP tools | β break | β
| β
*(it **is** an MCP server)* |
| Works on a Pro/Max subscription | β API-key only | β replaces it | β
built for it |
| Picks the cheap model for you | β one model for everything | β | β
`auto` routing |
| Shows what you saved | β | β | β
`savings` ledger |
| Billing | merged into one | one per-token bill | π subscription + cheap, **isolated** |
<sub>Comparison reflects how backend-swap setups (DeepClaude-style) behaved per public reports in mid-2026; specifics vary by tool and can change.</sub>
## How cheap is "cheap"?
The grunt work is the *easy* part β paying premium rates for it is pure waste. Per **million tokens** (public list prices, November 2026):
| Model | Input | Output | Best for |
|---|--:|--:|---|
| Claude Opus 5.5 *(API, for reference)* | $4.00 | **$20.00** | the judgment work you keep |
| DeepSeek V4 Flash | $0.30 *(off-peak $0.15)* | **$1.20** *(off-peak $0.60)* | code / formatting |
| Kimi K2.x | $0.60β0.95 | $2.50β4.00 | long docs (very large context) β K2 line is being retired; point the `kimi` alias at a newer Kimi model when it goes |
| Qwen | $0.05β0.40 | $0.20β1.20 | Chinese copy |
That's an output token costing **~$20 on Opus vs ~$1.20 on DeepSeek β roughly 17Γ more at peak (β33Γ off-peak) for work that doesn't need the smarts.** You're on a *subscription*, so you don't pay that $20 directly β your main thread spends *quota*, not dollars. That's the whole point: every routine task you offload is premium quota you keep for the hard problems. *(Summarizing a 40-page doc on DeepSeek Flash runs about a cent β your quota never even notices.)*
<sub>Prices are public list rates as of November 2026 and vary by tier, time of day and caching β check each provider. The stable takeaway is the order-of-magnitude gap, not an exact dollar saving.</sub>
## Billing isolation (the whole point)
Most "save money" hacks blur your bills together. Cheaplane keeps them physically apart:
```mermaid
flowchart LR
A["Main agent<br/>premium subscription"] -->|"delegate(task)"| B["Cheaplane MCP<br/>own process, own key"]
B -->|HTTP| C["LiteLLM proxy<br/>localhost:4000"]
C --> D["DeepSeek / Kimi / Qwen<br/>cheap, pay-per-use"]
```
The Cheaplane process **never imports your subscription provider's SDK, never reads its auth, never touches its OAuth token.** It knows exactly one thing: an HTTP endpoint (your proxy) and its key. Your main thread bills to your subscription; delegated calls bill to your cheap proxy. **The two can't cross β not by policy, by architecture.**
## Quick start
**Fastest path** β Claude Code, one script:
```bash
git clone https://github.com/millennialdreamer/millen-cheaplane && cd millen-cheaplane
cp litellm.yaml.example litellm.yaml # then: export DEEPSEEK_API_KEY=sk-...
litellm --config litellm.yaml & # start the cheap-model proxy on :4000
bash setup.sh # deps + register MCP + reminder hook + verify
```
`setup.sh` is idempotent (safe to re-run): it installs deps, registers the `delegate` MCP server with Claude Code, installs the per-turn reminder hook, and verifies the chain end-to-end. Then start a fresh Claude Code session β done.
<p align="center"><img src="assets/setup.png" alt="bash setup.sh β installs deps, registers the MCP server with Claude Code, installs the reminder hook, and verifies the chain end-to-end" width="760"></p>
**Prefer a package?** Cheaplane is on PyPI β no clone, no path to hard-code:
```bash
pip install cheaplane # or: uvx cheaplane / pipx install cheaplane
claude mcp add delegate cheaplane
```
You still want the proxy from step 1 below, and the [reminder hook](#make-your-agent-actually-use-it) is worth it β that part needs the repo.
<details>
<summary><b>Manual setup / what <code>setup.sh</code> does under the hood</b></summary>
<br>
**1. Get an OpenAI-compatible endpoint for the cheap models.** Most people run [LiteLLM](https://github.com/BerriAI/litellm) locally as a proxy in front of DeepSeek / Kimi / Qwen. A minimal config is ~5 lines:
```yaml
# litellm.yaml β exposes DeepSeek under the model_name "deepseek"
model_list:
- model_name: deepseek
litellm_params:
model: deepseek/deepseek-v4-flash # swap for any provider/model LiteLLM supports
api_key: os.environ/DEEPSEEK_API_KEY
```
```bash
pip install 'litellm[proxy]'
litellm --config litellm.yaml # serves http://localhost:4000
```
That `model_name: deepseek` lines up with Cheaplane's default alias, so it works out of the box. (`deepseek` is a built-in LiteLLM provider β no `api_base` needed; you'd add one only for a custom or self-hosted endpoint.) Already have an OpenAI-compatible endpoint (LiteLLM, OpenRouter, Ollama, vLLMβ¦)? Skip this and just point `DELEGATE_BASE_URL` at it.
**2. Install Cheaplane** β from PyPI, or from a clone if you also want the reminder hook and `probe.py`:
```bash
pip install cheaplane # installs a `cheaplane` command; that's the whole install
```
```bash
git clone https://github.com/millennialdreamer/millen-cheaplane && cd millen-cheaplane
uv sync # or: python -m venv .venv && .venv/bin/pip install mcp
```
**3. Register it with your MCP client.** Installed from PyPI β the command is already on your `PATH`:
```json
{
"mcpServers": {
"delegate": { "command": "cheaplane" }
}
}
```
From a clone β copy `.mcp.json.example` to `.mcp.json` in the repo root and fix the path (or use `claude mcp add`):
```json
{
"mcpServers": {
"delegate": {
"command": "uv",
"args": ["run", "--directory", "/ABSOLUTE/PATH/TO/cheaplane", "python", "server.py"]
}
}
}
```
**4. Verify it end-to-end** β with your proxy from step 1 running (handshake β list tools β a real delegated call):
```bash
uv run python probe.py
# β
chain works (main β MCP β cheap model β back)
```
</details>
## Using `delegate`
Your agent now has `delegate(task)` β **routing is automatic**; override only when you want to:
```text
delegate("convert this JSON to a TypeScript interface: β¦") # auto β deepseek (code)
delegate("summarize this 40-page contract: β¦") # auto β kimi (very long input)
delegate("β¦Chinese text in the task auto-routes hereβ¦") # auto β qwen (Chinese copy)
delegate("translate these UI strings to Japanese", "flash") # explicit alias still wins
```
The aliases below are the **example setup** the server ships with β a lineup that works well, not a requirement. Bring your own models and rules in [Make it yours](#make-it-yours).
| alias *(example setup)* | good for |
|---|---|
| `auto` | **default** β picks one of the below from the task itself |
| `deepseek` | code / balanced |
| `mimo` | reasoning / multi-step |
| `flash` | fast / formatting / translation |
| `kimi` | long documents (very large context) |
| `qwen` | Chinese copywriting |
Aliases map to your LiteLLM `model_name`s. Ask your agent for `list_models` to see the aliases and routing rules actually in effect.
## Make it yours
The idea is general β keep judgment on your premium model, send the churn somewhere cheaper. The model lineup above is just one example. Three knobs, none of which need a code edit:
**1. Endpoint** β any OpenAI-compatible server: LiteLLM, OpenRouter, Ollama, vLLM, a hosted provider.
```bash
export DELEGATE_BASE_URL=http://localhost:11434 # e.g. Ollama
export DELEGATE_API_KEY=... # if your endpoint wants one
```
**2. Aliases** β short names for the model names your endpoint serves. Set `DELEGATE_MODEL_MAP` (JSON), or put the same JSON in `~/.claude/delegate-model-map.json` (re-read on every call, so no restart):
```json
{"fast": "qwen3:8b", "smart": "deepseek-v4-flash", "long": "kimi-k2"}
```
**3. Routes** β what `model="auto"` picks. Put JSON in `~/.cheaplane/routes.json` (re-read on every call), or in `DELEGATE_ROUTES` (inline JSON, or a path to a JSON file):
```json
{
"rules": [
{"alias": "smart", "contains": ["```", "refactor", "stack trace", "sql"]},
{"alias": "long", "longer_than": 20000},
{"alias": "fast", "shorter_than": 800, "contains": ["translate", "format", "rename"]}
],
"default": "fast",
"notes": {"fast": "chores", "smart": "code", "long": "big documents"}
}
```
Rules are checked in order; the first one whose conditions **all** hold wins, otherwise `default`. Conditions:
| condition | matches when |
|---|---|
| `contains` | the task contains any of these substrings (case-insensitive) |
| `longer_than` / `shorter_than` | the task is longer / shorter than N characters |
| `cjk_count_over` | the task has more than N Han characters |
| `cjk_share_over` | Han characters are more than this share (0-1) of the task |
A rule with no conditions always matches. Leave out `rules` to keep the built-in ones and only change `default`; `notes` is optional and shows up in `list_models`. If the file is malformed, Cheaplane keeps the built-in rules and `list_models` tells you what was wrong.
<details>
<summary><b>What to delegate vs keep (rule of thumb)</b></summary>
<br>
**Delegate** (let the cheap model do it):
- boilerplate / scaffolding from a clear spec
- mechanical refactors, formatting, lint fixes
- translation; summarizing or extracting facts from long docs
- routine prose: changelogs, docstrings, commit messages
**Keep** (you do it yourself):
- planning, architecture, technical trade-offs
- **final review of delegated output β always you**
- talking to the user; judgment calls
- anything where being subtly wrong is expensive
The delegated model sees **only your `task` string** β it has no access to your conversation. Make each task self-contained: spec + the actual input + the exact output format you want.
</details>
## See what you saved
Every delegated call appends one line of **metadata only β never the task content** β to `~/.cheaplane/usage.jsonl`. Ask your agent for `savings` any time (sample output):
```text
Cheaplane savings β all time
delegated calls : 184
tokens offloaded: ~412,300 in / ~365,800 out
premium cost avoided (Opus list): ~$8.97
actually spent (DeepSeek-class) : ~$0.56 (β16Γ cheaper, in+out blended)
last 7 days : 31 calls, ~$1.63 avoided
```
Numbers are estimates at public list prices β the real win is the premium **quota** that never left your subscription. The ledger records token counts and model names only; delete the file any time, or set `DELEGATE_NO_LOG=1` to turn logging off entirely.
## Make your agent actually use it
Here's the dirty secret of every "delegate to a cheap model" tool: **installing it isn't the hard part β getting your agent to actually *use* it is.** Drop a tool into an agent and, a few turns into a real task, it forgets the tool exists and grinds through the grunt work itself on premium tokens. The instruction sinks down the context; attention moves on.
Cheaplane ships the fix in the box β three layers you can stack:
1. **Skill** (`SKILL.md`) β teaches the agent *when* to delegate. Works on any client; passive, so treat it as the baseline.
2. **A one-line default** in your `CLAUDE.md` / system prompt: *"Before doing replaceable grunt work yourself, delegate it."* Stronger β but a static instruction still drifts down a long conversation.
3. **A per-turn reminder hook** β the reliable one (Claude Code). It re-injects the nudge on **every** prompt, so the habit never sinks out of view. This is what turns an *installed* tool into a *used* one.
**On other MCP clients** (no `UserPromptSubmit` hook system), use layers 1β2 β wire the one-liner into whatever system prompt your client supports.
Install the hook β safe and idempotent (backs up your settings, **merges** instead of overwriting, de-dupes on re-run):
```bash
bash install-hook.sh # registers hooks/delegate-reminder.sh as a UserPromptSubmit hook
# verify it's wired up:
python3 -c "import json,os;s=json.load(open(os.path.expanduser('~/.claude/settings.json')));print([h['command'] for e in s.get('hooks',{}).get('UserPromptSubmit',[]) for h in e.get('hooks',[])])"
```
Start a fresh session, and your agent self-checks every turn: *"is this replaceable grunt work? β delegate it."*
<sub>The reminder costs ~60 tokens per turn β trivially less than the hundreds of premium tokens a single forgotten delegation burns. The hook uses Claude Code's <code>UserPromptSubmit</code> mechanism.</sub>
## Config
| Env var | Default | Meaning |
|---|---|---|
| `DELEGATE_BASE_URL` | `http://localhost:4000` | OpenAI-compatible endpoint (your proxy) |
| `DELEGATE_API_KEY` | `sk-litellm` | key for that endpoint |
| `DELEGATE_TIMEOUT` | `120` | per-call timeout (seconds) |
| `DELEGATE_MODEL_MAP` | *(none)* | JSON remapping aliases, e.g. `{"deepseek":"deepseek-v4-flash"}` β overrides defaults, no code edit |
| `DELEGATE_ROUTES` | `~/.cheaplane/routes.json` if present | routing rules for `auto`, as inline JSON or a path to a JSON file β see [Make it yours](#make-it-yours) |
| `DELEGATE_LOG` | `~/.cheaplane/usage.jsonl` | where the savings ledger lives |
| `DELEGATE_NO_LOG` | *(unset)* | set to `1` to disable the ledger entirely |
## FAQ
**Will this leak my subscription credentials?**
No. The `delegate` tool runs in its own process and only ever makes a plain HTTP call to the endpoint *you* configure. It never imports your subscription SDK and never sees its auth β see [Billing isolation](#billing-isolation-the-whole-point).
**What exactly does the savings ledger record?**
One JSON line per call: timestamp, alias, model name, and token/character counts. **Never the task text, never the model's output.** Delete `~/.cheaplane/usage.jsonl` any time, or set `DELEGATE_NO_LOG=1`.
**How does `auto` decide which model to use?**
An ordered list of deterministic rules (signal β alias); the first match wins. The built-in example: code signals β `deepseek`, very long input β `kimi`, Chinese-heavy β `qwen`, multi-step language β `mimo`, short mechanical chores β `flash`. Replace it with your own rules in `~/.cheaplane/routes.json` or `DELEGATE_ROUTES` ([Make it yours](#make-it-yours)); `list_models` shows what's active. An explicit alias always overrides it.
**How is this different from just using one API key for everything?**
With a single API key you stop using your subscription entirely and pay per token for *all* work β including the hard parts. Cheaplane keeps your subscription as the premium main thread and sends only the cheap, replaceable churn elsewhere.
**Does it work with anything besides Claude Code?**
Yes β any MCP-compatible client (Cursor, Cline, Windsurf, β¦). The main agent just needs to support MCP tools; see Manual setup for the generic JSON config.
**Do I have to use DeepSeek / Kimi / Qwen?**
No β that lineup is only the example setup. Anything reachable through an OpenAI-compatible endpoint works: name your own aliases with `DELEGATE_MODEL_MAP` and your own routing rules with `DELEGATE_ROUTES` ([Make it yours](#make-it-yours)).
**Why a proxy instead of calling providers directly?**
One endpoint, one key, usage logging, and easy model swaps β and it keeps provider keys out of the MCP server entirely.
## Roadmap & ideas (help wanted)
Cheaplane's core stays deliberately tiny β but the surface it opens up is big. Shipped so far: β
auto-routing (v0.2), β
savings ledger (v0.2), β
user-defined routing rules (v0.3). Still worth building β proposals and PRs welcome, and most are small enough to be good first issues:
- **Smarter routing** β rules are plain substring / length / script checks today; richer signals (or a learned router) are an open playground.
- **Richer savings dashboard** β the ledger is plain JSONL; a `cheaplane stats` HTML view would be lovely.
- **Result cache** β skip re-delegating identical tasks.
- **Auto-review** β lint/test code that comes back before you trust it.
- **Batch / parallel delegate** β hand off several chores in one call.
- **More client adoption recipes** β the reminder hook targets Claude Code's `UserPromptSubmit`; Cursor / Cline / others want their own nudge.
> Design rule: **keep the core single-file and dependency-light β that's the whole point.** Build extensions as opt-in, so the 5-minute read stays a 5-minute read.
## Contributing
Issues and PRs welcome β it's ~370 lines of single-file Python with no heavy deps, easy to hack on. Add a useful model alias, a routing signal, or a client recipe and send it over.
## License
MIT β see [LICENSE](LICENSE).
TDQS
Scored across 3 tools
The three tools split cleanly into discovery (list_models), action (delegate), and reporting (savings), with no overlap in what they return or when to call them. An agent can pick the right one without reading beyond the first line.
All names are lowercase snake_case, but the pattern is not uniformly verb_noun: list_models is verb_object while delegate is a bare verb and savings is a bare noun. It is still readable and predictable enough that an agent would not misguess a name.
Three tools is thin but well matched to a focused delegator: one does the work, one explains the routing aliases the work depends on, and one reports the payoff. Nothing extraneous, though the surface is small enough that any missing operation is conspicuous.
The core lifecycle (discover aliases β delegate β measure savings) is covered, but list_models exposes active auto-routing rules with no tool to view detail or modify them, and there is no way to inspect delegation history or per-call cost. These are workarounds-by-omission rather than dead ends, since the user must leave the server to change routing.