auto-model-switch

自动切换模型 - 当模型token用完或限流时,自动切换到备用模型,并通知用户。支持配置多个备用模型,智能切换策略。

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "auto-model-switch" with this command: npx skills add wei-wei-zhao/auto-model-switch

自动切换模型 (Auto Model Switch)

概述

当主模型token用完或遇到限流时,自动切换到备用模型,确保对话不中断。

快速开始

1. 安装依赖

cd ~/.openclaw/workspace/skills/auto-model-switch
npm install

2. 配置模型

编辑 config.yaml

models:
  - id: primary
    model: custom-maas-coding-api-cn-huabei-1-xf-yun-com/astron-code-latest
    name: "Astron Code"
    daily_limit: 10000000
    priority: 1
  
  - id: backup-1
    model: zai/glm-5
    name: "GLM-4.5"
    daily_limit: null
    priority: 2

3. 启用心跳检查

HEARTBEAT.md 中添加:

- 检查模型状态: node ~/.openclaw/workspace/skills/auto-model-switch/heartbeat.js

命令

命令说明
node auto_model_switch.js status查看当前模型状态
node auto_model_switch.js switch手动切换模型
node auto_model_switch.js heartbeat心跳检查(自动检测和切换)
node auto_model_switch.js sync从网关同步token使用量

触发条件

  • 警告:Token使用 > 80%
  • 切换:Token使用 > 95% 或 API限流

配置说明

models:
  - id: primary              # 模型标识
    model: model-id          # OpenClaw模型ID
    name: "显示名称"          # 友好名称
    daily_limit: 10000000    # 每日token限制(null=无限制)
    priority: 1              # 优先级(数字越小越优先)

auto_switch:
  on_limit_exceeded: true    # token用完时切换
  on_rate_limit: true        # 限流时切换
  retry_delay: 60            # 限流后重试延迟(秒)
  warning_threshold: 0.8     # 警告阈值
  critical_threshold: 0.95   # 切换阈值

notification:
  enabled: true              # 启用通知

与OpenClaw集成

设置环境变量以启用网关集成:

export OPENCLAW_GATEWAY_URL="http://localhost:3000"
export OPENCLAW_GATEWAY_TOKEN="your-token"

示例输出

📊 模型状态
当前:Astron Code
Token:8.5M / 10M (85%)

备用模型:
- GLM-4.5 (可用)

文件说明

auto-model-switch/
├── SKILL.md              # 本文件
├── config.yaml           # 模型配置
├── auto_model_switch.js  # 主脚本
├── heartbeat.js          # 心跳脚本
├── package.json          # Node.js配置
├── QUICKSTART.md         # 快速开始
└── state/                # 状态目录(自动创建)
    ├── model-switch.json # 当前状态
    └── switch-history.json # 切换历史

🔄 让模型切换自动化,对话永不断线

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

Huo15 Openclaw Enhance

火一五·克劳德·龙虾增强插件 v5.7.8 — 全面适配 openclaw 2026.4.24:peerDep ^4.24 + build/compat 同步到 4.24 + 14 处 api.on 全部去掉 as any 改成 typed hook(hookName 联合类型 + handler 自动推断 Pl...

Registry SourceRecently Updated
General

Content Trend Analyzer

Aggregates and analyzes content trends across platforms to identify hot topics, user intent, content gaps, and generates data-driven article outlines.

Registry SourceRecently Updated
General

Prompt Debugger

Debug prompts that produce unexpected AI outputs — diagnose failure modes, identify ambiguity and conflicting instructions, test variations, compare model re...

Registry SourceRecently Updated
General

Indie Maker News

独行者 Daily - 变现雷达。读对一条新闻,少走一年弯路。每天5分钟,给创业者装上商业雷达。聚焦一人公司、副业、创业变现资讯,智能分类,行动导向。用户下载即能用,无需本地部署!

Registry SourceRecently Updated