📇 🏠 🍎 🪟 🐧 - Token usage and cost tracking for OpenAI and Claude APIs with real-time session tracking
LLM Token Tracker 🧮
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
Token usage tracker for OpenAI, Claude, and Gemini APIs with **MCP (Model Context Protocol) support**. Pass accurate API costs to your users.
✨ Features
- 🎯 **Simple Integration** - One line to wrap your API client
- 📊 **Automatic Tracking** - No manual token counting
- 💰 **Accurate Pricing** - Up-to-date pricing for all models (2025)
- 🔄 **Multiple Providers** - OpenAI, Claude, and Gemini support
- 📈 **User Management** - Track usage per user/session
- 🌐 **Currency Support** - USD and KRW
- 🤖 **MCP Server** - Use directly in Claude Desktop!
- 🆕 **Intuitive Session Tracking** - Real-time usage with progress bars
📦 Installation
🚀 Quick Start
Option 1: Use as Library
🔧 With Real APIs
To use with actual OpenAI/Anthropic APIs:
Option 2: Use as MCP Server
Add to Claude Desktop settings (~/Library/Application Support/Claude/claude_desktop_config.json):
Then in Claude:
- **"Calculate current session usage"** - See current session usage with intuitive format
- **"Calculate current conversation cost"** - Get cost breakdown with input/output tokens
- "Track my API usage"
- "Compare costs between GPT-4 and Claude"
- "Show my total spending today"
Available MCP Tools
1. **get_current_session** - 🆕 Get current session usage (RECOMMENDED)
- Returns: Used/Remaining tokens, Input/Output breakdown, Cost, Progress bar
- Default user_id: current-session
- Default budget: 190,000 tokens
- **Perfect for real-time conversation tracking!**
2. **track_usage** - Track token usage for an AI API call
- Parameters: provider, model, input_tokens, output_tokens, user_id
3. **get_usage** - Get usage summary for specific user or all users
4. **compare_costs** - Compare costs between different models
5. **clear_usage** - Clear usage data for a user
Example MCP Output
📊 Supported Models & Pricing (Updated 2025)
OpenAI (2025)
| Model | Input (per 1K tokens) | Output (per 1K tokens) | Notes |
|-------|----------------------|------------------------|-------|
| **GPT-5 Series** | | | |
| GPT-5 | $0.00125 | $0.010 | Latest flagship model |
| GPT-5 Mini | $0.00025 | $0.0010 | Compact version |
| **GPT-4.1 Series** | | | |
| GPT-4.1 | $0.0020 | $0.008 | Advanced reasoning |
| GPT-4.1 Mini | $0.00015 | $0.0006 | Cost-effective |
| **GPT-4o Series** | | | |
| GPT-4o | $0.0025 | $0.010 | Multimodal |
| GPT-4o Mini | $0.00015 | $0.0006 | Fast & cheap |
| **o1 Reasoning Series** | | | |
| o1 | $0.015 | $0.060 | Advanced reasoning |
| o1 Mini | $0.0011 | $0.0044 | Efficient reasoning |
| o1 Pro | $0.015 | $0.060 | Pro reasoning |
| **Legacy Models** | | | |
| GPT-4 Turbo | $0.01 | $0.03 | |
| GPT-4 | $0.03 | $0.06 | |
| GPT-3.5 Turbo | $0.0005 | $0.0015 | Most affordable |
| **Media Models** | | | |
| DALL-E 3 | $0.040 per image | - | Image generation |
| Whisper | $0.006 per minute | - | Speech-to-text |
Anthropic (2025)
| Model | Input (per 1K tokens) | Output (per 1K tokens) | Notes |
|-------|----------------------|------------------------|-------|
| **Claude 4 Series** | | | |
| Claude Opus 4.1 | $0.015 | $0.075 | Most powerful |
| Claude Opus 4 | $0.015 | $0.075 | Flagship model |
| Claude Sonnet 4.5 | $0.003 | $0.015 | Best for coding |
| Claude Sonnet 4 | $0.003 | $0.015 | Balanced |
| **Claude 3 Series** | | | |
| Claude 3.5 Sonnet | $0.003 | $0.015 | |
| Claude 3.5 Haiku | $0.00025 | $0.00125 | Fastest |