Ai Model Router
by @yuldrone
Automatically routes requests between two configured AI models based on task complexity, privacy needs, and user preferences for optimized AI usage.
clawhub install ai-model-routerπ About This Skill
name: ai-model-router description: Intelligent AI model router that automatically switches between two configured models (local for simple tasks, cloud for complex ones). Detects local models (Ollama, LM Studio) automatically, routes based on task complexity and privacy. Use when users ask to "switch model", "use local/cloud model", or mention API keys/passwords (triggers privacy mode). Trigger on: sensitive data detection (forces local), complex tasks like "design architecture" (uses cloud), or configuration requests. version: 1.0.0
AI Model Router
Compact, intelligent model routing that just works.
Quick Start
# Install
npx clawhub@latest install ai-model-routerFirst 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 RouterCorerouter = 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:
sk-..., api_key)password, passwd)bearer, secret)Files
core/router.py - Core routing engine (~200 lines)modules/detector.py - Auto-detection (optional)modules/context.py - Context tracking (optional)Inspired By
This version combines:
π‘ Examples
# Install
npx clawhub@latest install ai-model-routerFirst run - auto-detects your models
python3 skill/core/router.py "What is Python?"List available models
python3 skill/core/router.py --list