← Back to Skills Marketplace
johnnywang2001

LLM Cost Tracker

by John Wang · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
310
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install llm-cost-tracker
Description
Track, analyze, and optimize LLM API spending across providers (OpenAI, Anthropic, Google, DeepSeek, etc.). Use when the user asks about API costs, token usa...
README (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.

Usage Guidance
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.
Capability Analysis
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`.
Capability Assessment
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.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install llm-cost-tracker
  3. After installation, invoke the skill by name or use /llm-cost-tracker
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
Track LLM API spending across OpenAI, Anthropic, Google, DeepSeek. Budget alerts, cost breakdowns, optimization tips.
Metadata
Slug llm-cost-tracker
Version 1.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is 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... It is an AI Agent Skill for Claude Code / OpenClaw, with 310 downloads so far.

How do I install LLM Cost Tracker?

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

Is LLM Cost Tracker free?

Yes, LLM Cost Tracker is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does LLM Cost Tracker support?

LLM Cost Tracker is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created LLM Cost Tracker?

It is built and maintained by John Wang (@johnnywang2001); the current version is v1.0.0.

💬 Comments