← Back to Skills Marketplace
2233admin

API配额监控与手动切换

by 2233admin · GitHub ↗ · v1.0.1
cross-platform ⚠ suspicious
573
Downloads
0
Stars
4
Active Installs
2
Versions
Install in OpenClaw
/install api-monitor
Description
实时监控OpenClaw模型API配额,配额不足时询问用户确认后再切换模型,支持多模型优先级和手动指定切换。
README (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 了解运行状态
Usage Guidance
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).
Capability Analysis
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.
Capability Assessment
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.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install api-monitor
  3. After installation, invoke the skill by name or use /api-monitor
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.1
1.0.1: 添加前置要求和风险提示,支持自定义路径配置
v1.0.0
初始版本:监控API使用量,支持手动确认后切换模型
Metadata
Slug api-monitor
Version 1.0.1
License
All-time Installs 4
Active Installs 4
Total Versions 2
Frequently Asked Questions

What is API配额监控与手动切换?

实时监控OpenClaw模型API配额,配额不足时询问用户确认后再切换模型,支持多模型优先级和手动指定切换。 It is an AI Agent Skill for Claude Code / OpenClaw, with 573 downloads so far.

How do I install API配额监控与手动切换?

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

Is API配额监控与手动切换 free?

Yes, API配额监控与手动切换 is completely free (open-source). You can download, install and use it at no cost.

Which platforms does API配额监控与手动切换 support?

API配额监控与手动切换 is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created API配额监控与手动切换?

It is built and maintained by 2233admin (@2233admin); the current version is v1.0.1.

💬 Comments