Skip to content
All posts

Engineering notes

We built a free tool that shows what your AI prompts cost, and what to cut

tokensaver is a free, open-source tool from Axieo that counts prompt tokens across 20 AI models, compares costs and suggests priced edits. It runs fully offline.

· 3 min read · Axieo team

Share

Every AI API bills by the token, and a system prompt is sent with every request. So a prompt that is 20% longer than it needs to be costs 20% more, on every call, for as long as it runs.

Most teams only see this on the monthly invoice. By then, nobody knows which part of which prompt is to blame.

So we built tokensaver, a free and open-source command-line tool. It reads a prompt and tells you three things: how many tokens it uses, what it costs on 20 models from OpenAI, Anthropic and Google, and which changes make it cheaper.

1. Count before you send

Install it with pip install prompt-tokensaver, then run tokensaver count prompt.txt.

Token counts are exact for OpenAI models. Claude and Gemini counts are estimates and are clearly labelled as estimates. tokensaver never presents a guess as a fact.

2. Compare models side by side

tokensaver compare prompt.txt prices the same prompt on all 20 models, cheapest first, per call and per million calls. Choosing a model is often the biggest saving of all, and this makes the gap visible.

3. Get fixes with a price on each one

tokensaver optimize prompt.txt looks for six kinds of waste:

  • pretty-printed JSON
  • extra whitespace
  • duplicated lines and paragraphs
  • instructions repeated in different words
  • polite filler
  • long few-shot examples

Each suggestion shows the tokens and dollars it saves on the model you choose.

On our sample customer-support prompt, the result went from 834 to 665 tokens on GPT-4o, a 20% cut. At GPT-4o's input price, those 169 tokens are worth about $422 per million calls.

4. Safe by default

Some fixes cannot change what a prompt means. Minifying JSON is one: tokensaver checks that the data is identical afterwards. Removing trailing spaces is another. These fixes are applied automatically.

Anything that could change meaning, such as removing a repeated instruction, waits for you to approve it. Few-shot examples are never edited, only flagged. You see a before/after diff, and the original file is never overwritten.

5. Your prompts stay on your machine

tokensaver runs fully offline. There is no API key, no account and no server. Prompts often contain business rules and customer data, so we did not want them going anywhere.

tokensaver also uses no AI model itself. Every rule is plain, tested code, so the same prompt always gets the same suggestions.

What you get

  • Free and open source under the MIT license.
  • Runs on Windows, macOS and Linux.
  • 216 automated tests.
  • Works with prompts in any language. Counting and the JSON, whitespace and duplicate rules are tested on 55 languages.

Code and documentation: github.com/behrouzbk/tokensaver.

Paying too much for AI?

A prompt is one part of an AI bill. Model choice, caching and output length matter too. Runaway AI spend is also a security risk (OWASP LLM10, Unbounded Consumption): an AI System Audit checks rate limits, budgets and spend alerts.

Found this useful? Pass it on.

Share

Want a second pair of eyes on your app or AI system?

Tell the Axieo team what you're running. A first written opinion within two business days.