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.1sonnet- Claude Sonnet 4.1sonnet-4,sonnet-4.1- Claude Sonnet 4.1sonnet-3.7- Claude Sonnet 3.7haiku- Claude Haiku 3.5haiku-3.5- Claude Haiku 3.5haiku-3- Claude Haiku 3
Full Names
claude-opus-4-1-20250805claude-sonnet-4-1-20250805claude-sonnet-3-7-20240805claude-haiku-3-5-20241022claude-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+
anthropicPython library- Valid Anthropic API key
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72db270ff557964dfb83565bdd9ee49a7ff6a8298269daa40f8b63482d805413
|
|
| MD5 |
af9bc6c0ece8d4c10dcbec7de0f319ec
|
|
| BLAKE2b-256 |
87b221859e3b9f6e4570bbad503aba7cfb8356952f8ef635bceb587d92876028
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anthropic_token_counter-0.1.0.tar.gz -
Subject digest:
72db270ff557964dfb83565bdd9ee49a7ff6a8298269daa40f8b63482d805413 - Sigstore transparency entry: 408496376
- Sigstore integration time:
-
Permalink:
weirdgiraffe/anthropic_token_counter@fa30f613b403ffd36b92e0d9bd02eb0f2f2855b2 -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/weirdgiraffe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@fa30f613b403ffd36b92e0d9bd02eb0f2f2855b2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file anthropic_token_counter-0.1.0-py3-none-any.whl.
File metadata
- Download URL: anthropic_token_counter-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f20d2707ecccd9dd2f9ff3f997f48c400414cf0e534507914d19582216a7cc64
|
|
| MD5 |
992775034280c6dd28b125c2e44c5f41
|
|
| BLAKE2b-256 |
366342fb473a4b3b49ebb76dc49522a083748d9f0c568ec3f55ca89ef5c39215
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anthropic_token_counter-0.1.0-py3-none-any.whl -
Subject digest:
f20d2707ecccd9dd2f9ff3f997f48c400414cf0e534507914d19582216a7cc64 - Sigstore transparency entry: 408496387
- Sigstore integration time:
-
Permalink:
weirdgiraffe/anthropic_token_counter@fa30f613b403ffd36b92e0d9bd02eb0f2f2855b2 -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/weirdgiraffe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@fa30f613b403ffd36b92e0d9bd02eb0f2f2855b2 -
Trigger Event:
push
-
Statement type: