← Back to Skills Marketplace
yuldrone

Ai Model Router

by yuldrone · GitHub ↗ · v2.0.0 · MIT-0
cross-platform ✓ Security Clean
354
Downloads
0
Stars
1
Active Installs
3
Versions
Install in OpenClaw
/install ai-model-router
Description
Automatically routes requests between two configured AI models based on task complexity, privacy needs, and user preferences for optimized AI usage.
README (SKILL.md)

AI Model Router

Compact, intelligent model routing that just works.

Quick Start

# Install
npx clawhub@latest install ai-model-router

# First run - auto-detects your models
python3 skill/core/router.py "What is Python?"

# List available models
python3 skill/core/router.py --list

How It Works

Your Request → Analyze → Select Model
                          ↓
                    Simple? → Primary (fast/cheap)
                    Complex? → Secondary (capable)
                    Private? → Primary (forced)

Scoring (from model-router-premium)

Pattern Points
Microservices, architecture +10
Design, implement, optimize +5
Explain, analyze, compare +3
Syntax, example, "what is" -3

Threshold: 5 (simple vs complex)

Features

Feature Status
Auto-detect local models ✓ (Ollama, LM Studio)
Cloud model registry ✓ (7 built-in)
Privacy detection ✓ (API keys, passwords)
Context tracking ✓ (conversations)
JSON config ✓ (optional)
CLI interface
Core code size ~200 lines

CLI

# Route a task
python3 skill/core/router.py "Design a system"
python3 skill/core/router.py "What is a for loop?"

# Options
--json                    # JSON output
--force primary           # Force primary model
--list                    # List all models
--status                  # Show status

Python API

from skill.core.router import RouterCore

router = RouterCore()
result = router.route("Design microservices")

print(result.model_name)   # "Claude Opus 4"
print(result.reason)        # "complex_task(score=15)"
print(result.confidence)    # 0.75

Configuration (Optional)

Create ~/.model-router/models.json:

{
  "primary_model": {"id": "ollama:llama3:8b"},
  "secondary_model": {"id": "anthropic:claude-opus-4"},
  "models": [...]
}

Without config: Auto-detects local + uses cloud registry.

Privacy Protection

Automatically forces primary (local) when sensitive data detected:

  • API keys (sk-..., api_key)
  • Passwords (password, passwd)
  • Tokens (bearer, secret)
  • Emails, SSN, credit cards

Files

  • core/router.py - Core routing engine (~200 lines)
  • modules/detector.py - Auto-detection (optional)
  • modules/context.py - Context tracking (optional)

Inspired By

  • model-router-premium: Simple scoring logic, cost-aware routing
  • Model Router v1: Full feature set, documentation

This version combines:

  • The simplicity of model-router-premium (~200 lines)
  • The features of ai-model-router (privacy, auto-detect, context)
Usage Guidance
This skill is largely coherent with its stated purpose, but review a few things before installing: 1) File/path mismatches: SKILL.md examples reference skill/core/router.py and modules/* while the files are under skill/*. Confirm how the package will be executed and fix paths before running. 2) The router will create ~/.model-router and write contexts and models.json — expect local persistence of truncated message text. 3) Cloud models in the built-in registry may require API keys (e.g., ANTHROPIC_API_KEY) even though the skill metadata doesn't declare required env vars; provide those only if you trust the cloud provider and the skill. 4) The privacy-detection regexes will flag emails, API keys, and tokens in user input and force routing to the primary (local) model — this is expected but may produce false positives. 5) Because some code was truncated in the provided bundle, if you plan to let the agent invoke this skill autonomously or route to cloud models, inspect the remaining code paths that actually perform network calls to model providers to ensure no unexpected endpoints or exfiltration are present. If unsure, run the skill in a sandboxed environment and inspect created files and network activity before adding it to agents that have access to sensitive data.
Capability Analysis
Type: OpenClaw Skill Name: ai-model-router Version: 2.0.0 The ai-model-router skill is a legitimate utility designed to route AI tasks between local and cloud models based on complexity and privacy requirements. It features a privacy-protection mechanism that uses regular expressions to detect sensitive data (API keys, passwords, etc.) in `skill/router.py` and forces local execution to prevent data leakage. The code performs safe, read-only file operations to detect local Ollama configurations in `skill/detector.py` and maintains a local conversation history in `skill/context.py`. No evidence of data exfiltration, remote code execution, or malicious intent was found.
Capability Assessment
Purpose & Capability
Name/description (route between local and cloud models based on complexity/privacy) aligns with the code: detector reads local Ollama configs, router scores complexity and checks privacy, and context manager stores conversation state. No unrelated credentials or binaries are requested. Minor mismatch: SKILL.md and examples reference paths like skill/core/router.py and modules/..., but the repo files are skill/router.py, skill/detector.py, skill/context.py — code attempts to import modules.context / modules.detector which may raise ImportError (the router has a fallback). Also SKILL.md claims `core ~200 lines` while router.py is larger; these are inconsistency/accuracy issues but not inherently malicious.
Instruction Scope
Runtime instructions stay within the stated purpose (route tasks, detect privacy, optionally read local Ollama config and write ~/.model-router config/context). They do write/read files in the user's home (~/.model-router, ~/.ollama/models.json and /usr/share/ollama/models.json) and the context manager persists truncated message content. The SKILL.md examples reference paths that don't match the shipped files (may confuse automated installs or cause ImportError), and the SKILL.md instructs local CLI commands that will execute Python scripts on the user's machine — review those paths before running.
Install Mechanism
No install spec provided (instruction-only install), no external downloads, no brew/npm installs. The code is present in the package so installing will only place those files locally; there is no installer that fetches remote code.
Credentials
The package declares no required env vars, and most operations are local/read-only. However built-in fallback models indicate cloud models may require API keys (e.g., ANTHROPIC_API_KEY is referenced in a Model definition). The skill does not declare or request those env vars in metadata — using cloud models will require the user to supply credentials separately. Privacy detection will scan text for tokens/emails, which is expected behavior but could flag benign inputs.
Persistence & Privilege
The skill does create and write files under the user's home (~/.model-router/contexts.json and models.json) for configuration and conversation context — this is consistent with its purpose. It does not request global agent privileges, does not set always:true, and does not modify other skills or system-wide configuration in the visible code.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install ai-model-router
  3. After installation, invoke the skill by name or use /ai-model-router
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v2.0.0
No changes detected in this release. - Version number and documentation remain unchanged. - No file or feature updates.
v1.1.0
- Major refactor: streamlined to a compact core (~200 lines), merging simplicity and core features. - Added automatic local model detection (Ollama, LM Studio); cloud model registry built-in. - Core CLI and Python API redesigned for simplicity—easy model listing, routing, and status checks. - Sensitive data detection improved; privacy mode forces use of local models for secure requests. - Centralized configuration now optional; auto-detects setup if no models.json present. - Legacy scripts, references, and excess code removed for easier maintenance.
v1.0.0
ai-model-router v1.0.0 – Initial Release - Introduces an intelligent router that automatically selects between two user-configured AI models (typically one local, one cloud) based on task complexity and privacy. - Detects sensitive data (like API keys or passwords) and always routes these queries to the local model for privacy. - Uses complexity scoring to determine if a task should stay on the fast/cheap primary model or use a more capable secondary model. - Provides interactive setup and flexible configuration via CLI and files. - Maintains conversation context across model switches for seamless user experience. - Supports a wide range of local and cloud AI models, with easy API key management.
Metadata
Slug ai-model-router
Version 2.0.0
License MIT-0
All-time Installs 1
Active Installs 1
Total Versions 3
Frequently Asked Questions

What is Ai Model Router?

Automatically routes requests between two configured AI models based on task complexity, privacy needs, and user preferences for optimized AI usage. It is an AI Agent Skill for Claude Code / OpenClaw, with 354 downloads so far.

How do I install Ai Model Router?

Run "/install ai-model-router" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Ai Model Router free?

Yes, Ai Model Router is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Ai Model Router support?

Ai Model Router is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Ai Model Router?

It is built and maintained by yuldrone (@yuldrone); the current version is v2.0.0.

💬 Comments