Why your PDF token count doesn't match your AI bill
Five extra pages changed none of our text counts. A local test explains why extracted-text estimates and native PDF API bills measure different things.
A PDF token counter says 21,419 tokens. Your API request reports something else. That difference can be legitimate: extracting the text and uploading the PDF are different ways to give a model information. A local text counter cannot see every input your provider bills.
I tested what changes a text count, then checked the providers' PDF documentation. The numbers below are local measurements, not API billing results. I did not send these files to an AI service or measure a bill.
One file can take two different paths
In a text-only workflow, software extracts the PDF's selectable text and sends that string as a prompt. Pictures, page geometry, and some table structure do not survive that step. If you count exactly that string with the right tokenizer, you have a useful measure of the document text, though not necessarily the whole request.
A native PDF input is different. OpenAI's file-input guide says PDF requests on vision-capable models include both extracted text and an image of each page. Image processing can add input tokens that a text counter never counted. The PDF detail setting also affects how page images are processed.
Google's document-processing guide describes native PDF vision, including charts, diagrams, and tables. Its guidance includes model-specific media-resolution and billing rules. Don't apply a single tokens-per-page constant to every Gemini generation. Check the selected model and the current pricing page. These sources were checked on October 26, 2026.
A local test: more pages, the same text count
I downloaded three public PDFs: the English Universal Declaration of Human Rights, Attention Is All You Need, and the NIST AI Risk Management Framework 1.0. For each, I made two separate variants using pdf-lib: one with a green rectangle drawn on the first page, and another with five blank pages appended. Neither change added text.
On October 26, I ran all nine files through pdf.js 5.7.284 and gpt-tokenizer 3.4.0. The extraction matches PDFShore's text counter: join each page's text items with spaces, join the pages with newlines, and trim the result. There was no OCR. Both tokenizers returned exactly the same count across the three versions of each document, and SHA-256 checks confirmed the extracted strings were identical.
| Document | Pages: original / padded | o200k, all 3 versions | cl100k, all 3 versions |
|---|---|---|---|
| UN declaration | 8 / 13 | 2,190 | 2,189 |
| Attention paper | 15 / 20 | 10,621 | 10,667 |
| NIST AI RMF | 48 / 53 | 21,419 | 21,619 |
This demonstrates a limit of text counting, not a price change. The counter did not capture the added visual mark or the extra pages. I did not test whether a particular provider charges more for those variants, skips empty pages, or processes their images differently. A rectangle is not a scanned document, and three documents are not a representative benchmark of all PDFs.
Source checksums for reproducing the test
Public files can change at the same URL. SHA-256 values of the downloaded originals:
UN: e75f479c5cc632e88dcf3da247bbef96b093462610c0eee53d281f1fe379661c
Attention: bdfaa68d8984f0dc02beaca527b76f207d99b666d31d1da728ee0728182df697
NIST: 7576edb531d9848825814ee88e28b1795d3a84b435b4b797d3670eafdc4a89f1Other things a document count leaves out
- The rest of the prompt.System instructions, your question, tool definitions, and conversation history are not inside the PDF's extracted text.
- Output. Answers and, where billed, reasoning tokens are separate from an input-only estimate. A short summary and a long extraction task have different output costs.
- Tokenizer differences. o200k_base and cl100k_base are specific public encodings, not universal meters. They do not measure Gemini or Claude exactly, and a new OpenAI model does not automatically use one of them.
- Pricing conditions. Caching, batch processing, and long-prompt thresholds can change the applicable rate. More than one price can apply to the same token total.
For example, a hypothetical 20,000-token text prompt at $2 per million costs $0.04 for input. A 1,000-token answer at $10 per million adds $0.01. That $0.05 illustration excludes page images, extra context, and other charges. It is arithmetic, not an observed PDF bill.
Should you send text instead of a PDF?
If the task is summarizing ordinary prose, extracted text may be enough. Inspect it first: missing paragraphs, wrong reading order, and repeated headers can make a small prompt a bad prompt. For a scan without a text layer, an empty local count means the extractor found no text, not that the document is free to process. OCR or native vision may be necessary.
If the question depends on a chart, visual layout, handwriting, or a table's spatial structure, retain that information. Text-only input may discard the very evidence the model needs. Native vision is not guaranteed to read it correctly either. Verify important results against the original page.
A practical way to reconcile an estimate
- Record the model ID, input method, PDF detail or media resolution, and pricing date.
- For text-only input, count the actual extracted string, not a words-to-tokens formula.
- Include the question, instructions, history, and an output allowance in your budget.
- For an authorized API test, inspect the response's usage fields and the provider's billing breakdown. Compare the same input path and settings, rather than a native PDF request against an extracted-text estimate.
The PDF Token Counter measures locally extracted text with public encodings. The Token Cost Calculator turns text-token estimates into input-cost estimates. Neither predicts the full bill for native PDF vision. PDF to Markdown helps inspect extracted content; the model-limit reference covers context budgets. These are API planning aids, not a pricing model for a ChatGPT or Gemini subscription.