Counting tokens and turning them into PKR
ٹوکن کیسے گنیں اور انہیں روپوں میں کیسے بدلیں
38 min read
Three ways to see it
There are three honest ways to count tokens before you spend money. First, paste the text into the official tokenizer tool. OpenAI's lives at platform.openai.com/tokenizer; Anthropic exposes an API endpoint and a Python helper. This works for short pieces and is the fastest way to build intuition. Second, use the SDK. In Python, anthropic.Anthropic().messages.count_tokens(...) returns an exact count for the model you specify. tiktoken does the same for OpenAI models. Third, use a rule of thumb when you need a rough number fast: English averages 1.3 tokens per word, mixed Urdu-English averages 2.0, pure Urdu averages 2.5 to 3.0. Anchor on these and you will rarely be off by more than 20%.
Now turn tokens into rupees. Every model has two prices, one for input tokens (what you send) and one for output tokens (what the model returns). Output is almost always more expensive than input, often 3-5 times. At time of writing, Claude Sonnet costs roughly USD 3 per million input tokens and USD 15 per million output. Claude Haiku is roughly 10x cheaper. GPT-4o sits between. Multiply your token count by the per-million price, divide by a million, multiply by the PKR-USD rate. That is your bill. Always check the live pricing page before you commit, because all three vendors revise prices every few months.
Worked example. Saima at SBP has 100 monetary policy reports, English, 25 pages each. A standard page is 500 words. So each report is 12,500 words, or roughly 16,000 input tokens at 1.3 tokens per word. She wants a half-page summary back, around 600 output tokens per report. Input: 100 reports x 16,000 tokens = 1.6 million tokens. Output: 100 x 600 = 60,000 tokens. At Sonnet pricing: input = 1.6 x 3 = USD 4.80. Output = 0.06 x 15 = USD 0.90. Total = USD 5.70. At a rate of PKR 280 per USD, the entire run costs the bank around PKR 1,600. That is less than one tank of petrol. This is the number you walk into procurement with.
Quick check
Quick check: what makes modern AI different from a rule-based program?
The why-tree
Why-tree level one: why count before you spend? Because LLM costs sneak up on departments. A pilot that costs PKR 5,000 a month can balloon to PKR 500,000 once the whole division adopts it, and nobody noticed because the unit cost was tiny. Counting up-front turns a vague concern into a number on a slide.
Try this with Claude
AI-edge prompt: 'I am building a cost model for an LLM rollout at HBL. Help me design a Google Sheet that takes (a) number of daily prompts, (b) average prompt length in words, (c) average response length in words, (d) language ratio Urdu vs English, (e) chosen model, and outputs daily, monthly, and yearly costs in both USD and PKR at a configurable exchange rate. Write the formulas in cell notation, not pseudocode.' Compare what the model gives you with what you would have written from scratch.
Sources
Sources and further reading. Anthropic, Pricing (anthropic.com/pricing) and Token counting docs (docs.anthropic.com/en/docs/build-with-claude/token-counting). OpenAI, Pricing (openai.com/api/pricing) and tiktoken (github.com/openai/tiktoken). Anthropic Cookbook examples on cost estimation (github.com/anthropics/anthropic-cookbook). For exchange-rate conversion, use SBP's daily reference rate (sbp.org.pk).