← 返回 Skills 市场
johnnywang2001

LLM Cost Tracker

作者 John Wang · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
310
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install llm-cost-tracker
功能描述
Track, analyze, and optimize LLM API spending across providers (OpenAI, Anthropic, Google, DeepSeek, etc.). Use when the user asks about API costs, token usa...
使用说明 (SKILL.md)

API Cost Tracker

Monitor and optimize your LLM API spending directly from your agent.

Quick Start

Run cost analysis:

python3 scripts/cost_tracker.py --summary

Commands

Check Current Spend

python3 scripts/cost_tracker.py --provider openai --period today
python3 scripts/cost_tracker.py --provider anthropic --period week
python3 scripts/cost_tracker.py --all --period month

Set Budget Alert

python3 scripts/cost_tracker.py --set-budget 100 --period month --alert telegram

Cost Breakdown by Model

python3 scripts/cost_tracker.py --breakdown model --period week

Optimization Recommendations

python3 scripts/cost_tracker.py --optimize

This analyzes usage patterns and recommends:

  • Model downgrades for simple tasks (e.g., use Haiku instead of Opus for classification)
  • Caching opportunities (repeated similar prompts)
  • Batch processing windows (off-peak pricing where available)
  • Context window optimization (trim unnecessary context)

Supported Providers

Provider Method Setup
OpenAI Usage API OPENAI_API_KEY env var
Anthropic Usage API ANTHROPIC_API_KEY env var
Google AI Billing API GOOGLE_API_KEY env var
DeepSeek Usage API DEEPSEEK_API_KEY env var

Budget Alerts

Configure in ~/.openclaw/cost-tracker.json:

{
  "budgets": {
    "daily": 10,
    "weekly": 50,
    "monthly": 200
  },
  "alertChannels": ["telegram", "discord"],
  "alertThresholds": [50, 75, 90, 100]
}

Alerts fire at each threshold percentage. At 100%, optionally pause non-critical agent tasks.

Output Format

Reports generate as markdown tables suitable for any messaging surface:

Provider    | Model              | Tokens    | Cost
------------|--------------------|-----------|---------
Anthropic   | claude-opus-4-6   | 2.1M      | $63.00
Anthropic   | claude-sonnet-4-6 | 5.4M      | $16.20
OpenAI      | gpt-4o            | 1.8M      | $9.00
            | TOTAL              |           | $88.20

Advanced: Cost Optimization Patterns

See references/optimization-guide.md for detailed strategies on reducing API spend by 30-60% without sacrificing quality.

安全使用建议
This package mostly looks like a normal local cost-tracker, but there are important inconsistencies and an incomplete file to review before trusting it: - Metadata mismatch: the registry says no required env vars, yet the SKILL.md and script read provider API keys (OPENAI_API_KEY, ANTHROPIC_API_KEY, GOOGLE_API_KEY, DEEPSEEK_API_KEY). Don't supply API keys until you confirm the code's behavior. - Files written/read: the script will create ~/.openclaw/cost-tracker.json and a ~/.openclaw/cost-data directory and write/read provider_*.json files. Expect local persistence of usage data. If that's unwanted, run the script in a controlled environment or change the paths before use. - Alerts and external endpoints: SKILL.md mentions alert channels (telegram/discord) but the visible code is truncated and does not show how alerts are sent. Inspect the rest of scripts/cost_tracker.py for any networking code that posts to third-party endpoints, and for any tokens required for alerts. - Network access: the script performs outgoing HTTPS requests to provider APIs. Only provide API keys for accounts you trust to be accessed by this tool, and consider using read-only/billing-scoped credentials if available. - To be safer: review the entire scripts/cost_tracker.py (the file appears truncated in the bundle), confirm there are no hard-coded remote endpoints beyond provider APIs, and run the script in a sandbox or isolated environment first. If you plan to use alerts, verify exactly which alert tokens are required and whether they are stored locally. If anything is unclear, treat the metadata mismatch as a red flag and request an updated manifest that accurately lists required env vars and alerting behavior.
功能分析
Type: OpenClaw Skill Name: llm-cost-tracker Version: 1.0.0 The skill bundle is a legitimate utility for monitoring and optimizing LLM API expenditures. The primary script, `scripts/cost_tracker.py`, accesses API keys from environment variables to query official usage endpoints (specifically OpenAI) and manages local usage logs in the user's home directory. There is no evidence of data exfiltration, malicious execution, or prompt injection; the code is well-structured, uses standard libraries, and aligns perfectly with the stated purpose in `SKILL.md`.
能力评估
Purpose & Capability
The name/description (LLM cost tracking and optimization) align with the included Python script which reads local usage files, queries provider usage APIs (OpenAI via OPENAI_API_KEY) and calculates costs. However the registry metadata claims no required environment variables or credentials while SKILL.md and the script require provider API keys (OPENAI_API_KEY, ANTHROPIC_API_KEY, GOOGLE_API_KEY, DEEPSEEK_API_KEY). This mismatch is unexplained and reduces trust in the metadata.
Instruction Scope
SKILL.md instructs running the bundled script and editing ~/.openclaw/cost-tracker.json, which the script indeed reads/writes. The instructions do not ask for unrelated files. The script performs network calls to provider APIs (expected), writes/reads files under ~/.openclaw (expected), and loads local provider_*.json usage files. The SKILL.md and registry fail to explicitly declare the environment variables the runtime code checks, and the SKILL.md references alert channels (telegram, discord) but the visible script portion does not show how alerts are delivered — the file is truncated, so the alerting/notification behavior must be reviewed before trusting it.
Install Mechanism
No install spec or downloads are present; this is a simple Python script included in the skill bundle. No external installers or archive extraction are performed by the registry metadata. Risk from install mechanism is low, but the code will be written to disk when the skill is installed (already present in the bundle).
Credentials
The tool legitimately needs provider API keys to query usage, which is proportionate to its function. However the skill's declared requirements list no required environment variables or primary credential while both SKILL.md and the script expect OPENAI_API_KEY, ANTHROPIC_API_KEY, GOOGLE_API_KEY, and DEEPSEEK_API_KEY. This inconsistency is suspicious: the skill will access secrets (API keys) but the registry metadata does not declare them. Also the SKILL.md mentions alert channels (telegram/discord) that commonly require tokens — those tokens are not documented in metadata either. Verify which credentials the skill will actually use and why they were omitted from metadata.
Persistence & Privilege
always:false (normal). The script creates and writes config and usage files under ~/.openclaw (CONFIG_PATH, DATA_PATH) and logs local usage; this is expected for a cost tracker and does not modify other skills or system-wide settings. No elevated privileges or permanent platform-wide overrides are requested in the visible code.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install llm-cost-tracker
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /llm-cost-tracker 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Track LLM API spending across OpenAI, Anthropic, Google, DeepSeek. Budget alerts, cost breakdowns, optimization tips.
元数据
Slug llm-cost-tracker
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

LLM Cost Tracker 是什么?

Track, analyze, and optimize LLM API spending across providers (OpenAI, Anthropic, Google, DeepSeek, etc.). Use when the user asks about API costs, token usa... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 310 次。

如何安装 LLM Cost Tracker?

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

LLM Cost Tracker 是免费的吗?

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

LLM Cost Tracker 支持哪些平台?

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

谁开发了 LLM Cost Tracker?

由 John Wang(@johnnywang2001)开发并维护,当前版本 v1.0.0。

💬 留言讨论