← All projects

TokenMeter

What a feature costs when a model writes it

Status Open source, MIT, self-hosted.


The problem

Providers quote their prices per million tokens. Nobody measures their repository in tokens, so the number on the pricing page answers a question nobody asked.

TokenMeter answers the question people actually have: what would it have cost to generate this codebase, and how much does that change depending on how you work.


A real encoder, not a rule of thumb

Token counts come from jtokkit running the o200k_base encoding, the same tokenization the models use. Dividing character counts by four is close enough to sound right and wrong enough to make the comparison between models meaningless, which is the entire output of the tool.


Three modes, and honesty about what they are

The same repository is priced three ways. Raw counts only the tokens of the final code, one times input and nothing on output: an absolute floor. Assisted multiplies input by five and adds one times output for human iteration and moderate reasoning. Agentic multiplies input by twenty and output by four, because an autonomous agent re-reads its context on every step and calls tools in between.

Those multipliers are fixed approximations and the tool says so in its own README. It is an estimate with a floor, not accounting. Publishing the multipliers is the point: a cost model you cannot inspect is a number you cannot argue with.


How a run works

Posting a repository URL to the analyze endpoint returns a 202 and queues an asynchronous job. The repository is cloned temporarily, counted, and thrown away.

The result breaks down by language, extension, folder and individual file, can be shared as a public URL or embedded as a badge, and is kept so analyses can be compared over time. Model prices are configuration, not hard-coded constants.


Stack

Java 21Spring Boot 3jtokkito200k_baseDockerCloudflareSonarCloud

Written up on the lab