返回顶部
🇺🇸 English
🇨🇳 简体中文
🇨🇳 繁體中文
🇺🇸 English
🇯🇵 日本語
🇰🇷 한국어
🇫🇷 Français
🇩🇪 Deutsch
🇪🇸 Español
🇷🇺 Русский
a

api-cost-tracker

Track AI API costs across OpenAI, Anthropic, Google AI with budget alerts, analytics, and optimization tips

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
418
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

api-cost-tracker

# API Cost Tracker 💰 Comprehensive AI API cost tracking across multiple providers. Monitor spending, set budgets, get alerts, and optimize your AI costs. ## Features - ✅ **Multi-Provider Support** - OpenAI, Anthropic, Google AI - ✅ **Real-Time Tracking** - Monitor costs as they happen - ✅ **Budget Alerts** - Get notified when approaching limits - ✅ **Usage Analytics** - Detailed insights into API usage - ✅ **Cost Optimization** - Tips to reduce spending - ✅ **Export Reports** - JSON, CSV, Markdown formats - ✅ **Historical Data** - Track costs over time - ✅ **Model Comparison** - Compare costs across models ## Installation ```bash cd api-cost-tracker npm install ``` ## Quick Start ```bash # Track all providers node scripts/main.mjs track # Track specific provider node scripts/main.mjs track --provider openai # View analytics node scripts/main.mjs analytics # Set budget node scripts/main.mjs budget set 100 --monthly # Export report node scripts/main.mjs export --format markdown --output report.md ``` ## Configuration Edit `config.json`: ```json { "providers": { "openai": { "enabled": true, "apiKey": "${OPENAI_API_KEY}" }, "anthropic": { "enabled": true, "apiKey": "${ANTHROPIC_API_KEY}" }, "google": { "enabled": true, "apiKey": "${GOOGLE_AI_KEY}" } }, "budgets": { "daily": 10, "weekly": 50, "monthly": 200 }, "alerts": { "enabled": true, "thresholds": [50, 75, 90, 100], "webhook": "https://your-webhook.com/alert" }, "tracking": { "autoTrack": true, "interval": 300000 } } ``` ## API Reference ### `track(options)` Track API usage and costs. **Options:** - `provider` (string): Specific provider or 'all' - `period` (string): 'today', 'week', 'month', 'all' **Returns:** ```json { "total": 45.67, "providers": { "openai": 32.10, "anthropic": 10.50, "google": 3.07 }, "models": { "gpt-4": 28.50, "claude-3": 10.50 } } ``` ### `analytics(period)` Get detailed analytics. **Period:** 'day', 'week', 'month', 'year' **Returns:** - Cost trends - Usage patterns - Model efficiency - Optimization suggestions ### `budget.set(amount, period)` Set budget limit. ### `budget.check()` Check current budget status. ### `export(format, options)` Export cost report. **Formats:** 'json', 'csv', 'markdown' ## Usage Examples ### Track Daily Costs ```bash node scripts/main.mjs track --period today ``` Output: ``` 💰 API Costs - Today ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ OpenAI GPT-4: $12.50 (125K tokens) GPT-3.5: $2.30 (230K tokens) Subtotal: $14.80 Anthropic Claude-3: $8.20 (82K tokens) Subtotal: $8.20 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Total: $23.00 Budget: $200/month (11.5% used) ``` ### Set Budget Alert ```bash node scripts/main.mjs budget set 100 --monthly node scripts/main.mjs alerts enable ``` ### Export Monthly Report ```bash node scripts/main.mjs export --format markdown --period month --output monthly-report.md ``` ### Compare Models ```bash node scripts/main.mjs compare --models gpt-4,claude-3,gemini-pro ``` ## Pricing Reference ### OpenAI (per 1K tokens) - GPT-4: $0.03 (input) / $0.06 (output) - GPT-4 Turbo: $0.01 / $0.03 - GPT-3.5 Turbo: $0.0005 / $0.0015 ### Anthropic (per 1K tokens) - Claude-3 Opus: $0.015 / $0.075 - Claude-3 Sonnet: $0.003 / $0.015 - Claude-3 Haiku: $0.00025 / $0.00125 ### Google AI (per 1K tokens) - Gemini Pro: $0.00025 / $0.0005 - Gemini Ultra: $0.0025 / $0.0075 ## Integration with OpenClaw Add to your HEARTBEAT.md for automated tracking: ```markdown Every 6 hours: - Run: node /path/to/api-cost-tracker/scripts/main.mjs track - Alert if budget > 75% ``` ### Automated Budget Monitoring ```bash # Add to crontab 0 */6 * * * cd /path/to/api-cost-tracker && node scripts/main.mjs check-budget ``` ## Advanced Features ### Cost Optimization Tips Run optimization analysis: ```bash node scripts/main.mjs optimize ``` Get suggestions like: - Switch to GPT-3.5 for simple tasks - Use Claude-3 Haiku for fast responses - Batch requests to reduce API calls - Cache common responses ### Webhook Integration Configure alerts to send to webhooks: ```json { "webhooks": [ { "url": "https://your-slack-webhook.com", "events": ["budget_exceeded", "high_usage"] } ] } ``` ### Historical Analysis ```bash # View last 30 days node scripts/main.mjs history --days 30 # Compare months node scripts/main.mjs compare --period month --previous ``` ## Data Storage Cost data is stored locally: ``` data/ ├── costs/ │ ├── 2026-03-01.json │ ├── 2026-03-02.json │ └── ... ├── budgets.json └── alerts.log ``` ## Troubleshooting ### API Key Issues ```bash # Test API keys node scripts/main.mjs test-keys ``` ### Missing Data ```bash # Rebuild database node scripts/main.mjs rebuild ``` ## Testing ```bash npm test ``` ## License MIT - Free for personal and commercial use. ## Support - GitHub Issues: [your-repo] - OpenClaw Discord: https://discord.gg/clawd ## Roadmap - [ ] More providers (Cohere, AI21, etc.) - [ ] Real-time dashboard - [ ] Team cost sharing - [ ] Custom pricing rules - [ ] Predictive analytics

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 api-cost-tracker-1776284604 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 api-cost-tracker-1776284604 技能

通过命令行安装

skillhub install api-cost-tracker-1776284604

下载

⬇ 下载 api-cost-tracker v1.0.0(免费)

文件大小: 10.8 KB | 发布时间: 2026-4-16 15:58

v1.0.0 最新 2026-4-16 15:58
Initial release of API Cost Tracker – monitor and manage AI API usage and costs across major providers.

- Track real-time spending on OpenAI, Anthropic, and Google AI APIs.
- Set budgets with customizable alerts and webhook integration.
- Analyze usage with detailed analytics and model cost comparisons.
- Export reports in JSON, CSV, or Markdown formats.
- Get optimization tips and maintain historical cost data locally.
- Supports automated checks, easy configuration, and troubleshooting commands.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部