汎用LLM・AI開発⭐ リポ 0品質スコア 60/100
api-cost-tracker
OpenAI、Anthropic、Google AIのAI API利用費を一元管理し、予算アラート、分析機能、最適化のヒントで効率的にコスト削減できます。
description の原文を見る
Track AI API costs across OpenAI, Anthropic, Google AI with budget alerts, analytics, and optimization tips
SKILL.md 本文
API コスト トラッカー 💰
複数のプロバイダ向けの包括的なAI APIコスト追跡。支出の監視、予算設定、アラート受信、AIコストの最適化ができます。
機能
- ✅ マルチプロバイダ対応 - OpenAI、Anthropic、Google AI
- ✅ リアルタイム追跡 - コストをリアルタイムで監視
- ✅ 予算アラート - 制限に近づいた時に通知
- ✅ 使用状況分析 - APIの使用状況を詳細に把握
- ✅ コスト最適化 - 支出を削減するためのヒント
- ✅ レポートエクスポート - JSON、CSV、Markdown形式
- ✅ 履歴データ - 時系列でコストを追跡
- ✅ モデル比較 - モデル間でのコスト比較
インストール
cd api-cost-tracker
npm install
クイックスタート
# すべてのプロバイダを追跡
node scripts/main.mjs track
# 特定のプロバイダを追跡
node scripts/main.mjs track --provider openai
# 分析を表示
node scripts/main.mjs analytics
# 予算を設定
node scripts/main.mjs budget set 100 --monthly
# レポートをエクスポート
node scripts/main.mjs export --format markdown --output report.md
設定
config.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リファレンス
track(options)
API使用状況とコストを追跡します。
オプション:
provider(文字列): 特定のプロバイダまたは 'all'period(文字列): 'today'、'week'、'month'、'all'
戻り値:
{
"total": 45.67,
"providers": {
"openai": 32.10,
"anthropic": 10.50,
"google": 3.07
},
"models": {
"gpt-4": 28.50,
"claude-3": 10.50
}
}
analytics(period)
詳細な分析を取得します。
期間: 'day'、'week'、'month'、'year'
戻り値:
- コスト傾向
- 使用パターン
- モデル効率
- 最適化の提案
budget.set(amount, period)
予算制限を設定します。
budget.check()
現在の予算状況を確認します。
export(format, options)
コストレポートをエクスポートします。
形式: 'json'、'csv'、'markdown'
使用例
日別コストの追跡
node scripts/main.mjs track --period today
出力:
💰 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)
予算アラートを設定
node scripts/main.mjs budget set 100 --monthly
node scripts/main.mjs alerts enable
月次レポートをエクスポート
node scripts/main.mjs export --format markdown --period month --output monthly-report.md
モデルを比較
node scripts/main.mjs compare --models gpt-4,claude-3,gemini-pro
料金リファレンス
OpenAI (1000トークンあたり)
- GPT-4: $0.03 (入力) / $0.06 (出力)
- GPT-4 Turbo: $0.01 / $0.03
- GPT-3.5 Turbo: $0.0005 / $0.0015
Anthropic (1000トークンあたり)
- Claude-3 Opus: $0.015 / $0.075
- Claude-3 Sonnet: $0.003 / $0.015
- Claude-3 Haiku: $0.00025 / $0.00125
Google AI (1000トークンあたり)
- Gemini Pro: $0.00025 / $0.0005
- Gemini Ultra: $0.0025 / $0.0075
OpenClawとの統合
HEARTBEAT.md に追加して自動追跡を実行します:
6時間ごと:
- 実行: node /path/to/api-cost-tracker/scripts/main.mjs track
- 予算が75%を超えた場合はアラート
自動予算監視
# crontab に追加
0 */6 * * * cd /path/to/api-cost-tracker && node scripts/main.mjs check-budget
高度な機能
コスト最適化のヒント
最適化分析を実行:
node scripts/main.mjs optimize
以下のような提案を取得:
- 単純なタスクはGPT-3.5に切り替える
- 高速応答にはClaude-3 Haikuを使用
- リクエストをバッチ化してAPIコールを削減
- 一般的な応答をキャッシュ
Webhook統合
Webhookにアラートを送信するよう設定:
{
"webhooks": [
{
"url": "https://your-slack-webhook.com",
"events": ["budget_exceeded", "high_usage"]
}
]
}
履歴分析
# 過去30日間を表示
node scripts/main.mjs history --days 30
# 月別に比較
node scripts/main.mjs compare --period month --previous
データストレージ
コストデータはローカルに保存されます:
data/
├── costs/
│ ├── 2026-03-01.json
│ ├── 2026-03-02.json
│ └── ...
├── budgets.json
└── alerts.log
トラブルシューティング
APIキーの問題
# APIキーをテスト
node scripts/main.mjs test-keys
データが見つからない
# データベースを再構築
node scripts/main.mjs rebuild
テスト
npm test
ライセンス
MIT - 個人使用および商用利用が可能です。
サポート
- GitHub Issues: [your-repo]
- OpenClaw Discord: https://discord.gg/clawd
ロードマップ
- その他のプロバイダ対応 (Cohere、AI21など)
- リアルタイムダッシュボード
- チーム間のコスト共有
- カスタム料金ルール
- 予測分析
ライセンス: MIT(寛容ライセンスのため全文を引用しています) · 原本リポジトリ
詳細情報
- 作者
- k5rs4n
- ライセンス
- MIT
- 最終更新
- 2026/3/1
Source: https://github.com/k5rs4n/api-cost-tracker / ライセンス: MIT