← Back to Skills Marketplace
wei-wei-zhao

Auto Model Switch

by wei-wei-zhao · GitHub ↗ · v1.0.0 · MIT-0
linuxdarwinwin32 ⚠ suspicious
130
Downloads
1
Stars
2
Active Installs
1
Versions
Install in OpenClaw
/install auto-model-switch
Description
自动切换模型 - 当模型token用完或限流时,自动切换到备用模型,并通知用户。支持配置多个备用模型,智能切换策略。
README (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 # 切换历史

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

Usage Guidance
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.
Capability Analysis
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.
Capability Assessment
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.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install auto-model-switch
  3. After installation, invoke the skill by name or use /auto-model-switch
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
auto-model-switch v1.0.0 - 初始版本发布。 - 自动检测模型token消耗和API限流。 - 在token用完或遇到限流时,自动切换到备用模型并通知用户。 - 支持配置多个备用模型及智能切换策略。
Metadata
Slug auto-model-switch
Version 1.0.0
License MIT-0
All-time Installs 2
Active Installs 2
Total Versions 1
Frequently Asked Questions

What is Auto Model Switch?

自动切换模型 - 当模型token用完或限流时,自动切换到备用模型,并通知用户。支持配置多个备用模型,智能切换策略。 It is an AI Agent Skill for Claude Code / OpenClaw, with 130 downloads so far.

How do I install Auto Model Switch?

Run "/install auto-model-switch" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Auto Model Switch free?

Yes, Auto Model Switch is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Auto Model Switch support?

Auto Model Switch is cross-platform and runs anywhere OpenClaw / Claude Code is available (linux, darwin, win32).

Who created Auto Model Switch?

It is built and maintained by wei-wei-zhao (@wei-wei-zhao); the current version is v1.0.0.

💬 Comments