← 返回 Skills 市场
wei-wei-zhao

Auto Model Switch

作者 wei-wei-zhao · GitHub ↗ · v1.0.0 · MIT-0
linuxdarwinwin32 ⚠ suspicious
130
总下载
1
收藏
2
当前安装
1
版本数
在 OpenClaw 中安装
/install auto-model-switch
功能描述
自动切换模型 - 当模型token用完或限流时,自动切换到备用模型,并通知用户。支持配置多个备用模型,智能切换策略。
使用说明 (SKILL.md)

自动切换模型 (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 # 切换历史

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

安全使用建议
This skill appears to implement the advertised auto-switching behavior, but review the following before installing: 1) The code uses OPENCLAW_GATEWAY_URL and OPENCLAW_GATEWAY_TOKEN to call your gateway and change model config — only provide a token with minimal required scope and verify you trust the gateway endpoint. 2) The package metadata did not declare these required env vars and lists only Node, yet Python scripts are included; if you don't use the Python parts they can be ignored or removed, but their presence is an inconsistency. 3) package-lock points to a non-default npm mirror (npmmirror.com); if you prefer, run npm install with your controlled registry or audit the downloaded packages. 4) Inspect the code (auto_model_switch.js) and test it in a sandboxed environment before giving it access to production credentials. If anything is unclear, ask the author to: (a) declare the gateway env vars in the metadata, (b) remove unused language artifacts or document why Python is included, and (c) confirm the minimal scope required of the gateway token.
功能分析
Type: OpenClaw Skill Name: auto-model-switch Version: 1.0.0 The skill 'auto-model-switch' is designed to automatically switch AI models via the OpenClaw Gateway API when token limits are reached or rate-limiting occurs. It utilizes the 'http' and 'https' modules in 'auto_model_switch.js' to communicate with a user-defined gateway URL and requires an 'OPENCLAW_GATEWAY_TOKEN' for authentication. While the code logic is transparent and directly supports its stated purpose, the use of network access and file system operations (reading/writing state files) to modify system-level configurations are considered high-risk capabilities that warrant a 'suspicious' classification according to the provided criteria, despite the lack of clear malicious intent.
能力评估
Purpose & Capability
The code implements automatic model switching and gateway integration matching the description. However, the package declares only Node as required while the repo also includes Python implementations and tests (auto_model_switch.py, test.py), which is inconsistent with the declared requirements and increases surface area.
Instruction Scope
SKILL.md and the code expect OPENCLAW_GATEWAY_URL and OPENCLAW_GATEWAY_TOKEN to be set and the scripts will call /api/status and POST /api/config/model on that gateway. The registry metadata lists no required env vars even though runtime behavior depends on those environment variables and will send requests to the provided gateway URL with the token.
Install Mechanism
There is no install spec (instruction-only), so nothing will be forced onto disk by the registry. The Node dependency (js-yaml) is standard, but the package-lock references registry.npmmirror.com (a mirror) rather than the default npm registry — this is not necessarily malicious but you should be aware of the alternate registry source.
Credentials
The skill requires (and documents) OPENCLAW_GATEWAY_URL and OPENCLAW_GATEWAY_TOKEN to perform model switches. Those are powerful credentials because the skill will attempt to change gateway configuration; yet the metadata declares no required credentials. Requesting a gateway token is proportionate to the claimed purpose, but the omission from the declared requirements is an inconsistency and the token must be trusted (it will be sent to the gateway URL).
Persistence & Privilege
The skill does not request always:true and does not modify other skills or system-wide settings. It writes state and history under its own state/ directory, which is expected for this functionality.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install auto-model-switch
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /auto-model-switch 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
auto-model-switch v1.0.0 - 初始版本发布。 - 自动检测模型token消耗和API限流。 - 在token用完或遇到限流时,自动切换到备用模型并通知用户。 - 支持配置多个备用模型及智能切换策略。
元数据
Slug auto-model-switch
版本 1.0.0
许可证 MIT-0
累计安装 2
当前安装数 2
历史版本数 1
常见问题

Auto Model Switch 是什么?

自动切换模型 - 当模型token用完或限流时,自动切换到备用模型,并通知用户。支持配置多个备用模型,智能切换策略。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 130 次。

如何安装 Auto Model Switch?

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

Auto Model Switch 是免费的吗?

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

Auto Model Switch 支持哪些平台?

Auto Model Switch 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(linux, darwin, win32)。

谁开发了 Auto Model Switch?

由 wei-wei-zhao(@wei-wei-zhao)开发并维护,当前版本 v1.0.0。

💬 留言讨论