Track and manage token usage across multiple AI providers (OpenAI, Anthropic, Gemini) with comprehensive cost analysis and session monitoring.
Real-time tracking: Monitor token consumption automatically via API client wrappers or manually, with session progress bars showing used/remaining tokens against configurable budgets
Cost analysis: Calculate costs in USD and KRW with real-time exchange rates, compare pricing between models, and access up-to-date 2025 pricing
User management: Track usage per user with customizable budgets, retrieve individual or overview summaries, and clear user-specific data
Data persistence: Maintain session data across server restarts with automatic historical tracking
MCP integration: Use as a Model Context Protocol server in Claude Desktop for real-time conversation tracking and cost monitoring
Provides automatic token usage tracking and cost calculation for OpenAI API calls, supporting all GPT models including GPT-4, GPT-3.5 Turbo, DALL-E 3, and Whisper with real-time usage monitoring and pricing.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@llm-token-trackercalculate current conversation cost"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
LLM Token Tracker ๐งฎ
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
get_current_session- ๐ Get current session usage (RECOMMENDED)Returns: Used/Remaining tokens, Input/Output breakdown, Cost, Progress bar
Default user_id:
current-sessionDefault budget: 190,000 tokens
Perfect for real-time conversation tracking!
track_usage- Track token usage for an AI API callParameters: provider, model, input_tokens, output_tokens, user_id
get_usage- Get usage summary for specific user or all userscompare_costs- Compare costs between different modelsclear_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 |
Claude 3 Opus | $0.015 | $0.075 | |
Claude 3 Sonnet | $0.003 | $0.015 | |
Claude 3 Haiku | $0.00025 | $0.00125 | Most affordable |
Google Gemini (2025)
Model | Input (per 1K tokens) | Output (per 1K tokens) | Notes |
Gemini 2.0 Series | |||
Gemini 2.0 Flash (Exp) | Free | Free | Experimental preview |
Gemini 2.0 Flash Thinking | Free | Free | Reasoning preview |
Gemini 1.5 Series | |||
Gemini 1.5 Pro | $0.00125 | $0.005 | Most capable |
Gemini 1.5 Flash | $0.000075 | $0.0003 | Fast & efficient |
Gemini 1.5 Flash-8B | $0.0000375 | $0.00015 | Ultra-fast |
Gemini 1.0 Series | |||
Gemini 1.0 Pro | $0.0005 | $0.0015 | Legacy model |
Gemini 1.0 Pro Vision | $0.00025 | $0.0005 | Multimodal |
Gemini Ultra | $0.002 | $0.006 | Premium tier |
Note: Prices shown are per 1,000 tokens. Batch API offers 50% discount. Prompt caching can reduce costs by up to 90%.
๐ฏ Examples
Run the example:
Check examples/basic-usage.js for detailed usage patterns.
๐ API Reference
new TokenTracker(config)
config.currency: 'USD' or 'KRW' (default: 'USD')config.webhookUrl: Optional webhook for usage notifications
tracker.wrap(client)
Wrap an OpenAI or Anthropic client for automatic tracking.
tracker.forUser(userId)
Create a user-specific tracker instance.
tracker.startTracking(userId?, sessionId?)
Start manual tracking session. Returns tracking ID.
tracker.endTracking(trackingId, usage)
End tracking and record usage.
tracker.getUserUsage(userId)
Get total usage for a user.
tracker.getAllUsersUsage()
Get usage summary for all users.
๐ Development
๐ License
MIT
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
๐ Issues
For bugs and feature requests, please create an issue.
๐ฆ What's New in v2.4.0
๐ Gemini API Support - Full integration with Google's Gemini models
๐ Gemini 2.0 Support - Free preview models included
๐ Enhanced Pricing - Up-to-date Gemini 1.5 and 2.0 pricing
๐ง Auto-detection - Automatic Gemini client wrapping
๐ฐ Cost Comparison - Compare Gemini with OpenAI and Claude
๐ฆ What's New in v2.3.0
๐ฑ Real-time exchange rates - Automatic USD to KRW conversion
๐ Uses exchangerate-api.com for accurate rates
๐พ 24-hour caching to minimize API calls
๐ New
get_exchange_ratetool to check current rates๐ Background auto-updates with fallback support
What's New in v2.2.0
๐๏ธ File-based persistence - Session data survives server restarts
๐พ Automatic saving to
~/.llm-token-tracker/sessions.json๐ Works for both npm and local installations
๐ Historical data tracking across sessions
๐ฏ Zero configuration required - just works!
What's New in v2.1.0
๐ Added
get_current_sessiontool for intuitive session tracking๐ Real-time progress bars and visual indicators
๐ฐ Enhanced cost breakdown with input/output token separation
๐จ Improved formatting with thousands separators
๐ง Better default user_id handling (
current-session)
Built with โค๏ธ for developers who need transparent AI API billing.