ClawKit Logo
ClawKitReliability Toolkit
Back to Registry
Official Verified

Smart Router Skill

Skill by astralwaveorg

skill-install — Terminal

Install via CLI (Recommended)

clawhub install openclaw/skills/skills/astralwaveorg/smart-router-skill
Or

智能路由器技能

概述

智能路由器是一个先进的模型调度系统,它超越了简单的关键词匹配,使用多维度分析来为每个消息选择最合适的模型。系统包含成本优化、自动模型扫描和性能监控功能。

功能特性

🎯 智能路由

  • 多维度分析:消息长度、内容复杂度、模式识别
  • 动态模型选择:基于任务类型自动选择最佳模型
  • 成本感知:优先使用免费模型,复杂任务才用付费模型
  • 上下文感知:考虑对话历史和用户偏好

💰 成本优化

  • 预算控制:设置每日/每月预算限制
  • 自动降级:简单任务自动使用免费模型
  • 使用统计:实时监控各模型成本
  • 智能提醒:成本接近阈值时预警

🔄 自动化管理

  • 定期扫描:自动发现OpenRouter免费模型
  • 性能监控:实时监控路由性能和系统健康
  • 自动备份:定期备份配置和日志
  • 规则优化:基于使用数据自动优化路由规则

安装和配置

前提条件

  • OpenClaw 2026.2.13 或更高版本
  • Node.js 18+
  • OpenRouter API密钥(用于模型扫描)

快速安装

# 1. 复制技能文件到OpenClaw技能目录
cp -r smart-router-skill /opt/homebrew/lib/node_modules/openclaw/skills/

# 2. 更新OpenClaw配置以启用技能
openclaw config patch --json '{"skills":{"entries":{"smart-router":{"enabled":true}}}}'

# 3. 重启OpenClaw
openclaw gateway restart

详细安装步骤

  1. 环境变量设置
export OPENROUTER_API_KEY="your-openrouter-api-key"
export DEEPSEEK_API_KEY="your-deepseek-api-key"
  1. 初始化系统
cd /Users/nora/.openclaw/users/main/workspace
node enhanced-intent-router.js init
  1. 运行集成测试
./test-integration.sh
  1. 部署系统
node update-openclaw-config.js update
openclaw gateway restart

使用方法

基本路由

// 使用智能路由器路由消息
const { SmartIntentRouter } = require('./enhanced-intent-router.js');

const router = new SmartIntentRouter();
await router.initialize();

const decision = router.analyzeMessage("帮我写一个Python函数");
console.log(decision);
// 输出: { agentId: 'code-agent', model: '4sapi-anthropic/claude-sonnet-4-5-20250929', ... }

命令行工具

# 初始化路由器
node enhanced-intent-router.js init

# 分析消息路由
node enhanced-intent-router.js analyze "你的消息"

# 运行测试用例
node enhanced-intent-router.js test

# 查看性能指标
node enhanced-intent-router.js stats

# 生成详细报告
node enhanced-intent-router.js report

OpenClaw集成

系统自动集成到OpenClaw,无需手动调用。所有消息都会经过智能路由器处理。

配置说明

路由规则配置 (smart-router-config.json)

{
  "routingRules": {
    "priority": [
      {
        "name": "代码相关任务",
        "conditions": {
          "keywords": ["代码", "编程", "Python", "Java"],
          "minLength": 10,
          "maxLength": 5000
        },
        "agent": "code-agent",
        "model": "4sapi-anthropic/claude-sonnet-4-5-20250929",
        "priority": 100
      }
    ],
    "fallback": {
      "agent": "free-agent",
      "model": "openrouter/google/gemma-3-27b-it:free"
    }
  },
  "costOptimization": {
    "budgetLimit": 10.0,
    "dailyLimit": 1.0,
    "preferFreeModels": true
  }
}

自定义路由规则

要添加新的路由规则:

  1. 编辑 smart-router-config.json
  2. routingRules.priority 数组中添加新规则
  3. 设置匹配条件和目标模型
  4. 无需重启,系统支持热重载

定时任务

系统包含以下自动化定时任务:

任务名称时间描述
OpenRouter扫描每天 6:00扫描免费模型并更新配置
每日性能报告每天 0:00生成路由性能报告
每周成本分析每周一 9:00分析成本优化效果
配置备份每天 23:30备份配置和日志
规则优化检查每天 12:00检查并优化路由规则

API参考

SmartIntentRouter 类

Metadata

Stars4126
Views1
Updated2026-04-15
View Author Profile
AI Skill Finder

Not sure this is the right skill?

Describe what you want to build — we'll match you to the best skill from 16,000+ options.

Find the right skill
Add to Configuration

Paste this into your clawhub.json to enable this plugin.

{
  "plugins": {
    "official-astralwaveorg-smart-router-skill": {
      "enabled": true,
      "auto_update": true
    }
  }
}
Safety NoteClawKit audits metadata but not runtime behavior. Use with caution.