Simon Willison releases ttok 0.4: the token counter gets --list-models
Simon Willison has released ttok 0.4, a command-line tool for counting tokens built on OpenAI's open-source tiktoken library. It is the project's first update in about two years. The release fixes a warning from the Click library, updates CI, and adds a --list-models command that prints the available models. The tool runs through uvx, so you can count tokens without installing anything: cat file.txt | uvx ttok. • Version 0.4, the first update in about two years • New --list-models command • Runs without installation via uvx
AI-processed from Simon Willison; edited by Hamidun News
Simon Willison has released ttok 0.4, the first update to his command-line token counter in roughly two years. The release makes three changes: it fixes a warning from the Click library, updates CI, and adds a --list-models command that prints the list of available models. Under the hood it still uses tiktoken, OpenAI's open-source tokenization library. The release is small, but it brings back into working order one of the simplest tools for managing the context window and request budgets.
What changed in 0.4
The update is mostly technical. The Click warning appeared every time the tool ran and cluttered the output. It is now fixed. The author also tidied up CI, the automated build and test pipeline for the project. After two years of inactivity, this matters: the tool once again builds and tests in a current environment instead of depending on settings that went out of date long ago.
The only new feature in the release is the --list-models flag. It shows which models ttok can count tokens for. Previously, you had to check a model name against the documentation or the tiktoken code. Now you can get the list straight from the terminal.
How to run it
ttok works with uvx, which runs Python tools through uv in a temporary, isolated environment. You do not need to install the package beforehand. Counting tokens in any text looks like this:
``` cat file.txt | uvx ttok ```
The text comes in on standard input, and the output is the token count. This format fits well into Unix pipelines: you can pipe the output of another command, a log, a repository dump, or document search results into ttok.
The release at a glance
- Version: ttok 0.4, published on GitHub.
- Author: Simon Willison.
- Foundation: OpenAI's open-source tiktoken library.
- New command: --list-models, a list of available models.
- Fixes: the Click warning and the CI update.
- Run without installing: via uvx.
- Previous update: about two years ago.
Where it comes in handy
Tokens determine two practical things: how much text fits into a model's context window, and how much a request will cost. Estimating by eye from the number of characters or words often misses. This is especially noticeable with code, JSON, tables, and non-English text, where there are usually more tokens than you would expect. Counting locally with a real tokenizer gives an exact figure without calling an API.
The typical use cases are simple. Before sending a large file to a model, check whether it fits in the window. Estimate the cost of batch-processing a set of documents. Compare how much shorter a prompt got after cleanup. Build a length check into a script or a pre-commit hook so that an overly long context does not go out in a request.
The limitation follows from the tool's foundation. tiktoken describes OpenAI's tokenizers. For models from other developers, which have their own token vocabularies, the result will be approximate, and it is better to get exact figures from the provider. For a rough sense of scale, this is usually enough.
If you only need ttok occasionally, you do not have to install it: uvx and one line in the terminal are enough. If you use it regularly, the --list-models command saves you from hunting for the right model name in the documentation.
- Oct 28, 2026Keystone removes the model name from code: open-source LLM gateway adds 0.64 ms
- Oct 28, 2026Wired Tested 6 AI Agents in a Day: Dots Leads, Gemini Spark Fails at Lunch
- Oct 28, 2026Anthropic Turns Claude Code Into a Platform: Claude Mods Flip the Agent Harness
- Oct 28, 2026Liquid AI releases LFM2.5-24B-A2B: an agent model with 2B active parameters
Key Questions Answered
What changed in 0.4?
The update is mostly technical. The Click warning appeared every time the tool ran and cluttered the output. It is now fixed. The author also tidied up CI, the automated build and test pipeline for the project. After two years of inactivity, this matters: the tool once again builds and tests in a current environment instead of depending on settings that went out of date long ago. The only new feature in the release is the --list-models flag. It shows which models ttok can count tokens for. Previously, you had to check a model name against the documentation or the tiktoken c
How to run it?
ttok works with uvx, which runs Python tools through uv in a temporary, isolated environment. You do not need to install the package beforehand. Counting tokens in any text looks like this: ``` cat file.txt | uvx ttok ``` The text comes in on standard input, and the output is the token count. This format fits well into Unix pipelines: you can pipe the output of another command, a log, a repository dump, or document search results into ttok.
What are the key details on The release at a glance?
Version: ttok 0.4, published on GitHub. Author: Simon Willison. Foundation: OpenAI's open-source tiktoken library. New command: --list-models, a list of available models. Fixes: the Click warning and the CI update. Run without installing: via uvx. Previous update: about two years ago.
Test Frontier LLMs & Autonomous Agents in One Workspace
Run Claude Opus 5.5, GPT-6, Gemini 3.1, and DeepSeek side-by-side in Nomad AI (nomadnet.ai) — unified model routing, deep research, and multimodal workflows under one subscription.
The AI world, distilled — once a week
Seven stories that actually mattered, hand-picked. No noise, no reposts, no press releases.
Done! Check your inbox for a confirmation.