← 返回 Skills 市场
api-cost-tracker
作者
charlie-morrison
· GitHub ↗
· v1.0.0
· MIT-0
102
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install ai-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...
使用说明 (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
- Cost Breakdown — by model, day, week, feature/tag, request type
- Trend Detection — spending velocity, anomaly detection, projected monthly cost
- Optimization Report — model substitution suggestions, caching opportunities, prompt compression candidates
- Budget Alerts — daily/weekly/monthly thresholds with projected overrun warnings
- Top Spenders — most expensive individual requests or sessions
- 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:
- Reads usage data from the specified source (file, API, or environment)
- Normalizes all entries to a common format (timestamp, model, input_tokens, output_tokens, cost)
- Applies current provider pricing to calculate/verify costs
- Groups and aggregates by the requested dimension
- Runs optimization analysis comparing current models to cheaper alternatives
- 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)
安全使用建议
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.
功能分析
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.
能力评估
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.
如何使用
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install ai-api-cost-tracker - 安装完成后,直接呼叫该 Skill 的名称或使用
/ai-api-cost-tracker触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release
元数据
常见问题
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... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 102 次。
如何安装 api-cost-tracker?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install ai-api-cost-tracker」即可一键安装,无需额外配置。
api-cost-tracker 是免费的吗?
是的,api-cost-tracker 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
api-cost-tracker 支持哪些平台?
api-cost-tracker 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 api-cost-tracker?
由 charlie-morrison(@charlie-morrison)开发并维护,当前版本 v1.0.0。
推荐 Skills