Serving and cost
tokenmeter
Count tokens and estimate prompt cost before sending.
Install
pip install tokenmeter-cliIf you use uv, also as an isolated CLI:
uv tool install tokenmeter-cliWhat it does
Prompt templates grow, an example gets added, the retrieved context balloons, and suddenly every call costs more than you thought. tokenmeter gives the exact count and a dollar estimate up front.
In action
A real recorded session of the CLI running.
Read it as text
input in tok out tok cost (USD) prompt.txt 18 0 $0.000045
$ tokenmeter count prompt.txt --model gpt-4o
input in tok out tok cost (USD)
prompt.txt 18 0 $0.000045Features
- —Exact counting with tiktoken for OpenAI encodings.
- —Per-model cost estimate from a dated table.
- —A file, a directory or stdin.
- —Budget gate for CI.