← 返回 Skills 市场
2233admin

API配额监控与手动切换

作者 2233admin · GitHub ↗ · v1.0.1
cross-platform ⚠ suspicious
573
总下载
0
收藏
4
当前安装
2
版本数
在 OpenClaw 中安装
/install api-monitor
功能描述
实时监控OpenClaw模型API配额,配额不足时询问用户确认后再切换模型,支持多模型优先级和手动指定切换。
使用说明 (SKILL.md)

API 使用量监控技能(询问确认模式)

概述

监控 OpenClaw 模型 API 使用量,配额不足时询问用户确认后再切换,确保用户知情。

功能

  • ✅ 实时监控当前模型 API 状态
  • ✅ 检测配额不足/错误
  • ✅ 询问用户确认后再切换模型
  • ✅ 支持多个模型优先级配置
  • ✅ 手动指定切换到某个模型

使用方法

准备工作

# 确认Python环境
python3 --version

# 确认脚本存在(路径根据实际安装位置调整)
ls -la ~/.openclaw/skills/api-monitor/api_monitor.py

查看当前状态

# 替换为实际脚本路径
SCRIPT_PATH="$HOME/.openclaw/skills/api-monitor/api_monitor.py"
python3 "$SCRIPT_PATH" --check

询问是否切换(生成询问消息)

SCRIPT_PATH="$HOME/.openclaw/skills/api-monitor/api_monitor.py"
python3 "$SCRIPT_PATH" --ask

确认切换(用户确认后执行)

SCRIPT_PATH="$HOME/.openclaw/skills/api-monitor/api_monitor.py"
python3 "$SCRIPT_PATH" --confirm

指定切换到某个模型

# 替换为目标模型
TARGET_MODEL="mydamoxing/MiniMax-M2.5"
SCRIPT_PATH="$HOME/.openclaw/skills/api-monitor/api_monitor.py"
python3 "$SCRIPT_PATH" --model "$TARGET_MODEL"

列出所有可用模型

SCRIPT_PATH="$HOME/.openclaw/skills/api-monitor/api_monitor.py"
python3 "$SCRIPT_PATH" --list-models

可用模型列表

  1. mydamoxing/MiniMax-M2.5-highspeed - MiniMax高速版
  2. mydamoxing/MiniMax-M2.5 - MiniMax普通版
  3. volcengine/ark-code-latest - 火山引擎
  4. hajimi/claude-sonnet-4-20250511 - 免费模型

工作流程

  1. 定时检查 → 运行 --check 查看状态
  2. 发现问题 → 运行 --ask 生成询问消息
  3. 用户确认 → 运行 --confirm 执行切换
  4. 或者 → 用户指定 --model xxx 直接切换

示例对话

用户: 检查一下API状态
助手: (运行 --check)
当前模型: mydamoxing/MiniMax-M2.5-highspeed
状态: API配额可能不足,建议切换模型
错误次数: 3

用户: 那就切换吧
助手: (运行 --confirm)
确认切换: mydamoxing/MiniMax-M2.5-highspeed → mydamoxing/MiniMax-M2.5
切换成功!

定时任务配置(可选)

如需定时自动检查,可配置 cron:

# 编辑 crontab
crontab -e

# 添加定时任务(每30分钟检查一次)
# 替换为实际路径
*/30 * * * * cd $HOME/.openclaw/skills/api-monitor && python3 api_monitor.py --check >> /var/log/api-monitor.log 2>&1

注意事项

  • 切换模型会中断当前会话
  • 建议在非高峰期操作
  • 始终需要用户确认才切换
  • 定期检查日志 /var/log/api-monitor.log 了解运行状态
安全使用建议
This skill appears to do what it says: check recent session errors and (after user confirmation) update ~/.openclaw/openclaw.json and restart the OpenClaw gateway. Before installing or running it, consider: 1) Review and backup your OpenClaw config (openclaw.json) so you can restore if something changes unexpectedly. 2) The script requires permission to write the config and to stop/start the gateway (it runs pkill and launches 'openclaw gateway start'); only run it as a user who should have that privilege. 3) Sessions files may contain sensitive session data — ensure you are comfortable the script will read those paths. 4) Test in a non-production environment first (use --check and --ask) and inspect the code (it's included) if you have concerns. 5) If you don't want automated restarts, avoid running --confirm automatically (cron should only run --check).
功能分析
Type: OpenClaw Skill Name: api-monitor Version: 1.0.1 The skill is classified as suspicious due to its use of high-privilege system commands (`pkill` and `subprocess.Popen`) to stop and restart the OpenClaw gateway service and modify its core configuration file (`openclaw.json`). While these actions are explicitly stated in `SKILL.md` as necessary for the skill's purpose (API monitoring and model switching), they represent significant system interaction capabilities. The script itself does not show malicious intent like data exfiltration or arbitrary command execution, but the power to manage a critical service and modify its configuration makes it a high-risk component that could be exploited if the agent or system were compromised, or if the `openclaw` command itself had vulnerabilities.
能力评估
Purpose & Capability
The skill claims to monitor OpenClaw API usage and switch models; the code reads OpenClaw config (openclaw.json) and recent session logs (sessions.json), updates the model in the config, and restarts the gateway. These requirements (file access and ability to restart the gateway) are coherent and necessary for the stated functionality.
Instruction Scope
SKILL.md and the script limit actions to checking session data, reporting suggestions, writing the model field in openclaw.json, writing logs, and restarting the OpenClaw gateway. This stays within the described scope. Note: the script will read session files (which may contain session data) and writes to logs and config; those are privacy-relevant but expected for this purpose.
Install Mechanism
No install spec; the skill is instruction-only with an included Python script. Nothing is downloaded or installed automatically by the skill itself, so there is low install-time risk.
Credentials
The skill does not request external credentials or unrelated env vars. It optionally honors OPENCLAW_DIR and LOG_DIR environment variables. However, it requires filesystem write permission to the OpenClaw config and the ability to kill/start the OpenClaw gateway process, which are elevated actions and should only be granted if you trust the script and understand the operational impact.
Persistence & Privilege
always:false (not force-included). The skill modifies its product's own config file (openclaw.json) and restarts the gateway — this is consistent with its function. It does not attempt to modify other skills or system-wide agent settings beyond controlling OpenClaw. Autonomous invocation is permitted by default but not unusual; combine that with the config-modifying behavior only if you want agents to be able to act without manual confirmation.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install api-monitor
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /api-monitor 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.1
1.0.1: 添加前置要求和风险提示,支持自定义路径配置
v1.0.0
初始版本:监控API使用量,支持手动确认后切换模型
元数据
Slug api-monitor
版本 1.0.1
许可证
累计安装 4
当前安装数 4
历史版本数 2
常见问题

API配额监控与手动切换 是什么?

实时监控OpenClaw模型API配额,配额不足时询问用户确认后再切换模型,支持多模型优先级和手动指定切换。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 573 次。

如何安装 API配额监控与手动切换?

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

API配额监控与手动切换 是免费的吗?

是的,API配额监控与手动切换 完全免费(开源免费),可自由下载、安装和使用。

API配额监控与手动切换 支持哪些平台?

API配额监控与手动切换 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 API配额监控与手动切换?

由 2233admin(@2233admin)开发并维护,当前版本 v1.0.1。

💬 留言讨论