智能路由降本,三档模型自动匹配
简介
基于正则表达式的智能任务路由系统,按复杂度自动分配本地/中端/高级AI模型,节省60%+ API成本。
原始描述
Regex-based routing sends simple tasks to local AI, medium to mid-tier, complex to premium — saving 60%+ on API costs.
通过你的 Agent 添加
安装目录:ai-task-router-auto-route-prompts-by-complexity-local-cloud/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
中文使用说明 来自收录源
核心用法
AI Task Router 是一款基于正则表达式模式匹配的智能任务路由系统,通过分析输入提示词的复杂度,自动将任务分配到最合适的AI模型层级,实现成本优化与性能平衡。
路由层级设计:
- Simple(简单任务):问候、时间查询等基础交互 → 本地Ollama模型($0成本)
- Moderate(中等任务):邮件撰写、基础分析 → 中端模型如Claude Sonnet($成本)
- Complex(复杂任务):代码调试、长文本创作 → 高级模型如Claude Opus($$$成本)
技术实现:
系统采用JavaScript类结构,支持自定义规则扩展。用户可通过addRule()方法添加专属正则匹配模式,灵活配置模型映射关系。内置置信度评分机制,为每个路由决策提供可解释性。
显著优点
- 成本效益突出:典型使用场景下70%任务路由至免费本地模型,整体API成本降低60-80%
- 架构简洁高效:纯正则匹配方案,无需LLM调用即可确定路由,零额外推理开销
- 高度可定制:支持动态添加业务专属规则,适配垂直领域需求
- 透明可解释:每个路由决策附带原因说明和置信度分数,便于调试优化
- MIT开源协议:代码完全开放,可自由修改和商业使用
潜在局限
- 正则匹配的固有局限:无法处理语义模糊边界,复杂提示可能误分类;面对新型任务类型时需要手动更新规则
- 本地化部署成本:虽节省API费用,但需承担本地GPU/内存资源投入
- 维护负担:规则库随业务扩展可能膨胀,长期维护需投入技术资源
- 作者可信度存疑:署名"@TheShadowRose"为匿名网络身份,无公开可验证的专业背景
适合人群
- 日均API调用量高的AI应用开发者
- 已有Ollama本地部署基础的技术团队
- 希望精细化控制多模型成本结构的产品负责人
- 具备JavaScript开发能力的独立开发者
常规风险
- 分类错误风险:简单任务误路由至高价模型,或复杂任务因正则漏匹配导致模型能力不足
- 数据安全:本地处理虽减少云端暴露,但需自行保障本地环境安全
- 依赖维护:OpenClaw框架及依赖库的长期维护可持续性需关注
- 隐性成本:硬件折旧、电力消耗、运维人力等本地部署综合成本需纳入核算
- 正则匹配的固有局限:无法处理语义模糊边界,复杂提示可能误分类;面对新型任务类型时需要手动更新规则
- 本地化部署成本:虽节省API费用,但需承担本地GPU/内存资源投入
- 维护负担:规则库随业务扩展可能膨胀,长期维护需投入技术资源
- 作者可信度存疑:署名"@TheShadowRose"为匿名网络身份,无公开可验证的专业背景
适合人群
- 日均API调用量高的AI应用开发者
- 已有Ollama本地部署基础的技术团队
- 希望精细化控制多模型成本结构的产品负责人
- 具备JavaScript开发能力的独立开发者
常规风险
- 分类错误风险:简单任务误路由至高价模型,或复杂任务因正则漏匹配导致模型能力不足
- 数据安全:本地处理虽减少云端暴露,但需自行保障本地环境安全
- 依赖维护:OpenClaw框架及依赖库的长期维护可持续性需关注
- 隐性成本:硬件折旧、电力消耗、运维人力等本地部署综合成本需纳入核算
- 分类错误风险:简单任务误路由至高价模型,或复杂任务因正则漏匹配导致模型能力不足
- 数据安全:本地处理虽减少云端暴露,但需自行保障本地环境安全
- 依赖维护:OpenClaw框架及依赖库的长期维护可持续性需关注
- 隐性成本:硬件折旧、电力消耗、运维人力等本地部署综合成本需纳入核算
技能正文
name: "AI Task Router — Auto-Route Prompts by Complexity (Local/Cloud)"
description: "Regex-based routing sends simple tasks to local AI, medium to mid-tier, complex to premium — saving 60%+ on API costs."
author: "@TheShadowRose"
version: "1.0.0"
tags: ["task-routing", "cost-optimization", "complexity-detection", "ollama", "auto-routing", "smart-dispatch"]
license: "MIT"
AI Task Router — Auto-Route Prompts by Complexity (Local/Cloud)
Regex-based routing sends simple tasks to local AI, medium to mid-tier, complex to premium — saving 60%+ on API costs.
Automatically routes prompts to the cheapest model that can handle them.
How It Works
Pattern matching classifies tasks into tiers:
| Task Type | Example | Routed To | Cost |
|---|---|---|---|
| Simple | "hi", "thanks", "what time is it" | Local (Ollama) | $0 |
| Moderate | "write an email", "analyze this" | Mid-tier (Sonnet) | $ |
| Complex | "debug this codebase", "write a chapter" | Premium (Opus) | $$$ |
Usage
const { TaskRouter } = require('./src/task-router');
const router = new TaskRouter({
defaultModel: 'local',
escalationModel: 'sonnet',
heavyModel: 'opus'
});
const result = router.route('analyze the sales data from Q3');
// { model: 'sonnet', reason: 'Analysis task', confidence: 0.8 }
Custom Rules
const { TaskRouter } = require('./src/task-router');
const router = new TaskRouter({
defaultModel: 'local',
escalationModel: 'sonnet',
heavyModel: 'opus'
});
const result = router.route('analyze the sales data from Q3');
// { model: 'sonnet', reason: 'Analysis task', confidence: 0.8 }
Add your own routing patterns:
router.addRule({
name: 'code-review',
pattern: /\b(review|refactor|debug|optimize)\b.*\b(code|function|class)\b/i,
model: 'opus',
reason: 'Code review needs deep reasoning'
});
Cost Savings
Typical usage pattern routes ~70% of tasks to free local models, ~25% to mid-tier, and ~5% to premium. With Opus at $15/M tokens vs Ollama at $0, this saves 60-80% on API costs.
⚠️ Disclaimer
⚠️ Disclaimer
This software is provided "AS IS", without warranty of any kind, express or implied.
USE AT YOUR OWN RISK.
- The author(s) are NOT liable for any damages, losses, or consequences arising from the use or misuse of this software — including but not limited to financial loss, data loss, security breaches, business interruption, or any indirect/consequential damages.
- This software does NOT constitute financial, legal, trading, or professional advice.
- Users are solely responsible for evaluating whether this software is suitable for their use case, environment, and risk tolerance.
- No guarantee is made regarding accuracy, reliability, completeness, or fitness for any particular purpose.
- The author(s) are not responsible for how third parties use, modify, or distribute this software after purchase.
By downloading, installing, or using this software, you acknowledge that you have read this disclaimer and agree to use the software entirely at your own risk.
DATA DISCLAIMER: This software processes and stores data locally on your system. The author(s) are not responsible for data loss, corruption, or unauthorized access resulting from software bugs, system failures, or user error. Always maintain independent backups of important data. This software does not transmit data externally unless explicitly configured by the user.
Support & Links
🐛 Bug Reports
TheShadowyRose@proton.me
☕ Ko-fi
ko-fi.com/theshadowrose
🛒 Gumroad
shadowyrose.gumroad.com
🐦 Twitter
@TheShadowyRose
🐙 GitHub
github.com/TheShadowRose
🧠 PromptBase
promptbase.com/profile/shadowrose
| 🐛 Bug Reports | TheShadowyRose@proton.me |
| ☕ Ko-fi | ko-fi.com/theshadowrose |
| 🛒 Gumroad | shadowyrose.gumroad.com |
| @TheShadowyRose | |
| 🐙 GitHub | github.com/TheShadowRose |
| 🧠 PromptBase | promptbase.com/profile/shadowrose |
Built with OpenClaw — thank you for making this possible.
🛠️ Need something custom? Custom OpenClaw agents & skills starting at $500. If you can describe it, I can build it. → Hire me on Fiverr
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。