How to Reduce LLM Token Usage and API Cost

Where the tokens in an LLM bill come from, how to count them, and the levers that cut cost in order of impact: output length, prompt caching, batch APIs, model choice and trimming what you paste.

· 11 min read

Illustration for the LLM Token Counter guide

An LLM API bill is a multiplication: tokens per request, times price per token, times requests. Every saving comes from shrinking one of those three numbers, and they are not equally easy to move. Rewording a prompt to save a dozen tokens rarely matters. Caching a 2,000-token system prompt, halving the length of answers, or moving overnight jobs to a batch API often cuts the bill by a third or more. This article explains what a token is, how to count them exactly, and the cost levers in roughly the order they pay off, with worked numbers at prices checked on 1 November 2026. The LLM Token Counter, Prompt Token Reducer and LLM API Cost Calculator do each step in the browser.

What a token is

Models do not read characters or words. They read tokens: entries from a fixed vocabulary of frequent words, word pieces, punctuation and bytes, built with byte-pair encoding. Common English words are usually a single token, and they normally include the space in front of them, so " the" and " invoice" are one token each. Rarer words, numbers, codes and many non-English scripts split into several pieces.

The sentence "Summarise the attached invoice for order A-1001." split into 13 o200k_base tokens, and the same order record costing 30 tokens as pretty-printed JSON, 20 minified and 17 as CSV
The sentence "Summarise the attached invoice for order A-1001." split into 13 o200k_base tokens, and the same order record costing 30 tokens as pretty-printed JSON, 20 minified and 17 as CSV

Different model families use different vocabularies, so the same text has a different token count on each:

Model familyTokenizerCounting
GPT-4o, GPT-4.1, o1, o3, o4-mini, GPT-5.xo200k_baseExact with tiktoken or gpt-tokenizer
GPT-4, GPT-3.5 Turbocl100k_baseExact
gpt-osso200k_harmony (o200k_base plus chat tokens)Exact for plain text
ClaudeNot publishedEstimate, or Anthropic's count-tokens API
GeminiNot publishedEstimate, or Google's countTokens API
Llama 3128k vocabulary built on tiktoken's 100kcl100k_base is a close English proxy

OpenAI's tiktoken library maps every gpt-5 model name to o200k_base. The larger vocabulary helps non-English text: "こんにちは世界" (hello world in Japanese) is 2 tokens in o200k_base and 4 in cl100k_base. Anthropic's pricing page notes that Claude Opus 4.7 and later use a newer tokenizer that produces about 30 percent more tokens for the same text, and its models overview puts 1M tokens at roughly 555,000 English words on that tokenizer, against about 750,000 on earlier Claude models. Google's token guide says a Gemini token is about 4 characters. A useful rule for English on OpenAI models is that 1,000 words is about 1,300 tokens; for anything that matters, count rather than estimate.

Count before you optimise

Paste a real request into the token counter, not the template. Real requests carry things templates hide: retrieved documents, chat history, tool definitions, pasted logs. A typical support chatbot request might be a 900-token system prompt, 600 tokens of retrieved help articles, 800 tokens of conversation history and a 200-token question. The question is the only part the user typed, and it is under a tenth of the input.

Two parts of the bill are easy to miss. Chat requests add a few tokens per message for role markers. Reasoning models also bill their hidden thinking as output tokens, which can be several times the visible answer; check the usage field in API responses to see the real figure.

Output tokens cost the most

Output is priced at 4 to 8 times input on most current models: Claude Sonnet 5.5 charges $2 per million input tokens and $10 per million output, GPT-6.1 Sol the same, and Gemini 2.5 Pro $1.25 and $10. In a typical chat request with 2,500 tokens in and 350 out, output is 41 percent of the cost on Sonnet 5.5 despite being 12 percent of the tokens.

That makes answer length the first thing to tune:

  • Give a length in the prompt ("under 120 words", "3 bullet points") and set max_tokens as a hard ceiling.
  • Ask for structured output with only the fields you need, rather than prose you parse afterwards.
  • For classification and extraction, ask for the label or the JSON and nothing else.
  • On reasoning models, use the lowest effort or thinking setting that still gives correct answers on your tests.

Cache the parts that repeat

Most prompts start with the same text every time: system prompt, tool definitions, a policy document, few-shot examples. Prompt caching bills that repeated prefix at a fraction of the input price when it is reused soon after. On Anthropic's current list, a cache hit costs 10 percent of the input price on most models and 5 percent on Claude Opus 5.5 and Sonnet 5.5. OpenAI's cached rates run from 50 percent of input on GPT-4o down to 5 percent on GPT-6.1 Sol, and Gemini's are 10 percent plus a per-hour storage fee.

The rules are similar everywhere. OpenAI's caching guide says caching is on by default, needs at least 1,024 tokens on GPT-5.6 and later, and only matches when the entire prefix is identical, so stable instructions and shared reference material go first and anything that changes, such as timestamps, user names or the question, goes last. Anthropic caches the prompt up to cache breakpoints set in the request, and charges 1.25 times the input price to write a 5-minute cache entry, which pays back after a single reuse at the 10 percent read price.

A common way to lose the discount is to put the current date or the user's name at the top of the system prompt. One changed character at the start makes every following token a cache miss.

Batch what can wait

OpenAI, Anthropic and Google all offer a batch API at 50 percent off input and output, in exchange for asynchronous processing with results within 24 hours. It suits evaluations, nightly classification, back-filling summaries, data extraction over archives and report generation. Discounts stack: Anthropic's pricing page says batch and caching discounts combine, and OpenAI lists separate batch rates for cached input.

A worked example

Take a support chatbot handling 5,000 requests a day, with 2,500 input tokens and 350 output tokens per request, on Claude Sonnet 5.5 at list prices ($2 input, $0.10 cached input, $10 output per million tokens). Months are 365 / 12 = 30.42 days.

Bar chart of monthly cost for one chatbot: $1,293 with no caching, $859 with 60 percent cache hits, $593 with answers halved to 175 tokens, $441 after trimming input to 2,000 tokens with 75 percent cached, and $23 on Claude Haiku 5.5
Bar chart of monthly cost for one chatbot: $1,293 with no caching, $859 with 60 percent cache hits, $593 with answers halved to 175 tokens, $441 after trimming input to 2,000 tokens with 75 percent cached, and $23 on Claude Haiku 5.5
ChangePer requestPer month
Starting point, no caching$0.0085$1,293
60% of input served from cache$0.00565$859
Answers cut from 350 to 175 tokens$0.0039$593
Input trimmed to 2,000 tokens, 75% cached$0.0029$441
Same workload on Claude Haiku 5.5$0.0001525$23

The first three changes keep the same model and cut the bill by two thirds. The arithmetic for the second row: (1,000 uncached tokens x $2 + 1,500 cached x $0.10 + 350 output x $10) / 1,000,000 = $0.00565 per request, times 5,000 a day and 30.42 days. The last row is a different decision. A smaller model is 19 times cheaper here, but only worth it if it answers your real questions well enough, which you can only learn by testing it on them. Run your own numbers in the cost calculator, which applies cache and batch discounts and long-context rates and lets you edit every price.

Trim what you paste

The text people paste into prompts is often heavier than it looks. In a test with 20 customer records of five fields each, pretty-printed JSON was 842 tokens, the same JSON minified was 482, and CSV with a header row was 248, less than a third of the original. Other common waste:

  • HTML from scraped pages. Tags, attributes, scripts and comments can outnumber the text. <p>Please note that customers are able to request a refund.</p> is 14 tokens; Customers can request a refund. is 6.
  • Tracking parameters. A product link with utm_source, utm_medium and utm_campaign was 23 tokens; without them, 10.
  • Repeated lines and boilerplate. Email signatures, disclaimers and duplicated rules in a system prompt that grew over time.
  • Filler phrases. "In order to" is "to"; "due to the fact that" is "because".

The Prompt Token Reducer applies these clean-ups with switches and lists every change it makes, so meaning is never changed silently. On its example prompt the default transforms take 221 tokens down to 134. Two transforms are off by default for a reason: CSV drops the field names from each row, and stripping Markdown removes emphasis a model may rely on.

For retrieval systems, the bigger win is usually sending fewer chunks rather than smaller ones. Retrieving ten 500-token chunks when the answer is always in the top three costs 3,500 input tokens per request for nothing.

Choose the model per task

Prices across current models span more than two orders of magnitude, from $0.05 per million input tokens for GPT-5 nano to $10 for GPT-6 Astra and Claude Fable 5.1. Many applications use one large model for everything when most requests are simple. Routing helps: a small model handles classification, extraction and short answers, and only hard requests go to a larger one. Hosted open-weight models are another option; gpt-oss-120b on Groq, for example, lists $0.15 input and $0.60 output per million tokens.

Whatever you choose, measure quality on a fixed set of real inputs before and after. A cheaper model that gets 5 percent more answers wrong can cost more in support tickets than it saves in tokens.

A checklist

  • Count tokens on real requests, including history, retrieved text and tool definitions.
  • Set an answer length in the prompt and a max_tokens ceiling.
  • Put stable content first and keep it byte-identical so it caches.
  • Move work that can wait to a batch API.
  • Minify JSON, strip HTML and tracking parameters, and send fewer retrieved chunks.
  • Try a smaller model on a fixed test set before deciding you need a large one.
  • Recheck prices regularly; they change often, and new models arrive every few months.

Writing a clear prompt in the first place helps too: a precise prompt gets the right answer in one call instead of three. The companion article on writing better AI prompts covers structure, examples and output formats.

Open the LLM Token Counter