← 返回 Skills 市场
chris-openclaw

Token Cockpit

作者 chris-openclaw · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ pending
61
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install token-cockpit
功能描述
See and slash your OpenClaw / LLM token bill. Use this skill whenever the user asks about token usage, model spend, API costs, or wants to save money on thei...
使用说明 (SKILL.md)

Token Cockpit

Running an agent feels free until the invoice lands. Token Cockpit turns the local usage logs you already have into a clear picture of where the money goes - and, more usefully, where it's being wasted. Everything is computed locally; no API key, no data leaves the machine.

Four jobs:

  1. Report - spend and token volume broken down by model, with a monthly projection.
  2. Budget - compare spend (or projected monthly spend) against a limit and emit a ready-to-send alert when you're close or over.
  3. Route - find small, cheap-to-serve calls that are running on premium models and estimate the savings from downgrading them.
  4. Simulate - a what-if: "how much would I save if I moved all my Opus traffic to Haiku?"

When to use this

Any time cost or usage comes up: "how much am I spending," "why is my bill so high," "break this down by model," "am I over budget," "should I switch to a cheaper model," "how much would Haiku save me," "project my monthly spend." If the user wants to reduce spend, lead with route and simulate; if they want to understand it, lead with report.

The tool

python token_cockpit.py report   --logs PATH [--days N]
python token_cockpit.py budget   --limit 50 [--period month|window] --logs PATH
python token_cockpit.py route    --logs PATH [--small-tokens 2000]
python token_cockpit.py simulate --from claude-opus --to claude-haiku --logs PATH

Add --json to any command for structured output you can reason over. --days N limits any command to the last N days.

Finding the usage log

The tool auto-detects common locations ($OPENCLAW_USAGE_LOG, ~/.openclaw/usage.jsonl, ~/.openclaw/logs/usage.jsonl, and the /data/.openclaw equivalents). If none exist, ask the user where their usage data lives and pass --logs. The loader is tolerant: it accepts JSONL or a JSON array, reads token counts from many field-name variants (input_tokens/prompt_tokens/tokens_in, etc.), and reads usage nested under a usage object. A bundled sample_usage.jsonl is included so you can demonstrate the output even before the real log is located.

A note on prices - read this before quoting dollars

The price table in token_cockpit.py is a set of editable defaults in USD per million tokens, and model prices change over time. Treat the script's dollar figures as estimates. When the user wants exact numbers, confirm current pricing and override with a pricing.json:

{
  "claude-opus": {"input": 15.0, "output": 75.0},
  "claude-haiku": {"input": 1.0, "output": 5.0},
  "gpt-4o-mini": {"input": 0.15, "output": 0.60}
}

Pass it with --pricing pricing.json. Any model with no matching entry is counted as $0 and clearly flagged (⚠) in the report so the totals are never silently wrong.

How to help

  1. Understand-the-bill requests: run report. Read back the headline (total + monthly projection) and the top one or two models by cost - that's where attention belongs. Don't recite every model.
  2. Save-money requests: run route first. It finds the specific waste (small tasks on premium models) and quantifies it. Then offer simulate for the bigger "what if I just switched defaults" question.
  3. Budget setup: run budget --limit X. The output is phrased as an alert message - if the user wants ongoing monitoring, this pairs naturally with a scheduled task that runs budget daily and messages them only when the level is WARN or OVER.

Interpreting the output honestly

  • The monthly projection extrapolates from the window's daily rate. Say so - a projection from three days of data is rougher than from thirty.
  • Routing and simulation savings assume the cheaper model uses the same token counts and does the job well enough. They're upper-bound estimates. Always pair the number with "verify quality before switching defaults" - a cheaper model that fails the task and forces a retry costs more, not less.
  • A clean route result ("no obvious wins") is a real and good answer. Don't manufacture savings that aren't there.

Pairs well with

A scheduled daily budget check that only pings when you cross 80% of your limit gives you a spend tripwire without having to think about it.

能力标签
requires-sensitive-credentials
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install token-cockpit
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /token-cockpit 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release of token-cockpit - Turn your OpenClaw/LLM usage logs into a clear dashboard of token spend, model costs, and savings opportunities—all local, no API needed. - Four commands: - `report` (breakdown/report with projection), - `budget` (alerts when near/over limit), - `route` (finds easily downgraded expensive model use), - `simulate` (estimates savings from switching models). - Supports JSONL and JSON logs, with autodetection and a bundled sample log for quick demo/testing. - Editable price table; outputs clear estimates with warnings if pricing is missing or outdated. - Designed to help you both understand spend (report) and reduce it (route/simulate).
元数据
Slug token-cockpit
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Token Cockpit 是什么?

See and slash your OpenClaw / LLM token bill. Use this skill whenever the user asks about token usage, model spend, API costs, or wants to save money on thei... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 61 次。

如何安装 Token Cockpit?

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

Token Cockpit 是免费的吗?

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

Token Cockpit 支持哪些平台?

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

谁开发了 Token Cockpit?

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

💬 留言讨论