Skip to main content

Token monitor for coding agents — like htop for AI spend

Project description

tktop

Token monitor for coding agents. Like htop for your AI spend.

Features

  • Live dashboard — real-time token usage breakdown (input/output/cache)
  • Token flow graph — sparkline showing output tokens per turn
  • Tool stats — see which tools consume the most calls
  • Drift detection — 9 algorithms detecting loops, thrashing, runaway sessions
  • Cost tracking — per-session cost estimates by model
  • Turn drill-down — inspect individual turns with token split and content preview
  • LLM analysis — on-demand optimization suggestions via Ollama/Anthropic/Vertex AI/OpenAI

Install

Requires Python 3.10 or newer.

# From PyPI
pip install tktop

# Upgrade to the latest release
pip install -U tktop

Usage

tktop              # launch interactive session list
tktop -h           # show help
tktop -v           # show version
tktop info         # print environment summary for bug reports
tktop doctor       # diagnose local setup

tktop doctor checks the settings file, Claude/Codex data directories, adapter discovery, and selected LLM provider configuration without contacting external LLM APIs.

Keybindings

Key Action
↑/↓ or j/k Navigate
enter Select / drill-down
a Run LLM analysis
r Refresh
escape Back
q Quit

Supported Agents

  • Claude Code
  • Codex
  • Cursor (planned)
  • Aider (planned)

LLM Analysis

The settings file is created at ~/.tktop/settings.json the first time tktop loads its configuration. View its path and resolved values with:

tktop config path
tktop config show

Example configuration:

{
  "session_adapter": "auto",
  "default_provider": "ollama",
  "ui": {
    "show_token_flow": false
  },
  "agents": {
    "claude": {
      "dir": "~/.claude"
    },
    "codex": {
      "dir": "~/.codex"
    }
  },
  "providers": {
    "ollama": {
      "host": "http://localhost:11434",
      "model": "llama3"
    },
    "anthropic": {
      "api_key": "",
      "model": "claude-sonnet-4-6"
    },
    "vertex": {
      "project": "",
      "region": "us-east5",
      "model": "claude-sonnet-4-6"
    },
    "openai": {
      "base_url": "https://api.openai.com/v1",
      "api_key": "",
      "model": "gpt-4o"
    }
  }
}

session_adapter accepts auto, claude, or codex. Supported analysis providers are ollama, anthropic, vertex, and openai.

Environment variables override settings.json. Common overrides are:

TKTOP_SESSION_ADAPTER=codex
TKTOP_CODEX_DIR=~/.codex
TKTOP_LLM_PROVIDER=openai
TKTOP_OPENAI_API_KEY=sk-...
TKTOP_OPENAI_MODEL=gpt-4o

For source checkouts, .env.example lists all supported environment variables. Prefer environment variables for API keys instead of storing secrets in JSON.

Development

make install  # install in dev mode
make test     # run tests
make clean    # clean build artifacts

Local development still uses an editable install:

pip install -e ".[dev]"

Use these commands while developing:

make run           # run directly from the editable source checkout
make check         # lint, security scan, and full tests
make package-test  # build and install the wheel in an isolated local venv
make package-run   # launch the locally built wheel

make package-test uses .venvs/package-test, which is ignored by git. It tests the same wheel artifact that would be uploaded to PyPI, without publishing anything.

For maintainers, a versioned release can be prepared with:

make release VERSION=0.1.1

Devbox

If you have the Devbox CLI installed, you can bootstrap the repo with:

devbox shell

On first entry, the shell creates .venv, installs .[dev], and activates the environment for the session.

License: MIT. See LICENSE.

Repository instructions for Codex are in AGENTS.md. The current design is documented in docs/specs/2026-06-08-tktop-design.md.

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

tktop-1.0.0.tar.gz (87.7 kB view details)

Uploaded Source

Built Distribution

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

tktop-1.0.0-py3-none-any.whl (43.4 kB view details)

Uploaded Python 3

File details

Details for the file tktop-1.0.0.tar.gz.

File metadata

  • Download URL: tktop-1.0.0.tar.gz
  • Upload date:
  • Size: 87.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tktop-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2702fea161216d8bed38f431a8bf188a6cff6496c1a8cff34ce71953f69e8b76
MD5 7e8dd46b1a0b883b99b4403836722dcb
BLAKE2b-256 917c36f79be9d16771da43405f7a982ca8ed5f013554762c90c1489b39d7b7e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for tktop-1.0.0.tar.gz:

Publisher: release.yml on chanilharisankar/tktop

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

File details

Details for the file tktop-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: tktop-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 43.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tktop-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f36bbe265429d99079bdc1c6ac58ebb792618f4429aa5960c07db4ad7d7268ce
MD5 35b587f8ab3f10934e180cf096defc60
BLAKE2b-256 c53b375f4f2806c1cd97b0a782f5bc9604fd57e0975414248b8a8275c53a4ee2

See more details on using hashes here.

Provenance

The following attestation bundles were made for tktop-1.0.0-py3-none-any.whl:

Publisher: release.yml on chanilharisankar/tktop

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