← Back to Skills Marketplace
charlie-morrison

api-cost-tracker

by charlie-morrison · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
102
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install ai-api-cost-tracker
Description
Track, analyze, and optimize AI API costs across OpenAI, Anthropic, OpenRouter, Google, and other LLM providers. Parses billing data, usage logs, or API resp...
README (SKILL.md)

API Cost Tracker

Analyze and optimize AI API costs across multiple providers with detailed breakdowns, trend detection, and actionable savings recommendations.

Quick Start

# Analyze OpenRouter usage (from activity page export)
python3 scripts/api_cost_tracker.py openrouter --file activity.json

# Analyze OpenAI usage (from billing export)
python3 scripts/api_cost_tracker.py openai --file usage.json

# Analyze from environment (auto-detect provider from API keys)
python3 scripts/api_cost_tracker.py auto --days 30

# Cost breakdown by model
python3 scripts/api_cost_tracker.py openrouter --file activity.json --by model

# Cost breakdown by day with trend analysis
python3 scripts/api_cost_tracker.py openrouter --file activity.json --by day --trends

# Find most expensive requests
python3 scripts/api_cost_tracker.py openrouter --file activity.json --top 20

# Compare current vs optimized (model substitution analysis)
python3 scripts/api_cost_tracker.py openrouter --file activity.json --optimize

# Set budget alert threshold
python3 scripts/api_cost_tracker.py openrouter --file activity.json --budget 50.00

# Output as markdown report
python3 scripts/api_cost_tracker.py openrouter --file activity.json --output markdown

# Output as JSON
python3 scripts/api_cost_tracker.py openrouter --file activity.json --output json

Supported Providers

Provider Input Format Auto-detect
OpenAI Billing CSV/JSON export, API responses OPENAI_API_KEY
Anthropic Usage API, console export ANTHROPIC_API_KEY
OpenRouter Activity JSON, API responses OPENROUTER_API_KEY
Google AI Billing export GOOGLE_AI_API_KEY
Generic CSV with columns: timestamp, model, tokens_in, tokens_out, cost N/A

Analysis Features

  1. Cost Breakdown — by model, day, week, feature/tag, request type
  2. Trend Detection — spending velocity, anomaly detection, projected monthly cost
  3. Optimization Report — model substitution suggestions, caching opportunities, prompt compression candidates
  4. Budget Alerts — daily/weekly/monthly thresholds with projected overrun warnings
  5. Top Spenders — most expensive individual requests or sessions
  6. Model Comparison — cost-per-quality analysis using common benchmarks

Output Formats

  • Terminal (default) — colored tables and charts
  • Markdown — report suitable for documentation
  • JSON — structured data for programmatic use
  • CSV — spreadsheet-compatible export

How It Works

The script:

  1. Reads usage data from the specified source (file, API, or environment)
  2. Normalizes all entries to a common format (timestamp, model, input_tokens, output_tokens, cost)
  3. Applies current provider pricing to calculate/verify costs
  4. Groups and aggregates by the requested dimension
  5. Runs optimization analysis comparing current models to cheaper alternatives
  6. Generates the report in the requested format

Pricing Database

Built-in pricing for 50+ models (updated March 2026). Override with --pricing custom_prices.json.

Requirements

  • Python 3.8+
  • No external dependencies (stdlib only)
Usage Guidance
This skill appears to be a local billing/usage analyzer and is largely coherent, but there are inconsistencies you should resolve before trusting it with real billing data or API keys: - Inspect the full scripts for network activity: search for imports or uses of requests, urllib, http.client, socket, or subprocess; if present, review where data is sent and to which endpoints. - Confirm whether the 'auto' mode actually reads API keys from the environment or calls provider APIs. The docs mention keys (OPENAI_API_KEY, etc.) but the manifest lists none — ask the author or open the full code to verify. - Test first on non-sensitive, synthetic billing exports to confirm behavior and outputs. - If you must provide API keys for auto-fetching, only do so after verifying the code path that uses them and ideally run the script in a restricted environment (isolated VM or container) to limit exposure. - If you want higher assurance, request the author to declare required env vars explicitly and include example runs that show remote fetches/endpoints; absence of those details lowers confidence. If you provide the rest of the script (the truncated portion), I can re-evaluate and raise the confidence level or change the verdict if network calls or credential misuse are found.
Capability Analysis
Type: OpenClaw Skill Name: ai-api-cost-tracker Version: 1.0.0 The skill is a local utility for analyzing AI API usage and costs from billing exports (JSON/CSV). The script `scripts/api_cost_tracker.py` uses only standard Python libraries to parse data, calculate costs based on a built-in pricing database, and generate reports. It contains no network access, no file writing, and no suspicious execution logic. While the `SKILL.md` documentation contains some minor inconsistencies regarding environment variable usage, the actual code is restricted to local file processing and is entirely consistent with its stated purpose.
Capability Assessment
Purpose & Capability
Name/description (API cost tracking, multi-provider) align with the included Python script which parses provider exports, normalizes entries, computes costs, and generates reports. However, the SKILL.md and provider table explicitly mention auto-detection from environment API keys (OPENAI_API_KEY, ANTHROPIC_API_KEY, etc.) while the package lists no required env vars and the visible code parses files only — this mismatch is unexplained and could be either a documentation error or an unshown code path that reads credentials.
Instruction Scope
Runtime instructions and Quick Start examples focus on local file analysis (CSV/JSON) and producing reports. The script portions shown parse files and do not contain obvious data-exfiltration steps or external endpoints. Still, the SKILL.md suggests 'analyze from environment' and 'API responses', and the rest of the script (truncated) may include API callers; that would expand scope. At present there is no instruction to read unrelated system files or to transmit data elsewhere.
Install Mechanism
No install spec is provided and the skill is instruction/code-only. Nothing in the manifest indicates downloads or archive extraction, so the install risk is low (the only artifact is the bundled Python script).
Credentials
The SKILL.md references provider API keys for auto-detection, but requires.env is empty and the visible code does not read environment credentials. This discrepancy is notable: if full script includes paths that read API keys or call provider APIs, requesting those credentials would be proportionate; as-is, the declared environment access is absent and unclear.
Persistence & Privilege
Skill does not request always:true, does not declare any persistent system hooks, and the visible code appears to operate transiently on provided files and produce outputs. There is no evidence it modifies other skills or agent-wide configuration.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install ai-api-cost-tracker
  3. After installation, invoke the skill by name or use /ai-api-cost-tracker
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
Initial release
Metadata
Slug ai-api-cost-tracker
Version 1.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is api-cost-tracker?

Track, analyze, and optimize AI API costs across OpenAI, Anthropic, OpenRouter, Google, and other LLM providers. Parses billing data, usage logs, or API resp... It is an AI Agent Skill for Claude Code / OpenClaw, with 102 downloads so far.

How do I install api-cost-tracker?

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

Is api-cost-tracker free?

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

Which platforms does api-cost-tracker support?

api-cost-tracker is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created api-cost-tracker?

It is built and maintained by charlie-morrison (@charlie-morrison); the current version is v1.0.0.

💬 Comments