Skip to main content

Token tracker for LLM CLI tools with live terminal dashboard

Project description

Tokentap (formerly Sherlock)

Token Tracker for LLM CLI Tools

Python License Platform Claude Code Gemini Codex MiniMax

InstallationQuick StartFeaturesCommandsContributing


tokentap tracks token usage for LLM CLI tools with a live terminal dashboard. See exactly how many tokens you're using in real-time.

Why tokentap?

  • Track Token Usage: See exactly how many tokens each request consumes
  • Monitor Context Windows: Visual fuel gauge shows cumulative usage against your limit
  • Debug Prompts: Automatically saves every prompt as markdown and JSON for review
  • Zero Configuration: No certificates, no setup - just install and go

Installation

pip install tokentap

Or install from source:

git clone https://github.com/jmuncor/tokentap.git
cd tokentap
pip install -e .

Requirements

  • Python 3.10+

Quick Start

Terminal 1: Start the Dashboard

tokentap start

You'll be prompted to choose where to save captured prompts, then the dashboard appears:

┌─────────────────────────────────────────────────────────────┐
│  TOKENTAP - LLM Traffic Inspector                           │
├─────────────────────────────────────────────────────────────┤
│  Context Usage  ████████████░░░░░░░░░░░░░░░░  42%           │
│                 (84,231 / 200,000 tokens)                   │
├─────────────────────────────────────────────────────────────┤
│  Time     Provider    Model                      Tokens     │
│  14:23:01 Anthropic   claude-sonnet-4-20250514   12,847     │
│  14:23:45 Anthropic   claude-sonnet-4-20250514   8,234      │
│  14:24:12 Anthropic   claude-sonnet-4-20250514   15,102     │
├─────────────────────────────────────────────────────────────┤
│  Last Prompt: "Can you help me refactor this function..."   │
└─────────────────────────────────────────────────────────────┘

Terminal 2: Run Your LLM Tool

# For Claude Code
tokentap claude

# For Gemini CLI (see known issues)
tokentap gemini

# For OpenAI Codex
tokentap codex

# For MiniMax-powered tools
tokentap run --provider minimax python my_app.py

That's it! Watch the dashboard update in real-time as you work.

Features

Live Terminal Dashboard

Real-time token tracking with color-coded fuel gauge:

  • Green: < 50% of limit
  • Yellow: 50-80% of limit
  • Red: > 80% of limit

Prompt Archive

Every intercepted request is saved to your chosen directory:

  • Markdown - Human-readable format with metadata
  • JSON - Raw API request body for debugging

Session Summary

When you exit, see your total usage:

Session complete. Total: 84,231 tokens across 12 requests.

Commands

Command Description
tokentap start Start the proxy and dashboard
tokentap claude Run Claude Code with proxy configured
tokentap gemini Run Gemini CLI with proxy configured
tokentap codex Run OpenAI Codex CLI with proxy configured
tokentap run --provider <name> <cmd> Run any command with proxy configured

Supported providers for --provider: anthropic, openai, gemini, minimax

Options

tokentap start [OPTIONS]

Options:
  -p, --port NUM    Proxy port (default: 8080)
  -l, --limit NUM   Token limit for fuel gauge (default: 200000)
tokentap claude [OPTIONS] [ARGS]...

Options:
  -p, --port NUM    Proxy port (default: 8080)

How It Works

┌─────────────────────────────────────────────────────────────────┐
│  Terminal 1: tokentap start                                     │
│  ┌─────────────────────────────────────────────────────────────┐│
│  │  HTTP Proxy (localhost:8080)                                ││
│  │  + Dashboard                                                ││
│  │  + Prompt Archive                                           ││
│  └─────────────────────────────────────────────────────────────┘│
└───────────────────────────────┬─────────────────────────────────┘
                                │ HTTP
                                │
┌───────────────────────────────┴─────────────────────────────────┐
│  Terminal 2: tokentap claude                                    │
│  ┌─────────────────────────────────────────────────────────────┐│
│  │  Sets ANTHROPIC_BASE_URL=http://localhost:8080              ││
│  │  Runs: claude                                               ││
│  └─────────────────────────────────────────────────────────────┘│
└─────────────────────────────────────────────────────────────────┘
                                │
                                │ HTTPS
                                ▼
                      ┌───────────────────┐
                      │ api.anthropic.com │
                      └───────────────────┘

For OpenAI-compatible providers like MiniMax, tokentap uses path-prefix routing so requests are forwarded to the correct upstream API:

tokentap run --provider minimax python my_app.py
  → sets OPENAI_BASE_URL=http://localhost:8080/minimax/v1
  → requests arrive at /minimax/v1/chat/completions
  → proxy strips prefix, forwards to https://api.minimax.io/v1/chat/completions

Supported Providers

Provider Command Status
Anthropic (Claude Code) tokentap claude Supported
Google (Gemini CLI) tokentap gemini Blocked by upstream issue
OpenAI (Codex) tokentap codex Supported
MiniMax tokentap run --provider minimax <cmd> Supported

Known Issues

Gemini CLI

Gemini CLI currently has a known issue where it ignores custom base URLs when using OAuth authentication. tokentap's Gemini support will work automatically once the Gemini CLI team fixes this issue.

Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Setup

git clone https://github.com/jmuncor/tokentap.git
cd tokentap
python -m venv venv
source venv/bin/activate
pip install -e .

License

This project is licensed under the MIT License - see the LICENSE file for details.


See what's really being sent to the LLM. Track. Learn. Optimize.

tokentap.ai

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tokentap-0.1.1.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tokentap-0.1.1-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file tokentap-0.1.1.tar.gz.

File metadata

  • Download URL: tokentap-0.1.1.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tokentap-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4af83eec6ac95fd9a76b0044d7c9cebb3f6779295cb7bb7fc0805d88ca1335c9
MD5 d7440b6c0da8a0afa573f4e6c29b75ee
BLAKE2b-256 d94368c93dc40bf6b015d0c9142092b1adc72bae71b82dbad45461cc64a7269a

See more details on using hashes here.

Provenance

The following attestation bundles were made for tokentap-0.1.1.tar.gz:

Publisher: publish.yml on jmuncor/tokentap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tokentap-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: tokentap-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 18.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tokentap-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 40d823ad97f6e6a1a94a289a0f6a6acb1971abdb3c4e6818b389ad1e7be53d95
MD5 7b220a7b7e0b262bb1873b233ffd5fa5
BLAKE2b-256 cff7117810309150c4c8cfd4f044c1a166183cf65e6ce686652abefce2688583

See more details on using hashes here.

Provenance

The following attestation bundles were made for tokentap-0.1.1-py3-none-any.whl:

Publisher: publish.yml on jmuncor/tokentap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page