Model Router logo

Model Router

Organization
UitbreidenOS
model-router

Select optimal Claude model tier (Haiku/Sonnet/Opus) for any task using Mixture of Experts routing — 5 modes including tier classification, cascade escalation, parallel expert panel, domain routing, and budget governance

Overview

PublisherUitbreidenOS
RepositoryUitKit
Skill namemodel-router
Stars
14
Forks
5
Bundled files
Instructions only
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by UitbreidenOS on GitHub. Read the source before you install it.

Installation

Install the Model Router AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/UitbreidenOS/UitKit/tree/main/plugins/uitkit-ai-engineering/skills/model-router
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/UitbreidenOS/UitKit.git /tmp/UitKit
mkdir -p .claude/skills
cp -r /tmp/UitKit/plugins/uitkit-ai-engineering/skills/model-router .claude/skills/model-router
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Model Router in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Model Router on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Model Router is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Model Router — Mixture of Experts Routing

When to activate

  • User asks which Claude model to use for a task ("should I use Opus or Haiku?")
  • Optimizing cost by routing to the cheapest capable model tier
  • Building a multi-agent workflow and need to assign model tiers to subtasks
  • User mentions "MoE", "model routing", "tier selection", "cost optimization", "smart model selection"
  • Debugging a workflow where wrong model was selected for a task
  • Understanding Haiku/Sonnet/Opus capability boundaries and when to switch between them
  • Session has token budget constraints and needs dynamic routing

When NOT to use

  • Model is already explicitly specified by the user (no routing needed)
  • Single short interactive conversation where overhead exceeds benefit
  • Task is clearly Opus-only (security architecture review, threat modeling) — skip routing
  • Quality is only concern and cost is unlimited — default to Opus
  • User is asking general questions about Claude's capabilities (not task-specific routing)

Instructions

Routing Mode 1: Tier Router (Task Classification)

Analyzes task text for complexity signals — keywords, word count, domain hints.

Tier assignment logic:

  • Opus tier activated by keywords: architect, architecture, security, threat, exploit, vulnerability, design system, reasoning, planning, explore, critique, ambiguous, tradeoff, evaluate options, decide, strategy, complex decision, deep dive, analysis
  • Haiku tier activated by keywords: format, lint, rename, translate, classify, extract, boilerplate, generate stub, template, sort, list, summarize short, count, convert, reformat, cleanup, validation, parsing, simple task
  • Sonnet tier is default fallback for general-purpose work (coding, refactoring, writing, orchestration)

Confidence scoring: Higher confidence (0.7+) when multiple keywords match. Lower confidence (0.4) when task description is vague or very short.

When to use: Quick, automatic tier selection when you need to route immediately without complex reasoning.

Routing Mode 2: Cascade Escalator (Progressive Refinement)

Starts with the cheapest capable model, escalates to higher tiers only when confidence is insufficient.

Flow:

  1. Initial classification yields a tier + confidence score
  2. If confidence < threshold (default 0.65), escalate one tier up (Haiku → Sonnet → Opus)
  3. Stop at Opus or when confidence threshold is met
  4. Max escalations default to 2 (prevents runaway escalation)

When to use: Uncertain task boundaries where you'd rather start cheap and escalate as needed. Balances cost with safety.

Configuration:

  • --confidence-threshold: Re-classify at higher tier if below this (default 0.65)
  • Max escalations capped at 2

Routing Mode 3: Parallel Expert Panel (Multi-Model Voting)

Runs the same task prompt against all 3 model tiers simultaneously, aggregates results via voting.

Voting strategies:

  • Majority: Tier chosen by most experts wins (e.g., 2/3 vote for Sonnet)
  • Confidence-weighted: Score each tier by average confidence; highest-confidence tier wins
  • Synthesis: Return all 3 results for an external judge model (Sonnet) to synthesize consensus

When to use: High-stakes decisions (security designs, architecture choices) where you want consensus from diverse model strengths. Costs 3x more upfront but reduces escalation/retry risk.

Routing Mode 4: Domain Expert Router (Path-Based Routing)

Routes by file paths and task domain, without inspecting task text deeply.

Domain rules (checked in priority order):

Path PatternDomainTierReasoning
security/, auth, credentials, secrets, corsSecurityOpusHigh stakes, exploit-adjacent
architecture/, .yaml, .yml, .tfInfra/ArchitectureOpusSystem design decisions
data/, ml/, .pyData/MLSonnetComplex but not architectural
.ts, .tsx, .js, .jsxSource CodeSonnetCoding work, balanced reasoning
.md, .txtDocumentationHaikuText formatting only
(no paths provided)Task classificationPer Tier RouterFalls back to keyword analysis

When to use: Codebases with clear domain structure. Automatic routing with zero inspection overhead. Ideal for high-volume pipelines.

Routing Mode 5: Budget Governor (Token Ratio Thresholds)

Dynamically routes based on remaining token budget as a percentage of total session budget.

Thresholds:

  • If remaining / total < 15%: Force Haiku (conservation mode; preserve tokens for critical tasks)
  • If remaining / total >= 50% AND task classified as Opus: Use Opus (budget permissive)
  • Otherwise: Use Tier Router classification

Budget ratio thresholds:

  • Below 15%: "budget critical" → Haiku only
  • 15–50%: "moderate budget" → Sonnet or Haiku
  • 50%+: "budget healthy" → Any tier permitted

When to use: Long-running sessions with fixed token caps. Ensures you won't run out of tokens mid-session by auto-downgrading complexity under budget pressure.

Configuration:

  • totalBudget: Session token budget (default 100000)
  • opusThreshold: Use Opus only if >= 50% remains (default 0.5)
  • haikuThreshold: Force Haiku if < 15% remains (default 0.15)

Using the CLI

Classify a task:

bash
uitkit moe classify "format the JSON output"
# → Tier: HAIKU, Confidence: 85%, Reasoning: 2 haiku keywords detected

Show escalation path:

bash
uitkit moe cascade "design a distributed system" --confidence-threshold=0.7
# → Original Tier: SONNET, Escalations: 1, Final Tier: OPUS

Get expert panel vote:

bash
uitkit moe panel "review this code" --strategy=majority
# Shows Haiku, Sonnet, Opus opinions + voting consensus

Route by file domain:

bash
uitkit moe domain "src/security/auth.ts,src/security/jwt.ts" "security audit"
# → Domain: security, Routed Tier: OPUS

Budget-aware routing:

bash
uitkit moe budget "write unit tests" --remaining 25000 --total 100000
# → Budget Ratio: 25%, Routed Tier: SONNET (below 50% threshold but above 15%)

System status:

bash
uitkit moe status
# Prints active routing modes, thresholds, tier costs

Programmatic Usage

javascript
import MoeRouter, { classifyTask, routeByDomain, budgetGovernedRouter } from './lib/moe-router.js';

// Tier Router
const result = classifyTask('design a microservices architecture');
console.log(result.tier, result.confidence);  // claude-opus-4-7, 0.85

// Domain Router
const domainRoute = routeByDomain(['src/security/auth.ts'], 'refactor');
console.log(domainRoute.tier);  // claude-opus-4-7

// Budget Governor
const governor = budgetGovernedRouter({ totalBudget: 50000 });
const budgetRoute = governor.route('write tests', 7500);  // 15% remaining
console.log(budgetRoute.tier);  // claude-haiku-4-5 (forced)

Example

Scenario: Task is "refactor the authentication module in src/security/auth.ts". Session has 60,000 tokens remaining out of 100,000 total.

Tier Router analyzes: Keyword "refactor" suggests Sonnet → confidence 0.62

Domain Router checks: File path contains "security/" → Opus candidate → confidence high

Budget Governor sees: 60% budget remaining >= 50% threshold → Opus allowed

Decision: Domain signal overrides tier signal. Security files always route to Opus for maximum scrutiny.

Final Selection: claude-opus-4-7

CLI command:

bash
uitkit moe domain "src/security/auth.ts" "refactor the authentication module"
# → Detected Domain: security
# → Routed Tier: OPUS
# → Reasoning: security-sensitive file detected

Budget impact: At 60% budget remaining, this Opus task is acceptable. If budget had been 12% remaining, Budget Governor would force Haiku instead despite security domain (conservation mode).


Tier Reference

ModelCostSpeedReasoningWhen to Use
Haiku1xFastestLimited reasoningFormatting, classification, templating, boilerplate, simple extraction
Sonnet12xFastGood reasoningGeneral coding, refactoring, documentation, orchestration, reviews
Opus300xModerateDeep reasoningArchitecture, security, ambiguous decisions, threat modeling, complex planning

Cost note: Choosing Haiku over Opus saves ~300x on tokens for simple tasks. Cascade Escalator prevents overpaying for easy work while protecting against under-speccing hard problems.

Frequently asked questions

What does the Model Router AI skill do?

Select optimal Claude model tier (Haiku/Sonnet/Opus) for any task using Mixture of Experts routing — 5 modes including tier classification, cascade escalation, parallel expert panel, domain routing, and budget governance

Why use Model Router on TypingMind?

Because you install it once and use it with any model. Model Router is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Model Router in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/UitbreidenOS/UitKit/tree/main/plugins/uitkit-ai-engineering/skills/model-router. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Model Router?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Model Router?

As many as you like. As long as a model supports skills, you can use Model Router with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Model Router AI skill free?

It is published on GitHub by UitbreidenOS. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇