Skip to main content

yaptax

Every language at English price. (Formerly langtax.)

Measure the language tax in your AI prompts. The same meaning takes more tokens outside English, and you pay per token. yaptax counts your own prompts per language, on the tokenizers your models use, and tells you how many of those tokens English would not need.

Everything runs on your machine. Your text is never uploaded to us.

pip install yaptax
yaptax measure prompts.jsonl

New in 0.5:

  • Claude, ChatGPT and Gemini, side by side: yaptax measure prompts.jsonl --tokenizers o200k,claude,gemini counts your own text on GPT-4o, Claude and Gemini (Claude and Gemini through their free token-counting APIs, with your keys).
  • yaptax slim: cuts tokens without changing what prompts say. On examples/app_log.jsonl (a Hindi support bot whose code builds prompts with json.dumps), it cuts 881 tokens to 456 on o200k (48%), almost all from \uXXXX escapes.
  • The router talks to Claude natively (provider = "anthropic"), to Gemini through Google's OpenAI-compatible endpoint, and can slim every request (slim = true). yaptax providers --config openai,claude,gemini writes a starter config.
Language                           Records  Label     o200k tokens  o200k extra  cl100k tokens  cl100k extra
---------------------------------  -------  --------  ------------  -----------  -------------  ------------
Hindi (hin_Deva)                         2  labelled            47          36%            142           79%
Spanish (spa_Latn)                       2  labelled            33          24%             38           34%
English (eng_Latn)                       2  labelled            31           0%             31            0%
Tamil (tam_Taml)                         1  labelled            28          50%            114           87%
...

o200k: 207 tokens. The same meaning in English would take about 148, so about 59 (29%) are language tax.

That is examples/support.jsonl, ten short customer-support messages.

Commands

Command What it does
yaptax measure FILE Tokens per language in a file, and how many are language tax
yaptax measure FILE --spend 2000 Also shows the tax in money for a monthly spend
yaptax measure FILE --lang hi Treat every record as one language
yaptax measure FILE --tokenizers o200k,qwen3 Choose tokenizers (see below)
yaptax measure FILE --json Machine-readable output
yaptax check FILE --spend 2000 --out check.md Short markdown Language Cost Check: tokens per language, language tax, fewest-token tokenizer per language, rough savings range. First tokenizer in --tokenizers is the model you use today
yaptax measure FILE --tokenizers o200k,claude,gemini --sample 50 Your text on GPT-4o, Claude and Gemini. Claude and Gemini are counted by their providers' token-counting APIs with your keys, 50 records per language by default
yaptax measure FILE --tokenizers o200k,claude --router-ratios Also prints token_ratios for router.toml, so the router estimates Claude's tokens per language from your own text
yaptax slim FILE --out slim.jsonl Cuts wasted tokens (escaped JSON, padding, invisible characters, extra spaces) without changing what prompts say, and flags habits that cost tokens on every request, such as a non-English system prompt
yaptax providers Ready-made router entries for OpenAI, Claude, Gemini, DeepSeek, Mistral, OpenRouter and Ollama; --config openai,claude,gemini --out router.toml writes a starter config
yaptax telemetry status, on or off Anonymous usage counts, off by default (see below)
yaptax ratios Tamil The Index's ratios for one language, on all 8 tokenizers
yaptax demo --open The router on a fake provider, with a live savings dashboard (needs yaptax[router])
yaptax router --config router.toml The router in front of your real models, with your own keys
yaptax quality --config router.toml prompts.jsonl --judge MODEL --rules rules.toml Do the cheaper models answer as well, per language? Writes allow rules for the router (needs yaptax[router])
yaptax quality --demo The quality report on the fake provider: no keys, nothing paid

Input: .jsonl, .json, .csv, .tsv, or plain text with one prompt per line (- reads stdin).

  • Text is taken from a text, prompt, content, input, message, query or question field, or from chat messages. Use --text-field for another name.
  • Language is taken from a lang, language or locale field if there is one (hi, hi-IN, hin_Deva and Hindi all work). Use --lang-field for another name.
  • Without a label, the language is guessed from the writing system. All Devanagari is scored as Hindi, for example. Latin-script text is only scored as English if it looks like English; otherwise it is counted but not scored. Label your data for exact results.

yaptax Router: cut the tax automatically

Measuring is step one. The router is step two: an OpenAI-compatible endpoint that sends each request to the cheapest model you allow for its language, and shows what that saved.

pip install "yaptax[router]"
yaptax demo --open

yaptax demo runs the router against a built-in fake provider, sends 34 multilingual support messages through it and opens a live savings dashboard. Every model gets the same demo price, so the saving you see comes only from tokens. No real model is called and nothing is paid. On the demo set, routing saves 53% against sending every language to Qwen3:

Language Routed to Saved
Hindi gpt-4o 64%
Tamil gpt-4o 68%
Telugu gpt-4o 72%
Thai deepseek-v3 31%
Arabic mistral-nemo 24%
Amharic, English qwen3 (baseline) 0%

For real traffic, write a config with your models, your prices and your keys (see examples/router.toml), then:

yaptax router --config router.toml
from openai import OpenAI
client = OpenAI(base_url="http://127.0.0.1:8787/v1", api_key="unused")
reply = client.chat.completions.create(model="yaptax-auto", messages=[{"role": "user", "content": "मेरा ऑर्डर कहाँ है?"}])

How it decides:

  • Language: the x-yaptax-lang header if you send one; otherwise a guess from the user's text.
  • Cost: for each allowed model, input tokens on its tokenizer times its input price, plus an expected answer length on its tokenizer times its output price. OpenAI's tokenizers are counted exactly; others are estimated from the Language Cost Index. It picks the cheapest. On a tie it stays on your baseline.
  • Pinning: send a configured model name instead of yaptax-auto and the router uses that model, logging it like any other request.
  • Safety: per-language allow/deny rules, written for you by yaptax quality (below). If the chosen model is down (5xx), it retries on your baseline.
  • Accounting: the actual cost uses the provider's reported usage. The baseline cost is an estimate of the same request on your baseline, with the answer converted to its tokenizer using the Index ratios.
  • Privacy: the log keeps language, models, token counts, costs and timing. No prompt or answer text, and keys stay in your environment.
  • Endpoints: POST /v1/chat/completions (streaming supported), GET /v1/models, GET /stats, and the dashboard at /.

What it doesn't do yet: route by latency, or re-check quality on live traffic by itself (run yaptax quality again when models or prompts change).

Quality check: cheaper, but as good?

Fewer tokens only helps if the answers stay good. yaptax quality sends the same prompts to your baseline and to each cheaper model the router may use, then checks every candidate, language by language:

pip install "yaptax[router]"
yaptax quality prompts.jsonl --config router.toml --judge gpt-4o --rules rules.toml --pairs pairs.jsonl
  • Answered: a real reply, no error. Reasoning models get room to think (--max-tokens, default 2048), or turn thinking off the way your app does (--reasoning-effort none).
  • Right language: the reply is in the prompt's writing system, and a Spanish or Hindi question did not get an English reply.
  • Not worse: a judge model compares the two answers twice, with the order swapped, and only "better or tie" in both orders counts. Results come with 95% intervals, because 20 prompts is a first check, not proof.
  • Cost: what each answer really cost, from the provider's own token counts and your prices. Candidates that are not cheaper are skipped, so no judge calls are spent on them.

It writes a markdown report and [languages.xxx] allow = [...] rules: paste them into router.toml and the router only uses models that passed for that language. pairs.jsonl holds every prompt with both answers, for you to read; it stays on your machine. Try the report first with yaptax quality --demo.

The judge is a model, not a person, and the language check cannot tell Hindi from Marathi. Read some pairs yourself before trusting a pass.

Free Language Cost Check

Want this number for your own product? We run a free one-week Language Cost Check for teams that serve users outside English.

  • What you get: tokens per language on the model you use today and three alternatives, how much of your bill is language tax, a rough savings range, and a 20-minute call.
  • What to send: 20 to 500 real prompts, with names, phone numbers, emails and IDs removed first. Tell us which models you use and roughly what you spend a month.
  • What happens to them: we measure them on our own machines and delete them after we send you the result. The numbers stay with you; no prompt text is kept.
  • How to ask: open a GitHub issue titled "Language Cost Check" in this repository. Do not paste prompts into the issue, it is public. Tell us your languages and models. We will reply there with how to send the prompts privately.

You can also run the same measurement yourself with yaptax measure. Nothing leaves your machine.

Tokenizers

ID Used by Needs
o200k GPT-4o, GPT-4.1, GPT-5, o3 built in
cl100k GPT-4, GPT-3.5 built in
gpt2 GPT-2 built in
utf8-bytes byte-level models built in
qwen3, deepseek-v3, mistral-nemo, bloom those open models pip install 'yaptax[hf]'; fetched from Hugging Face at the exact revisions the Index used

| claude, claude:<model id> | Claude (default claude-opus-5-5) | pip install 'yaptax[claude]' and ANTHROPIC_API_KEY; counted by Anthropic's token-counting endpoint | | gemini, gemini:<model id> | Gemini (default gemini-2.5-flash) | GEMINI_API_KEY; counted by Google's countTokens endpoint |

Anthropic and Google do not publish their tokenizers as files, so claude and gemini send the text being counted to that provider, with your key, and nowhere else. The framing tokens those endpoints add to each message are measured once and subtracted. They are not in the Language Cost Index, so their "extra" column shows n/a: compare their token counts with the other columns.

Using Claude and Gemini through the router

pip install 'yaptax[router,claude]'
yaptax providers --config openai,claude,gemini --out router.toml   # then add prices
yaptax measure prompts.jsonl --tokenizers o200k,claude,gemini --router-ratios   # paste token_ratios into router.toml
yaptax router --config router.toml

Your app keeps calling http://127.0.0.1:8787/v1/chat/completions in the OpenAI format. For a model with provider = "anthropic" the router calls Claude's Messages API with the official SDK and converts the answer back, streaming and tool calls included. prompt_cache = true asks Claude to cache the repeated start of each request. Sampling settings such as temperature are dropped for Claude, because current Claude models reject them. Gemini uses Google's OpenAI-compatible endpoint, so it needs no conversion.

Anonymous usage counts (off by default)

yaptax asks once, in an interactive terminal, whether you will share anonymous usage counts; the default answer is no, and it never asks in CI or scripts. When on, each command sends a random install id, the command name, the yaptax version, the OS family and the Python version. Never your text, file names, token counts or keys. It tells us whether people come back after the first try. yaptax telemetry off, YAPTAX_TELEMETRY=0 or DO_NOT_TRACK=1 turn it off; src/yaptax/usage.py is the whole implementation.

How "extra tokens" is computed

For each language, yaptax divides your token count by that language's ratio to English in the Language Cost Index: the same 1,012 FLORES-200 sentences, measured in 204 languages on 8 tokenizers. The difference is the language tax. It is an average, so a single short text can differ.

Checked: on FLORES-200 devtest, yaptax measure gives exactly the token totals published with the Index for Hindi, Tamil and English on o200k, cl100k, Qwen3 and BLOOM.

What it does not tell you: fewer tokens is not the same as a cheaper or better model. Prices per token differ between models, and so does answer quality in each language. Measuring those on your own traffic is what our Language Cost Audit does: write to the address on neurotitan.in.

Develop

pip install -e ".[test]"
pytest

MIT licence. The bundled Index data comes from Sentence-cost-in-Electron; FLORES-200 is by Meta AI (CC BY-SA 4.0).

By NeuroTitan Labs.

Metadata

Release files for yaptax 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for yaptax 0.5.0
File Size Uploaded Provenance Actions
yaptax-0.5.0.tar.gz 89.3 kB With provenance Details for yaptax-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for yaptax 0.5.0
File Interpreter ABI Platform Actions
yaptax-0.5.0-py3-none-any.whl Python 3 none any Details for yaptax-0.5.0-py3-none-any.whl

Total release size: 169.6 kB

Release files / yaptax-0.5.0.tar.gz

Download URL yaptax-0.5.0.tar.gz
Size 89.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0a12808cc299343e33e714e4a6fcf2188300cfd114f3a605c21ac3fe99651153
BLAKE2b-256 checksum
How to use checksums
9c36e43a5afd3aead88b3816d6cae83e2cf74cd12658f53b663d0aa3e2da02ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / yaptax-0.5.0-py3-none-any.whl

Download URL yaptax-0.5.0-py3-none-any.whl
Size 80.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c74ca40ed0633be96d32e0938101ab42dcfb5835f55f444d36846613ae3c8dfc
BLAKE2b-256 checksum
How to use checksums
d915484b24e7e29f12f9d6000df86884688e92cc655c9ef4da917e7cd416500e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Security for yaptax 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for yaptax-0.5.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page