Skip to main content

Anthropic Tokens Counter - count tokens for Claude models

Project description

ATC - Anthropic Tokens Counter

A command-line tool to count tokens for Anthropic's Claude models before sending requests.

Features

  • Count tokens for various Claude models (Opus, Sonnet, Haiku)
  • Read input from files or stdin
  • Model management with short and full names
  • Configurable default model
  • Cross-platform XDG configuration support

Installation

From Source

git clone <repository-url>
cd claude-count-tokens
pip install .

For Development

git clone <repository-url>
cd claude-count-tokens
pip install -e .

Setup

Before using ATC, you need to set your Anthropic API key:

export ANTHROPIC_API_KEY="your-api-key-here"

Usage

Count Tokens

Count tokens from stdin:

echo "hello world" | atc

Count tokens from a file:

atc CLAUDE.md
atc ./CLAUDE.md
atc ~/.claude/CLAUDE.md
atc /Users/foo/.claude/CLAUDE.md

Count tokens with a specific model:

echo "hello world" | atc --model sonnet
atc CLAUDE.md -m haiku

Model Management

List available models:

atc models

List models with full names:

atc models --verbose
atc models -v

Set default model:

atc models set-default sonnet

Available Models

Short Names

  • opus - Claude Opus 4.1 (default)
  • opus-4, opus-4.1 - Claude Opus 4.1
  • sonnet - Claude Sonnet 4.1
  • sonnet-4, sonnet-4.1 - Claude Sonnet 4.1
  • sonnet-3.7 - Claude Sonnet 3.7
  • haiku - Claude Haiku 3.5
  • haiku-3.5 - Claude Haiku 3.5
  • haiku-3 - Claude Haiku 3

Full Names

  • claude-opus-4-1-20250805
  • claude-sonnet-4-1-20250805
  • claude-sonnet-3-7-20240805
  • claude-haiku-3-5-20241022
  • claude-haiku-3-20240307

Configuration

ATC stores its configuration in $XDG_STATE_HOME/atc/settings.json (or ~/.local/state/atc/settings.json if XDG_STATE_HOME is not set).

The configuration file stores:

  • Default model selection

Requirements

  • Python 3.8+
  • anthropic Python library
  • Valid Anthropic API key

License

MIT License

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

anthropic_token_counter-0.1.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

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

anthropic_token_counter-0.1.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file anthropic_token_counter-0.1.0.tar.gz.

File metadata

  • Download URL: anthropic_token_counter-0.1.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for anthropic_token_counter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 72db270ff557964dfb83565bdd9ee49a7ff6a8298269daa40f8b63482d805413
MD5 af9bc6c0ece8d4c10dcbec7de0f319ec
BLAKE2b-256 87b221859e3b9f6e4570bbad503aba7cfb8356952f8ef635bceb587d92876028

See more details on using hashes here.

Provenance

The following attestation bundles were made for anthropic_token_counter-0.1.0.tar.gz:

Publisher: publish-to-pypi.yml on weirdgiraffe/anthropic_token_counter

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

File details

Details for the file anthropic_token_counter-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for anthropic_token_counter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f20d2707ecccd9dd2f9ff3f997f48c400414cf0e534507914d19582216a7cc64
MD5 992775034280c6dd28b125c2e44c5f41
BLAKE2b-256 366342fb473a4b3b49ebb76dc49522a083748d9f0c568ec3f55ca89ef5c39215

See more details on using hashes here.

Provenance

The following attestation bundles were made for anthropic_token_counter-0.1.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on weirdgiraffe/anthropic_token_counter

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