api-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 usage, billing, budget alerts, cost optimization, or wants to monitor how much their OpenClaw agent is spending. Supports daily/weekly/monthly breakdowns, per-model cost analysis, budget threshold alerts, and cost reduction recommendations.

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "api-cost-tracker" with this command: npx skills add Johnnywang2001/llm-cost-tracker

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

ProviderMethodSetup
OpenAIUsage APIOPENAI_API_KEY env var
AnthropicUsage APIANTHROPIC_API_KEY env var
Google AIBilling APIGOOGLE_API_KEY env var
DeepSeekUsage APIDEEPSEEK_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.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

Sendflare

通过 Sendflare SDK 发送带附件的电子邮件,管理联系人列表,支持 CC/BCC 和安全 API 认证。

Registry SourceRecently Updated
General

Playtomic - Book courts using padel-tui

This skill should be used when the user asks to "book a padel court", "find available padel courts", "search padel courts near me", "reserve a Playtomic cour...

Registry SourceRecently Updated
General

Fund Keeper

国内场外基金智能顾问 + 股票行情查询。实时估值、买卖建议、收益统计、定投计划、OCR 识图、股票 - 基金联动。支持离线模式、多数据源缓存。

Registry SourceRecently Updated