← 返回 Skills 市场
freedompixels

AI Token消耗监控

作者 freedompixels · GitHub ↗ · v1.0.2 · MIT-0
cross-platform ✓ 安全检测通过
94
总下载
0
收藏
0
当前安装
2
版本数
在 OpenClaw 中安装
/install ai-token-usage
功能描述
AI Token消耗监控。读取会话日志,统计Token消耗,检测异常并提供优化建议。 帮助用户了解AI使用成本,避免意外超支。 当用户说"Token"、"消耗多少"、"Token统计"、"费用"、"超支"时触发。 Keywords: Token, 消耗, 费用, 统计, 监控, 成本.
使用说明 (SKILL.md)

Token Monitor - AI Token 消耗监控

监控 AI Token 消耗,检测异常,提供优化建议。

功能

  • 📊 读取 session 日志统计 Token 消耗
  • 🚨 检测异常消耗(短时激增、重复失败等)
  • 💡 给出优化建议
  • 📈 生成消耗趋势报告

使用

检查今日消耗

python3 ~/.qclaw/skills/token-monitor/scripts/token_stats.py --today

检查指定日期

python3 ~/.qclaw/skills/token-monitor/scripts/token_stats.py --date 2026-04-13

检查异常模式

python3 ~/.qclaw/skills/token-monitor/scripts/token_stats.py --check-anomaly

生成优化报告

python3 ~/.qclaw/skills/token-monitor/scripts/token_stats.py --report

异常检测规则

规则 阈值 说明
单日总量 >1000万 严重超标
单小时 >200万 需要检查
重复失败 >3次 死循环风险
浏览器快照 单次>5000字 未压缩

历史数据参考

日期 Input Output Total 状态
4/11 3.46M 117K 28.8M 🚨 超标
4/12 5.57M 127K 37.0M 🚨 严重超标
4/13 1.80M 22K 9.5M ⚠️ 偏高
4/14 430K 20K 3.7M ✅ 正常

4/12是Token浪费最严重的一天:3700万token,根因是Chrome CDP崩溃重试+ClawHub限速重试

优化建议库

  • 浏览器快照用 compact=true
  • 同一操作失败3次立即换方案
  • 限速不硬等,跳转做其他事
  • 后台进程不轮询

数据存储

  • 日志:~/.qclaw/agents/main/sessions/*.jsonl
  • 统计:memory/token-usage-YYYY-MM-DD.json
安全使用建议
This skill appears to do what it claims: analyze local session logs and save aggregated token-usage JSON files. Before installing, consider: (1) the script will read your session files (~/.qclaw/agents/main/sessions) which may contain message contents—if those messages include sensitive data you may prefer not to run it or to inspect the script first; (2) it writes aggregated stats under ~/.qclaw/workspace/memory; ensure you are comfortable with that storage location; (3) it requires a local Python runtime to execute; (4) although no network calls are present, review the code if you want extra assurance. If you do not want the skill invoked autonomously, disable autonomous invocation in your agent settings.
功能分析
Type: OpenClaw Skill Name: ai-token-usage Version: 1.0.2 The skill is a utility designed to monitor AI token consumption by parsing local session logs located in the user's OpenClaw directory. The Python script `scripts/token_stats.py` reads JSONL files to aggregate usage metrics and saves reports locally to a memory directory, with no evidence of network exfiltration, unauthorized access to sensitive credentials, or malicious prompt injection.
能力评估
Purpose & Capability
Name/description say it will read session logs and count tokens. The SKILL.md and scripts/token_stats.py both reference the same session path (~/.qclaw/agents/main/sessions) and a local memory path (~/.qclaw/workspace/memory). No unrelated credentials, binaries, or external services are requested.
Instruction Scope
Runtime instructions and the script only read local session JSONL files, compute aggregates, print reports, detect anomalies, and save aggregated JSON files. The script does not read unrelated system config, access network endpoints, or exfiltrate data. Note: it does read message-level session files (which may contain sensitive message text) but only stores aggregated token counts.
Install Mechanism
No install spec (instruction-only) and included Python script; no download or third-party installers. Risk from install mechanism is low. Running requires a local Python runtime.
Credentials
The skill requires no environment variables or credentials. It reads only session logs under the agent workspace and writes aggregated stats to the workspace memory directory — proportional to the stated purpose.
Persistence & Privilege
always:false and user-invocable:true. The skill writes files only under ~/.qclaw/workspace/memory and does not change other skills or system settings. Autonomous invocation (model invocation enabled) is the platform default but is not combined here with other concerning privileges.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install ai-token-usage
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /ai-token-usage 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.2
- Updated keywords in the description to include "成本" (cost). - No functional changes; documentation only.
v1.0.1
- 新增技能:AI Token消耗监控,帮助用户追踪和优化Token使用。 - 支持读取会话日志,统计每日/历史Token消耗。 - 检测异常模式,如短时激增、重复失败等,并给出优化建议。 - 提供消耗趋势报告及详细异常检测规则。 - 明确列出常见Token异常原因及优化方案。
元数据
Slug ai-token-usage
版本 1.0.2
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 2
常见问题

AI Token消耗监控 是什么?

AI Token消耗监控。读取会话日志,统计Token消耗,检测异常并提供优化建议。 帮助用户了解AI使用成本,避免意外超支。 当用户说"Token"、"消耗多少"、"Token统计"、"费用"、"超支"时触发。 Keywords: Token, 消耗, 费用, 统计, 监控, 成本. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 94 次。

如何安装 AI Token消耗监控?

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

AI Token消耗监控 是免费的吗?

是的,AI Token消耗监控 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

AI Token消耗监控 支持哪些平台?

AI Token消耗监控 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 AI Token消耗监控?

由 freedompixels(@freedompixels)开发并维护,当前版本 v1.0.2。

💬 留言讨论