AboutWhat I doProjectsLabContact

Serving and cost

tokenmeter

Count tokens and estimate prompt cost before sending.

tokenmeter-cli on PyPItokenmeter-cli downloads per monthtokenmeter CI statusMIT license0 downloads/month on PyPI

Install

pip install tokenmeter-cli

If you use uv, also as an isolated CLI:

uv tool install tokenmeter-cli

What 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.000045

Features

  • 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.
View the code on GitHub

Other tools

hola@jmwebsoluciones.com