← 返回
未分类 中文

Model Routing Middleware

Intelligent model selection middleware for AI agents. Route tasks to the best model, manage context, and cut API costs 40-70%.
面向AI代理的智能模型选择中间件,自动将任务路由至最优模型,管理上下文,削减API费用40%~70%
larios613-hub
未分类 clawhub v1.0.0 1 版本 99539.2 Key: 无需
★ 0
Stars
📥 216
下载
💾 0
安装
1
版本
#latest

概述

Model Routing — Intelligent Model Selection Middleware

Automatically select the best LLM model and think mode based on task type, context size, and response confidence. Cut API costs 40-70% by routing simple tasks to fast models and complex tasks to capable ones.

How It Works

User message → Task Classifier → Model Router → Best Model → Response
                                     ↓
                          Low confidence? → Escalate to stronger model

Quick Start

# config.yaml
models:
  casual_chat:
    model: qwen3-14b
    think: false
  coding:
    model: qwen-coder
    think: true
  reasoning:
    model: deepseek-r1
    think: true
  long_context:
    model: glm-5.1
    think: false
from router import get_router

router = get_router()
result = await router.route("Write a Python web scraper")
# → Routes to qwen-coder with think=True

Features

  • Task-type classification (coding, reasoning, chat, summarization)
  • Per-model think mode configuration
  • Confidence-based escalation (retry with stronger model)
  • Context management and compaction at 55% threshold
  • Hot-reload configuration (no restart needed)
  • 83 tests passing

Cost Savings

Task TypeWithout RoutingWith RoutingSavings
--------------------------------------------------
Casual chatGPT-4 ($0.03/1K)Qwen3-14B (local)~100%
CodingGPT-4 ($0.03/1K)Qwen-Coder (local)~95%
Hard reasoningGPT-4 ($0.03/1K)DeepSeek-R1 (local)~90%

License

MIT

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-23 23:45 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

Restaurant Operator

larios613-hub
管理餐厅运营,涵盖食谱创建、库存预测、菜单优化、员工排班和食品安全合规。
★ 0 📥 422

Youtube Learning

larios613-hub
概述YouTube视频,提炼关键点,制作笔记、测验和学习路径,实现高效知识获取。
★ 0 📥 426

Photo Editor Pro

larios613-hub
Photo Editor Pro 提供AI增强编辑、背景移除、色彩调校、批量处理和格式转换,专为专业图像工作流程设计。
★ 0 📥 415