ClaudeMod
ModsDashboardsNetwork

Claude Code Mixture of Models

Keeps your Claude subscription for high-risk turns and sends the rest to a cheaper model (GLM, Kimi or any Anthropic-compatible gateway) through a child Claude Code process, with the routing decision shown on every turn.

Install· Claude Code 2.1.330+
$claude plugin marketplace add alinaqi/mixture-of-models-claude-mod
$claude plugin install mixture-of-models@mixture-of-models-claude-mod
Run claude plugin validate to auditGuide →
Access & PermissionsNetwork

Makes outbound network requests, calls MCP servers, or requests auth handles.

Network accessRuns shell commandsDrives ClaudeReads filesReads env varsReads transcriptPersists local stateDraws UI

Statically scanned from hooks & source. Learn how to audit

Ali Shaheen4 starsAdded 1 months ago

mixture-of-models-claude-mod

English · 简体中文 · 日本語 · Deutsch · Français · العربية

ci License: MIT Changelog

Setting this up with a coding agent? Point it at INSTALL.md: "Follow INSTALL.md in alinaqi/mixture-of-models-claude-mod to set up Mixture of Models for me." It has every command, a check for each step, and what to ask you. Works for Claude Code, Codex, Cursor, OpenCode, Antigravity, GitHub Copilot CLI, Aider, Continue and Goose.

Installed? GUIDELINES.md has the best practices for each agent: let the system pick the models, how to word prompts so routing and memory work, what to delegate, and what to do when a route looks wrong.

Keep your Claude subscription for the turns that need it. Hand the rest to a cheaper model. A Claude Code mod (an in-process plugin, new in Claude Code 2.1.287) that scores every prompt for blast radius and answers the low-score turns with a separate headless Claude Code on an Anthropic-compatible gateway (GLM, Kimi, DeepSeek, whatever yours serves). Your main session is never renamed, re-pointed or touched. Ported from Maggy's routing.

Routes can also name a model family: claude/sonnet runs that Claude member on your own Claude login, kimi/auto lets the score pick a Kimi member, and codex hands the turn to the Codex CLI (codex exec) on Palgu or on your ChatGPT login. See Families and Codex.

Get Palgu's models in one command

No dashboard, no copying keys. After installing the mod, in Claude Code:

/palgu login
  1. The mod shows a sign-in link and a short code, for example WDJB-MJHT.
  2. Open the link, sign in to Palgu or sign up (new accounts start on the free plan), check the code matches and press Allow. The page names the app: Allow Mixture of Models on "Claude Code on your-mac"?
  3. Back in the terminal a toast says Signed in to Palgu as you@example.com. That's it: simple and coding turns now run on Palgu's models (GLM 5.3, Kimi K3.1, DeepSeek V4 Pro, Gemini 3.8 Flash, MiniMax M3, GPT-6), and critical turns stay on Claude. No restart.
CommandWhat it does
/palgu loginSign up or sign in, and connect this computer
/palgu statusWho is signed in, the organisation and its plan, and what it spent of its Palgu budget this period
/palgu upgradePlans and billing (paid plans are bought on the web; your key picks up the new plan by itself)
/palgu continue [--open]Continue this session in Palgu with its full context: copies cd <folder> && palgu --continue-claude=<session id>; --open starts it in a new macOS Terminal tab. Palgu reads the transcript itself and redacts credentials

How it works: Palgu's device sign-in (the same one srooterctl uses) mints an API key for this computer only. You can see and revoke it on Palgu's Devices page. The mod saves it in Claude Code's secure storage with claude plugin configure --values-stdin, so it never appears on a command line or in a settings file. Already have a key, or use another gateway? See Setup.

To be precise about what it is: turn-level delegation, not per-request model mixing. A routed turn runs in a child process with a short brief of your recent context; the child's answer lands in your transcript, tagged. Critical turns stay on Claude exactly as before.

Install

Mods need Claude Code 2.1.287 or later. The stable Homebrew cask is still 2.1.286, so check first:

claude --version
# too old? one of:
brew uninstall --cask claude-code && brew install --cask claude-code@latest   # Homebrew
npm install -g @anthropic-ai/claude-code@<version>                            # npm: a version from 2.1.287 on
claude update                                                                 # native installer

Then:

claude plugin marketplace add alinaqi/mixture-of-models-claude-mod
claude plugin install mixture-of-models@mixture-of-models-claude-mod

or, inside a session, /plugin install mixture-of-models --marketplace alinaqi/mixture-of-models-claude-mod.

Your hooks do not run in the gateway child. The child runs claude -p --bare, and --bare skips every hook from your settings and plugins, so a hook that blocks .env does not guard it there, and what the child reads goes to the gateway model. The mod does not rely on hooks for this: every Claude child gets Claude Code permission deny rules, which --bare keeps, for .env and .env.* files, *.pem, *.key, id_rsa*, id_ed25519* and secrets/ folders (Read rules also cover Grep and Glob). Add your own with router.child.deny, for example ["Read(**/credentials.json)"]. Commands the child is not allowed to run still come to you as an Allow / Deny dialog. A Codex child is read-only but not covered by these rules: keep secrets out of a project you route to Codex.

Updates. At session start the mod checks GitHub for a newer version (at most every 12 hours) and, when there is one, says so once in a toast and on the band: 0.33.0 available: /route update. Run /route update: it installs the new version, and the band then says 0.33.0 installed: /reload-plugins. Third-party marketplaces do not auto-update by default. Turn it on once in /plugin → Marketplaces → mixture-of-models-claude-mod → Enable auto-update, or update by hand with claude plugin marketplace update mixture-of-models-claude-mod && claude plugin update mixture-of-models@mixture-of-models-claude-mod. A new version takes effect after /reload-plugins (or a restart).

Fastest start, on Palgu: start claude and run /palgu login. It shows a link and a code; approve it in the browser (sign up there if you are new) and the mod saves its own Palgu key and routes from that moment, no copying keys. /palgu status says who is signed in, on which plan and how much of the budget is spent, /palgu upgrade opens plans and billing.

Or give the child a gateway yourself: OpenRouter, a LiteLLM proxy, or any Anthropic-compatible endpoint that serves your model ids (tested with palgu; z.ai or Moonshot's Anthropic endpoints work the same way), see Setup. Start claude, run /route. Until a gateway is configured the mod is observe-only and changes nothing.

Design rule: the main session is never touched. It stays on your claude.ai subscription with no ANTHROPIC_BASE_URL. When a prompt is routed to GLM or Kimi, the mod answers that turn itself by running a separate, headless claude -p child whose environment alone points at the gateway (palgu). The child's output becomes the turn's answer in your transcript. Nothing about the main process, its model, its auth or its requests changes.

Per prompt the mod:

  1. Scores it on two axes with one classifier call: a 1-10 blast radius and a task kind (code | research | review | docs | data | multimodal). The score decides whether Claude is mandatory; the kind picks which cheaper model gets the rest. A local Ollama model does it for free, claude-haiku-5-5 on your plan is the fallback, then the last verdict seen. See How it decides.
  2. Applies Maggy's pre-routing rules first: use claude or execute the plan force critical; follow-ups after a child-answered turn return to the main session; go ahead, yes, or a prompt of six words or fewer while the main session is mid-task keeps it there; coding-level work stays on a mid-task main session.
  3. Delegates a routed turn to the child: claude -p --model glm-5.3 on the gateway, fed a brief over stdin with the last few exchanges of your session plus the task.
  4. Falls back to the main model for that turn if the child fails, prints nothing, or its answer fails vetting (see What a child may not do), and says so in the transcript.
  5. Shows you what ran where, on every turn. See What you see.

critical turns never start a child. They run in the main session, on the subscription, exactly as if the mod were not there.

How it decides

The classifier is asked one question: how much damage does a wrong answer do? It answers with a number, and the rubric is explicit:

ScoreMeansTier (default thresholds)
1-2lookups, grep, shell one-liners, syntax questions, reading logs, git status or diffsimple
3-4single-file edits, tests, docs, config changes, small bug fixes, scaffolding3 simple, 4 coding
5-6multi-file features, wiring services or tools together, integrations, deployments that follow a known patterncoding
7-8debugging across services, data migrations, performance work, changes that are awkward to undo7 coding, 8 critical
9-10security or auth design, architecture decisions, production incidents, anything irreversiblecritical

The prompt tells the classifier that length, the number of services named, or pasted API keys do not raise the score by themselves, which is what used to push ordinary integration work onto the main session. It also says that deep reasoning (algorithms with proofs, concurrency, performance tuning, cryptography) scores at least 7 whatever the blast radius, so hard-but-safe work stays on Claude. Move the cut-offs with router.thresholds; for example { "simple": 3, "coding": 8 } keeps everything but 9-10 off Claude.

The kind picks the model. Below critical, routes.kinds maps the task kind to a model: by default research and review go to DeepSeek V4 Pro (deepseek-v4-pro on Palgu, 1M-token context), multimodal stays on Claude, and everything else takes the tier's model (GLM). Until 0.20.0 they went to Kimi, which Palgu does not answer today (an empty response after about two minutes). Add "docs": "gpt-6.2-sol" or "data": "..." to the matrix as your gateway allows.

Models you can name. Any model id your gateway serves works in routes, routes.kinds or a pin. The mod knows these Palgu gateway models, so /route <prefix> expands to them even when no route names them: glm-5.3, kimi-k3.1-pro, kimi-k3.1-pro-highspeed, deepseek-v4-pro, gemini-3.8-flash, minimax-m3, minimax-m2.5, gpt-6.2-sol, gpt-6-luna, gpt-6.2-astra and mercury-3. The band above the prompt has a button for each of these families. kimi-k3.1-pro replaces kimi-k3; an old /route kimi-k3 pin expands to it. Gemini, MiniMax and GPT-6 are options, not defaults: /route minimax, /route gpt (GPT-6 Sol) or /route gpt/auto (Luna for simple turns, Sol for coding, Astra for critical) pins them. Inception's Mercury 3 is pin-only too: /route mercury (mercury-3 on Palgu, mercury/3 on OpenRouter).

Which Palgu models work. Tested on 2026-10-29 the way the mod runs a turn (a pinned claude -p --bare child doing a short research task with tool calls): glm-5.3, deepseek-v4-pro, gemini-3.8-flash, minimax-m3, gpt-6.2-sol, gpt-6-luna, gpt-6.2-astra, kimi-k3.1-pro, kimi-k3.1-pro-highspeed and mercury-3 pass in 19 to 46 s; minimax-m2.5 kept retrying refused commands until it ran out of turns. Kimi's earlier failures were Moonshot being overloaded (429 engine_overloaded): Claude Code retried each request ten times, so a turn took about two to three minutes to fail. The child now retries at most twice (router.child.maxRetries, default 2), so a busy provider falls back in seconds. Research and review stay on DeepSeek by default; Kimi is a pin. The child always sends x-srooter-pin: <model> to Palgu: without it Palgu routes by intent and may answer with another model (it served every model unpinned as Gemini).

When a child fails. The main model takes a routed turn only after every equivalent model has failed. On Palgu the child sends x-palgu-fallback: auto, so on an overload the gateway first walks the pinned model's own fallback chain (its fallback list, then its class). If the child still fails with an overload (429, 5xx, a timeout, no answer), the mod runs the turn again on the next equivalent: models of the same class first (from Palgu's live list), then the other healthy ones, up to router.child.fallbacks (default 3). A prompt too long for the model moves only to a larger-window model (router.child.longContext); a bad request (400, 401, 403, 404, 422) is not retried on other models. The route line says what happened: child: deepseek-v4-pro failed (429) → served by glm-5.3, or all equivalents failed: deepseek-v4-pro (429), glm-5.3 (529), …; main model answered. When Palgu's own chain served another model, the line says child: kimi-k3.1-pro → served by deepseek-v4-pro (gateway fallback), and the turn counts and is priced as that model. A child answer the mod discards (it gave up, narrated, asked you to act and so on: What a child may not do, below) walks the same way, except a HANDBACK or a request that you act.

Subagents. A subagent runs inside Claude Code on your main session's own connection, so the mod can only choose which Claude model it uses, never a gateway model. Before a built-in general-purpose subagent starts, the mod scores its task like a prompt: a simple one runs on Haiku, coding on Sonnet, a critical one keeps the main session's model. Explore runs on Haiku. The mod only ever picks a cheaper model than the main session's, and leaves alone a subagent whose model was already chosen, a plugin's or your own agent (its definition may set a model), a fork, a teammate and a workflow agent. The transcript says subagent general-purpose on haiku · simple 2/10; /route off turns it off, and router.subagents sets it per agent type.

Routing strategies: route by complexity, cost, speed, quality, or your own rules

What the classifier scores, where the tiers split and which model each tier takes is a routing strategy, one markdown file with a rubric, like a skill. Four come built in:

StrategyScoresTiers (simple / coding)Goes to
complexity (default)blast radius, as above3 / 7your routes: GLM, DeepSeek for research and review, Claude for critical
costrisk of a cheaper model being wrong; when unsure, lower4 / 8GLM, DeepSeek V4 Pro for coding, research and review, Gemini for images, Claude for critical
speedreasoning depth3 / 7Gemini 3.8 Flash, GPT-6 Sol for coding, Sonnet rather than Opus for critical
qualitystakes; when unsure, higher2 / 5GLM for lookups only, Sonnet for coding, Claude for critical

/route strategies lists them and yours, /route strategy cost switches (remembered across sessions; router.strategy in model-config.json sets a default), and the band then reads auto (cost).

Your own. Put a file in ~/.claude/mixture-of-models/strategies/<name>.md, or ask Claude to use the plugin's routing-strategy skill, which asks what you want to optimise and writes it:

---
name: frugal
description: Everything but production work goes to cheap models.
score: risk
thresholds: {"simple": 5, "coding": 8}
routes: {"simple": "glm/5.3", "coding": "deepseek/v4-pro", "critical": "claude", "kinds": {"review": "kimi/pro"}}
---
Risk: how bad a wrong answer from a cheaper model would be. When unsure, score lower.
1-5: lookups, docs, tests, single-file edits, small fixes.
6-8: multi-file features, integrations, refactors that tests cover.
9-10: security, production, data migrations, anything irreversible.

thresholds and routes are JSON on one line and optional (left out, your config's apply); the body is the rubric the classifier reads. The reply format stays " ", so tiers, families, failure memory and savings work the same. The safety rules above run first under every strategy: security work, notifications and session commands stay on Claude. A file that does not parse is skipped and named in the log; /route strategy <name> re-reads the folder, so a new file is picked up without a restart.

Families: pick a member, or let the tier pick

Any route, kind route or pin may be <family>/<member> or <family>/auto instead of a model id. A bare claude still means "the main session", exactly as before, so old configs behave the same.

FamilyMembers (alias = exact id)auto by tier (default)Runs on
claudefable = claude-fable-5-1, opus = claude-opus-5-5, sonnet = claude-sonnet-5-5, haiku = claude-haiku-5-5simple → haiku, coding → sonnet, critical → opus; fable only if you add "criticalPlus": "fable" (10/10 critical turns)a headless claude -p --model <id> child on your Claude login (no gateway); a member that is the session model stays in the main session
kimipro = kimi-k3.1-pro, highspeed = kimi-k3.1-pro-highspeedsimple → highspeed, coding and critical → prothe gateway child
glm, deepseek, gemini, minimaxfrom the gateway catalogue: glm/5.3 = glm-5.3, deepseek/v4-pro = deepseek-v4-pro, gemini/3.8-flash, minimax/m3 = minimax-m3, minimax/m2.5the first memberthe gateway child
gptsol = gpt-6.2-sol, luna = gpt-6-luna, astra = gpt-6.2-astrasimple → luna, coding → sol, critical → astrathe gateway child
codexnone by default: codex/<any model id> passes the id to Codexnone by default: Codex's own default modela codex exec child, see Codex

auto uses the same classifier, thresholds, borderline second sample and failure memory as the tiers, then looks up the tier in the family's auto map. It never leaves the family. A Claude-family tier ("critical": "claude/opus") is mandatory Claude just like "claude": routes.kinds does not override it. Override members or the tier map per family in router.families; a pinned /route claude/auto still classifies each prompt and picks the member from the score.

Why a child for a Claude member, not the session's own /model: the main session is never renamed or re-pointed (ADR 0001), so a member other than the session model runs in a separate headless Claude Code started with Claude Code's own --model <id> flag. That child runs without --bare (which would force API-key auth), so it uses your claude.ai login and loads your hooks and plugins; the mod stays inactive inside it via MAGGY_ROUTER_CHILD. Its environment clears any inherited ANTHROPIC_BASE_URL; an ANTHROPIC_API_KEY exported in your shell still wins over the login, for the child as for the main session. See ADR 0002.

Codex as a child

codex, codex/<model> and codex/auto routes, and /route codex, answer the turn with the Codex CLI in non-interactive mode:

codex exec --json -C <session cwd> [-m <model>] [Palgu provider flags] --sandbox read-only -c approval_policy="never" -

with the same brief on stdin, the same child.timeoutMs, the same vetting, failure memory, route line and provenance tag as the Claude child. router.codex.auth picks the account:

  • "palgu" (default): Codex talks to your gateway's Responses endpoint, /v1/responses. On OpenRouter and LiteLLM the provider is named openrouter or litellm, the base URL is <gateway_url>/v1 (https://openrouter.ai/api/v1, http://localhost:4000/v1; a LiteLLM /anthropic URL drops that suffix first) and the key goes in OPENROUTER_API_KEY or LITELLM_API_KEY, following OpenRouter's and LiteLLM's Codex guides. Name the model on those gateways: OpenRouter needs a full slug (/route codex/openai/gpt-5.6-terra), LiteLLM one of your model_names; Codex's own default model id is not one of them. On Palgu the mod adds an explicit palgu provider with -c model_provider="palgu", -c model_providers.palgu.base_url="<gateway>/v1", -c model_providers.palgu.wire_api="responses" and -c model_providers.palgu.env_key="PALGU_API_KEY", as Palgu's Codex docs describe (Codex ignores OPENAI_BASE_URL under a ChatGPT login, so the provider must be explicit). The base URL is your gateway_url with /anthropic replaced by /v1, or router.codex.baseUrl. Your gateway key goes only into the child's environment as PALGU_API_KEY, never on the command line, never printed. Needs the gateway URL and key, like the Claude gateway child.
  • "chatgpt": no provider flags and no key: Codex uses your own codex login and ~/.codex/config.toml. The mod never reads or writes ~/.codex.

Sandbox and approvals

codex exec cannot ask anyone anything: in non-interactive mode Codex runs with approval policy Never (Codex 0.163 rejects approval_policy = "untrusted" outright), so a command its sandbox allows runs without a question, and one it does not is refused. The sandbox is therefore the only gate, and the mod keeps it narrow:

  • router.codex.sandbox is "read-only" by default: Codex can read the project and run commands that only read; it cannot edit files or use the network. That is narrower than the Claude child (acceptEdits), because codex exec has no way to let edits through while still gating commands. -c approval_policy="never" is passed explicitly, so a request to escalate out of the sandbox is refused, never run.
  • Opting out, at your own risk: "workspace-write" lets Codex edit files in the project and run any command there without asking you (network stays off: -c sandbox_workspace_write.network_access=false). "danger-full-access" removes the sandbox entirely; only use it in a disposable, externally sandboxed environment. Any other value means read-only.
  • router.codex.allowOutsideGit (default false) adds --skip-git-repo-check. Without it Codex refuses to start outside a git repository, the route line says child answer discarded (outside a git repo; set router.codex.allowOutsideGit), and the main model answers.
  • router.codex.args adds flags (for example -c model_reasoning_effort="high"), but never the sandbox or approval: --sandbox/-s, --dangerously-bypass-approvals-and-sandbox, --approve-for-me, --full-auto, --add-dir, --skip-git-repo-check, -a/--ask-for-approval and -c approval_policy=…/sandbox_mode=…/sandbox_workspace_write.…/sandbox_permissions=… are dropped, and the session log names what was ignored. --ephemeral there also disables the resume below.

Refused commands. codex exec --json does not report a command its sandbox blocked, nor an escalation it refused: neither appears as an event (checked against Codex 0.163.0). So the brief tells Codex to end its answer with NEEDS-APPROVAL: <exact command> for each command the sandbox blocked, and the mod also counts the reject command lines Codex writes to stderr for refused escalations. Then, as for the Claude child:

  • With the read-only default, the mod asks you with the same dialog, naming the commands and what approving allows: "Codex child on codex/default was refused by its read-only sandbox: touch made.txt. Allow and continue resumes it for this turn with permission to edit files in the project and run commands there (no network)." On Allow and continue the same thread resumes (codex exec -C <cwd> resume --json … -c sandbox_mode="workspace-write" -c approval_policy="never" -c sandbox_workspace_write.network_access=false <thread> -) with a message naming the approved commands. That widens the sandbox for the rest of that turn, not just for the named commands, which is why the question says so. It is asked at most once per turn (child.relayRounds: 0 turns it off).
  • On Deny, when nobody can answer, or when your sandbox is already wider than read-only, nothing is widened and the refusal is never silent: the answer ends with a line naming the refused commands (Codex's sandbox refused, and nothing ran: touch made.txt.) and the route line shows · sandbox read-only · refused: touch made.txt (or refused: 2 unnamed for escalations Codex did not name).
  • Because the refusal report comes from Codex's own answer, a model that ignores the instruction can still leave a refusal unnamed. The route line always shows the sandbox the turn ran in (sandbox read-only, or sandbox workspace-write (approved)), so a turn that could not write is visible as such.

If codex is not on PATH the mod says codex is not installed: npm install -g @openai/codex (or brew install --cask codex) …, the route line says child answer discarded (codex not installed), and the main model answers.

Borderline scores get a second opinion. A score on the coding cut-off or one above it is sampled a second time and the higher wins, so a 7-or-8 debugging task doesn't flip tiers on classifier noise.

It remembers failures. Every two child failures for a kind lower that kind's coding cut-off by one (never below simple + 1), so work the cheap model keeps failing at drifts back to Claude. /route reset clears the memory.

It protects the thread of work. A child has no memory beyond its brief, so the mod never lets a follow-up land on one. After a child-answered turn, continue, yes or any prompt of six words or fewer goes back to the main session, which holds the whole transcript. And while the main session is mid-task (its last answer used tools), coding-level work stays with it (via mid-task guard on the route line); only lookups and new, self-contained tasks go out. Without these rules a session that had routed a task would restart it on every "continue".

Some turns never leave the main session, whatever the score or /route pin, because a child cannot see the conversation, teammates, background tasks or the session's tools (via notification, via session command, via security or verdict on the route line):

  • notifications: <teammate-message …>, idle_notification JSON, <task-notification>, [SYSTEM NOTIFICATION …];
  • short operator commands about session state or tools (12 words or fewer): approve git pull --ff-only, continue, resume, merge it, check the sub agents, what's the status, anything naming a PR, branch, CI, workflow or sub-agent;
  • security and verdict turns (security, vulnerability, CVE, verdict, …).

What a child may not do

Every brief opens with a preamble: the child has no access to the main session, must never invent statuses, IDs, PR numbers, run results or file changes, must never ask you to approve or run anything, and replies HANDBACK when the task needs the session's state or tools. The mod then vets the answer and discards it, letting the main model do the turn itself, when it:

AnswerExample
starts with HANDBACKHANDBACK / needs the PR list
apologizes and gives up, or hands the work back to you"I'm sorry, but I don't have permission…", "could you please review the repository? Once that's done, we can continue"
talks about you to someone else instead of answering"The user can type "continue" or give the next instruction"
says it is blocked or asks you to act"blocked by the permission system", "you must approve it in the UI", "run gh pr create yourself"
claims an action or session fact with no tool call (num_turns 1)"I added X", "PR #812 is open", "14 commits behind", "no build runs exist"
is mostly narration of intent"I'll read the config. Then I will update the router."
repeats an answer already giventhe same verdict re-posted on every idle notification

A discarded answer counts as a child failure for that kind and shows as child answer discarded (<reason>), main model answered on the route line. The main model is never asked to relay a child's text: the mod answers the turn with a vetted child answer, or leaves the turn to the main model.

A discarded answer is first tried on the next equivalent model, as an overload is (When a child fails, above), and the route line says child: glm-5.3 failed (gave up) → served by deepseek-v4-pro. Two are not: HANDBACK, where the child asked for the main session, and a request that you act, which any model would meet alike; the main model takes those at once.

Every route line and the band show the score and the kind, so when a decision looks wrong you can see the numbers behind it.

What you see

Claude and the gateway are both visible, all the time:

SurfaceMain-session turnRouted turn
Band above the promptmixture-of-models · auto · last: claude-opus-5 · critical 9/10
0: help 1: auto 2: glm 3: deepseek … 9: claude off
… · running glm-5.3 in a child… while it runs
SpinnerThinking…Thinking · via glm-5.3 (child)…
Question dialogClaude's own questionsChild on glm-5.3 wants to run: Bash(git pull --ff-only) with Allow and continue / Deny
Reply in the transcriptunchanged (or tagged ⇢ claude-opus-5 · main session with ui.tags: "all")a dim ⇢ glm-5.3 · child on gateway line above the reply, kept in scrollback (· child on your Claude subscription for a Claude member, · Codex child for Codex)
Line under the answerroute: claude-opus-5 · main session · critical 9/10 via claude-haiku-5-5 · 23.1k in / 0.9k out · cache 91% · today: 8 turns, 5 off Claude (63%)route: glm-5.3 · coding 6/10 via ollama · child 42s · saved ~$0.39 · today: …
/routemixture-of-models live · mode auto · current route: … · today: … · saved ~$12.40 on 48 routed turns (82% of their Claude price) · 61% of all spend ($20.33) vs all claude-opus-5-5, at API pricessame
/palgu loginOpen https://www.palgu.ai/connect?code=WDJB-MJHT and approve code WDJB-MJHT …, then a toast Signed in to Palgu as you@acme.com (Acme, plan starter). Routed turns now run on Palgu.same
/route statsA pane, "Mixture of models", with four tabs on hotkeys m, k, s and r (click the pane first; a bare digit in an empty prompt presses the band's buttons): models (bars per model, share of turns, the headline "N of M turns off Claude" and, in green, what routing saved), kinds (each kind and which models took it), scores (a 1-10 histogram coloured by tier, cut-offs marked), recent (the last decisions with score, kind, model and child time). Esc closes it.same
/route usage (today, week, month, all)Models used, last 7 days: 42 turns, 30 off Claude (71%), then one line per model with its share and a bar, the models your subagents ran on, and the savingssame
/route stats resetstats reset: model counts, decision log, savings and subagent counts start again from nowsame

How much it saves

Every routed turn is priced twice: at your session's Claude model (what the same tokens would have cost there) and at what it actually cost. On Palgu, the actual cost comes from Palgu's own /v1/pricing/quote, the formula it bills by; on another gateway, from router.prices; a claude/<member> child is priced at that member's Claude rate. Turns that stay in the main session count toward the all-Claude total too, so the percentage is the share of your whole Claude bill that routing took away, not just of the routed turns.

  • Under each routed answer: · saved ~$0.39.
  • /route status: saved ~$12.40 on 48 routed turns (82% of their Claude price) · 61% of all spend ($20.33) vs all claude-opus-5-5, at API prices, a running total across sessions.
  • /route stats: the same total, in green, on the models tab.

In our own use, coding agents running around the clock used up a Claude Max 20x subscription's weekly limit in about three days on Claude alone; with Mixture of Models the same subscription lasted the full seven days. See GUIDELINES.md.

It is an estimate, and it says so. Claude prices are the API list prices (Opus 5.5 $4 / $20 per million input / output tokens, Sonnet 5.5 $2 / $10, Haiku 5.5 $0.10 / $0.50, Fable 5.1 $10 / $50; cache reads and 5-minute and 1-hour cache writes at their own rates), so on a claude.ai subscription it is the API-equivalent saving, not money back. It assumes the routed turn would have used the same number of tokens on Claude. A routed turn the mod cannot price (a gateway with no router.prices entry for that model, or a Codex child) claims no saving; /route status counts it as unpriced.

The band's buttons have digit hotkeys: with an empty prompt, type 3 and pause to pin Kimi, 1 to go back to auto, 0 for help: a pane that says what the mod does, where it stands (mode, gateway, savings), what every button and command does, and how to connect Palgu, OpenRouter or LiteLLM. /route help opens it too. Turn the band off with "ui": { "band": false }.

Other coding agents

The mod runs inside Claude Code. For other agents, the mom CLI and a thin adapter per tool bring the same pieces: Palgu picks the model per request, Palgu memory is recalled into each prompt, and a turn that stops mid-task is continued (ADR 0005).

npm install -g github:alinaqi/mixture-of-models-claude-mod   # installs `mom` and every agent's plugin files
mom login                                                     # sign in to Palgu in the browser

Then, for your agent:

# Codex
mom setup codex --write && codex plugin marketplace add alinaqi/mixture-of-models-claude-mod && codex plugin add mixture-of-models@mixture-of-models
codex -p palgu

# Cursor (in the project folder; then Developer: Reload Window)
mom setup cursor --write

# OpenCode
mom setup opencode --write

# Antigravity
agy plugin install "$(npm root -g)/mixture-of-models-claude-mod/integrations/antigravity"

# GitHub Copilot CLI
copilot plugin install alinaqi/mixture-of-models-claude-mod:integrations/copilot

Optional, per project, uploads its source to Palgu: mom memory on. Every command, with checks and troubleshooting: INSTALL.md. How to get the most out of each agent: GUIDELINES.md.

AgentStatusGuide
Codex (CLI, 0.163+)Plugin: memory recall, heartbeat, indexing; codex -p palgu routes through Palguintegrations/codex
CursorPlugin (or mom setup cursor): MCP server for Palgu memory search and delegation to Palgu models (mom mcp), heartbeat and indexing through hooks, a rule for when to delegate. No per-turn routing: Cursor's hooks cannot change the modelintegrations/cursor
OpenCode (1.19+)Plugin with full parity: per-request Palgu model (auto, /route pin, or your tier routes), memory recall, heartbeat, indexing, /route and /palgu; mom setup opencode --write adds the providerintegrations/opencode
Antigravity (agy 1.0.7+)Plugin: memory recall into the first model call of each turn, heartbeat, indexing, Palgu tools over MCP (palgu_delegate for routed subtasks). Its hooks cannot change the modelintegrations/antigravity
GitHub Copilot CLI (1.0.112+)Plugin: heartbeat, indexing, Palgu tools over MCP (memory search, palgu_delegate), a skill for when to use them. Its hooks cannot change the model or add to a promptintegrations/copilot
Aider, Continue, GoosePalgu routes (model: auto); no hooks, so no memory recall or heartbeat. Aider checked liveintegrations/gateway

Palgu memory consent (mom memory on) is per project folder and shared by every agent that uses mom. It is separate from the mod's /palgu memory on.

Requirements

  • Claude Code v2.1.287 or later (claude --version). Mods do not load on older builds; claude update.
  • A gateway the child can use: Palgu's Anthropic endpoint, OpenRouter, a LiteLLM proxy, or any Anthropic-compatible endpoint that serves the model ids in routes, with its key.
  • Optional: Ollama with a small model for free classification (ollama pull qwen2.5-coder:3b). Without it the classifier falls back to Haiku on your plan.

Setup

See GETTING_STARTED.md for the full walkthrough, or ./install.sh.

  1. Give the child its gateway. On Palgu, /palgu login does this whole step: it uses Palgu's device sign-in (the same one srooterctl uses), Palgu mints a key for this computer that you can revoke on its Devices page, and the mod saves the URL and the key with claude plugin configure --values-stdin. Otherwise the plugin asks for two values, and the key is masked and kept in Claude Code's secure storage, never in a settings file:

    /plugin configure mixture-of-models@mixture-of-models-claude-mod
    

    or from the shell: run claude plugin configure mixture-of-models@mixture-of-models-claude-mod --values-stdin, type {"gateway_url":"https://api.palgu.ai/anthropic","gateway_key":"<your key>"} on its input and press Ctrl-D, so the key stays out of your shell history and process list.

  2. Optionally tune routes, thresholds and the child in ~/.claude/model-config.json; config.example.json in the repo is a complete starting point (also shown below).

  3. Start claude and run /route.

Until a gateway URL and key are present the mod is observe-only: it classifies and /route shows what it would do, but no child starts.

The third option, gateway_provider, says what kind of gateway it is: auto (the default, also when empty) detects Palgu (*.palgu.ai) and OpenRouter (openrouter.ai) from the URL and treats any other host as a generic Anthropic-compatible gateway, exactly as before 0.16; palgu, openrouter, litellm or anthropic-compatible name it outright. The provider decides how the child sends the key and which model ids the default routes and the band use:

ProviderChild authDefault model idsx-srooter-* headers
palguANTHROPIC_API_KEY (x-api-key)Palgu's: glm-5.3, deepseek-v4-pro, …yes
openrouterANTHROPIC_AUTH_TOKEN (Authorization: Bearer)OpenRouter slugs behind the families: glm/5.3 → z-ai/glm-5.3, …no
litellmANTHROPIC_AUTH_TOKEN (Authorization: Bearer)Palgu's names; your proxy's model_names decideno
anthropic-compatibleANTHROPIC_API_KEY (x-api-key)Palgu'syes

Whichever variable carries the key, the child's environment sets the other one to empty, because the child inherits your shell and Claude Code sends both when both are set: an ANTHROPIC_API_KEY exported in your shell never rides along to OpenRouter, and a stray ANTHROPIC_AUTH_TOKEN never reaches Palgu. The key is never on a command line.

OpenRouter

  1. Create a key at openrouter.ai/keys.

  2. /plugin configure mixture-of-models@mixture-of-models-claude-mod with

    OptionValue
    gateway_urlhttps://openrouter.ai/api
    gateway_keyyour OpenRouter key (sk-or-…)
    gateway_providerauto (or openrouter)

    or from the shell: run claude plugin configure mixture-of-models@mixture-of-models-claude-mod --values-stdin, type {"gateway_url":"https://openrouter.ai/api","gateway_key":"<your key>","gateway_provider":"openrouter"} on its input and press Ctrl-D, so the key stays out of your shell history.

  3. Start claude. Simple and coding turns run on z-ai/glm-5.3, research and review on moonshotai/kimi-k3.1-pro; the band offers glm, kimi, deepseek (deepseek/deepseek-v4-pro), gemini (google/gemini-3.8-flash), minimax (minimax/minimax-m3, minimax/minimax-m3.1-flash), gpt (openai/gpt-6-sol, -luna, -astra) and mercury (inception/mercury-3). With eleven buttons the last has no number key; click it or Tab to it. These are the slugs OpenRouter's model list served on 2026-10-29. OpenRouter has no Kimi highspeed variant, so kimi/auto is pro for every tier.

Routes on OpenRouter name family members (glm/5.3), because an OpenRouter slug has a / in it; a slug that a family lists (z-ai/glm-5.3) works too. For another OpenRouter model, add it to a family and route to it:

{ "router": {
    "families": { "glm": { "members": { "4.6": "z-ai/glm-4.6" } } },
    "routes":   { "simple": "glm/4.6" } } }

As OpenRouter's Claude Code guide says, Claude Code is only guaranteed to work with Anthropic's own models; a routed turn whose model cannot handle Claude Code's tools fails, and the main model answers it.

LiteLLM

A LiteLLM proxy serves its Anthropic-compatible /v1/messages on its own address. It runs on your host, so it is never detected: name it.

OptionValue
gateway_urlyour proxy, for example http://localhost:4000 (or its /anthropic pass-through, http://localhost:4000/anthropic)
gateway_keythe proxy's master key or a virtual key (sk-…)
gateway_providerlitellm

The child sends the key as Authorization: Bearer. Model names are whatever model_names your proxy's config.yaml defines. The defaults are Palgu's names (glm-5.3, kimi-k3.1-pro, …): name your proxy's models the same, or point the routes at yours:

{ "router": {
    "routes":   { "simple": "my-glm", "coding": "my-glm", "kinds": { "research": "my-kimi", "review": "my-kimi" } },
    "families": { "glm": { "members": { "mine": "my-glm" } } } } }

A virtual key reaches only the models it is allowed; a 401 or an unknown model makes the child fail, and the main model answers.

Security and data use

Network hosts this plugin contacts

  • https://api.palgu.ai — Palgu, fixed in the code: /auth/device/code and /auth/token on /palgu login, /me and /me/org-settings on /palgu status, /v1/models/health at session start, after /palgu login and on /route models (the gateway key as x-api-key; nothing else is sent), /v1/pricing/quote after a routed turn when your gateway is Palgu and router.prices has no entry for the model, /anthropic/heartbeat when the main session ends a turn (the heartbeat, below), and /v1/cortex/search on each prompt of yours in a project where you ran /palgu memory on (Palgu memory recall, below).
  • https://raw.githubusercontent.com — at session start (at most every 12 hours, in the background) and on /route update: a GET of /alinaqi/mixture-of-models-claude-mod/main/.claude-plugin/plugin.json to read the published version. Nothing is sent.
  • http://localhost:11434 — a local Ollama (/api/chat) that scores each prompt. It stays on your machine; skipped when nothing answers there.
  • Anthropic, through Claude Code's own $.model.classify on your own plan — only when Ollama does not answer, to score the prompt.
  • The gateway URL you set in plugin settings (gateway_url, for example https://api.palgu.ai/anthropic, https://openrouter.ai/api or your LiteLLM proxy). The user can set a custom gateway URL in plugin settings; only that URL is contacted for routed turns, and it is the child process, not the mod, that contacts it. A Codex child uses that gateway's /v1 (or the router.codex.baseUrl you set), or OpenAI on your own Codex login with codex.auth: "chatgpt". A claude/<member> child uses Anthropic on your own Claude login.

Data the plugin sends

  • Conversation messages (session.messages): the prompt plus the last router.child.contextMessages messages (default 12) that have text, each cut to 1,200 characters, with the names of the tools they used. They are written to the child's stdin, and the child sends them to the gateway URL above (or to Anthropic or Codex for those routes) to get the model's answer. Sent only on a routed turn: one the score, or your /route pin, sends away from the main session. Critical, security, notification and operator turns are never routed themselves, but a later routed turn's context can include their recent text, because the context is the last messages with text whatever their route. While it works, the child's own agent loop also sends what its tools read in the project, under the deny rules in What a child may not do.
  • The prompt text and the scoring rubric: to the local Ollama, or to Anthropic through $.model.classify, for every prompt that reaches classification.
  • Local file contents (fs.read): ~/.claude/model-config.json (your settings; never sent) and ~/.claude/mixture-of-models/strategies/*.md (your routing strategies; the rubric of the active strategy is part of the scoring prompt, so it goes to Ollama or Anthropic as above). The mod reads no project files itself.
  • To Palgu: on /palgu login the client id mixture-of-models, the device name Claude Code on <HOSTNAME>, the mod's version, a random install id and the device code; on /palgu status the gateway key as a Bearer header; for a price quote the model id, four token counts and the key. No prompt or answer text.
  • To Palgu, the heartbeat: when the main session finishes an answer and your gateway is Palgu (and router.heartbeat is not local or off), the last 600 characters of that answer, a session id (the install id and the prompt's number) and the key as x-api-key. Palgu says whether the turn stopped mid-task. Nothing else from the conversation.
  • To Palgu, through the palgu CLI and only after you run /palgu memory on: the project's source files, for Palgu memory (see Programs). palgu uses its own sign-in.
  • To Palgu, Palgu memory recall, only in a project folder where you ran /palgu memory on and while the mod is signed in to Palgu: each prompt of yours of four words or more (on one line, at most 300 characters; not slash commands), the project's Palgu name and the key as a Bearer header, to /v1/cortex/search. What comes back (at most 8 one-line pointers: recorded intent and ADRs, docs, code symbols with their files; at most 2,000 characters) is added beside your prompt for the main session and to the brief of a routed child (Claude, a Palgu model or Codex), so every model that answers sees the same memory. A search that fails or takes over 3 s adds nothing and never holds up the prompt.
  • To a Palgu or generic gateway, the child's identifying headers: x-srooter-client (mod name and version), x-srooter-project (the session folder's name, slugged) and, on Palgu, x-srooter-pin (the routed model id). See Headers the child sends. A child with a routed model also sends x-palgu-fallback: auto.
  • No other data is sent. No telemetry. No analytics.

Programs the plugin runs

Each $.process.run call has its program and fixed flags written as literal text at the call. No shell runs any of them.

  • claude -p --model <model> --output-format stream-json --verbose --max-turns <n> --add-dir <cwd> <child.args> --disallowedTools <deny rules> — Claude Code itself, headless, to run a routed turn on the gateway or on your Claude login (claude/<member> routes). Dynamic arguments: the model id (from your routes or pin; refused unless it is one plain id of letters, digits and . _ : / @ [ ] -, not starting with -, at most 200 characters), the turn limit and child.args/router.child.deny from your model-config.json, and the session's working directory; each is refused if it is not a plain string or holds a NUL. After you approve commands the child was refused, the same call adds --resume <its session id> --allowedTools <the patterns you approved>.
  • codex exec --json … -, and codex exec -C <cwd> resume --json … <thread id> - after you approve refused commands — the Codex CLI, for codex routes only, with the same checks (the thread id as a plain id).
  • claude plugin configure mixture-of-models@mixture-of-models-claude-mod --values-stdin — once after /palgu login, to save the key Palgu minted in Claude Code's secure storage. Every argument is fixed text; the key goes on stdin only, and only after it is checked to be one plain token (A-Z a-z 0-9 . _ -, 8 to 512 characters).
  • claude plugin marketplace update mixture-of-models-claude-mod, then claude plugin update mixture-of-models@mixture-of-models-claude-mod — on /route update, only when GitHub lists a newer version. Every argument is fixed text.
  • palgu memory index . (in the session folder, in the background, at most every 10 minutes per project) and palgu memory status . --json — the Palgu CLI, only in a project folder where you ran /palgu memory on and while the mod is signed in to Palgu. Every argument is fixed text. palgu signs in with its own key (palgu login); the mod passes it no key, environment or stdin. Indexing uploads the project's source files to Palgu, which is why it is off until you turn it on.
  • The plugin never runs commands received from the network. Network response

Details

Author
@alinaqi
GitHub Stars
4
Sub-category
Dashboards
License
MIT
Surfaces
terminal
Added
1 months ago
Last synced
today
Events hooked
session.startprompt.submitturn.startturn.stepturn.completeui.rendercommand.run

Weekly Mods Digest

Top new Claude Code mods and install commands, once a week. No fluff, unsubscribe anytime.

More Mods

Claude Flightdeck
ModsSecurity

Claude Flightdeck

Live agent dashboard pane with context consumption, advisor timeline, permission verdicts, and subagent swimlanes.

Reads Files
by Sam Casella
GitHub
ModsInterface

Terminal Browser

Browse documentation, GitHub pull requests, and web pages in a split terminal pane directly beside your Claude Code conversation.

Network
by Zenbu Labs
GitHub
Agent Flow
ModsAutomation

Agent Flow

Interactive visual tree of the active session's subagents, background tasks, and teammates beside the transcript via /flow.

UI Only
by Charlie
GitHub

Command Palette

Search for a command to run...