← 返回 Skills 市场
yuldrone

Ai Model Router

作者 yuldrone · GitHub ↗ · v2.0.0 · MIT-0
cross-platform ✓ 安全检测通过
354
总下载
0
收藏
1
当前安装
3
版本数
在 OpenClaw 中安装
/install ai-model-router
功能描述
Automatically routes requests between two configured AI models based on task complexity, privacy needs, and user preferences for optimized AI usage.
使用说明 (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)
安全使用建议
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.
功能分析
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.
能力评估
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.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install ai-model-router
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /ai-model-router 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
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.
元数据
Slug ai-model-router
版本 2.0.0
许可证 MIT-0
累计安装 1
当前安装数 1
历史版本数 3
常见问题

Ai Model Router 是什么?

Automatically routes requests between two configured AI models based on task complexity, privacy needs, and user preferences for optimized AI usage. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 354 次。

如何安装 Ai Model Router?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install ai-model-router」即可一键安装,无需额外配置。

Ai Model Router 是免费的吗?

是的,Ai Model Router 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Ai Model Router 支持哪些平台?

Ai Model Router 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Ai Model Router?

由 yuldrone(@yuldrone)开发并维护,当前版本 v2.0.0。

💬 留言讨论