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.
pip install yaptax
yaptax measure prompts.jsonl
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 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,queryorquestionfield, or from chatmessages. Use--text-fieldfor another name. - Language is taken from a
lang,languageorlocalefield if there is one (hi,hi-IN,hin_DevaandHindiall work). Use--lang-fieldfor 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-langheader 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-autoand the router uses that model, logging it like any other request. - Safety: per-language
allow/denyrules, written for you byyaptax 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 |
Anthropic and Google do not publish their tokenizers as files, so they are not here yet.
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.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| yaptax-0.4.0.tar.gz | 68.1 kB | Without provenance | Details for yaptax-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| yaptax-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for yaptax-0.4.0-py3-none-any.whl |
Total release size: 129.3 kB
Release files / yaptax-0.4.0.tar.gz
| Download URL | yaptax-0.4.0.tar.gz |
|---|---|
| Size | 68.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
46477575b7a43cfc2659d341c1a5410c96521d8b63fb9bef33bfa1760809f829
|
|
BLAKE2b-256 checksum How to use checksums |
2522758e13ebfd307cfcc99b8a4ac06442263d1356fa63523fb09371bd84a91c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Release files / yaptax-0.4.0-py3-none-any.whl
| Download URL | yaptax-0.4.0-py3-none-any.whl |
|---|---|
| Size | 61.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e45d9244494104bcfa548b7c9d61b359c32911eae0521cf96d3aba3efadb9123
|
|
BLAKE2b-256 checksum How to use checksums |
8b6cda6e674e777901ecc0d8f7c05f62b0dfc9b427809c965aa49f90a63bb5df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Security for yaptax 0.4.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.