AI Pipeline Tool

Token Tracker

Track AI token usage across sessions, tasks, and models. Set budgets, monitor costs, and get alerts before you overspend.

Get the CLI Tool

Run the Token Tracker locally as an MCP server, or try the interactive demo below.

npx @clinetools/token-tracker
Requires Node.js 18+
  • Multi-model pricing — Claude Sonnet, Opus, Haiku, GPT-4o, GPT-4o-mini
  • Budget alerts — warnings at 80%, 90%, and 100% thresholds
  • Aggregation — group usage by session, task, tool, or model
  • Period filtering — view usage for today, this week, this month, or all time
  • Persistent storage — usage data saved to JSON for historical tracking

How to Use It

Three steps to start tracking token usage and controlling AI costs.

1

Set a Budget

Define daily, weekly, or monthly token budgets to keep spending under control.

set_budget({ name: "daily-dev", limit: 100000, period: "daily" })
2

Track Usage

Log every API call with model, tokens, session, and task for full visibility.

track_usage({ inputTokens: 3000, outputTokens: 2000, model: "claude-sonnet", session: "dev-session", task: "code-review" })
3

Review Reports

Get aggregated reports grouped by session, task, tool, or model with cost breakdowns.

get_usage_report({ period: "today", groupBy: "model" })

MCP Client Configuration

{
  "mcpServers": {
    "token-tracker": {
      "command": "npx",
      "args": ["@clinetools/token-tracker"]
    }
  }
}

Example: Track and Report

// Prompt to your AI agent:
"Track that I used 5000 input and 3000 output tokens
on claude-sonnet for the code-review task"

// The agent calls:
track_usage({
  inputTokens: 5000,
  outputTokens: 3000,
  model: "claude-sonnet",
  task: "code-review"
})

// Output:
{
  "recorded": {
    "inputTokens": 5000,
    "outputTokens": 3000,
    "model": "claude-sonnet",
    "cost": 0.06
  },
  "totals": {
    "inputTokens": 42000,
    "outputTokens": 28000,
    "totalEntries": 15
  }
}

Example: Budget Alert

// Set a daily budget:
set_budget({ name: "daily", limit: 50000, period: "daily" })

// When usage approaches the limit, alerts appear:
{
  "alerts": [
    "WARNING: Budget \"daily\" (daily) is at 82% — 9,000 tokens remaining"
  ],
  "budgets": [{
    "name": "daily",
    "limit": 50000,
    "used": 41000,
    "remaining": 9000,
    "percentUsed": 82
  }]
}
Live Demo

Try It Online

Log token usage, set budgets, and see a live dashboard of costs and consumption.

Log Token Usage

Demo Presets

Usage Dashboard

0
Total Tokens
$0.000
Total Cost
0
Entries
0
Models Used

Recent Entries

No usage recorded yet. Log some tokens or try a demo preset.

Why Token Tracking Matters

Unmonitored AI usage leads to surprise bills — tracked usage leads to informed decisions.

Token Economics

Input tokens cost 3-20x less than output tokens. Understanding this ratio lets you design prompts that minimize expensive output while maximizing the value of cheaper input context.

Budget Strategies

Set daily budgets for development work and weekly budgets for production pipelines. Layer budgets at different periods to catch both short spikes and gradual overuse before they become costly.

Model Selection

Claude Haiku costs 60x less than Opus per token. Route simple tasks like summarization and triage to cheaper models, and reserve expensive models for complex reasoning that actually needs them.

Cost Optimization

Track per-task costs to find your most expensive workflows. A single poorly-designed prompt loop can consume more tokens than a week of normal usage. Usage data makes these patterns visible and fixable.

Track Every Token

Our Pro plan includes automated usage tracking with team dashboards and Slack alerts for budget thresholds.

View Plans