How Many Tokens Does a Gemini PDF Page or Image Really Cost? (Measured With count_tokens)
Almost every blog post about Gemini API pricing repeats the same rule of thumb: "a PDF page costs 258 tokens." I wanted to verify that before budgeting a document pipeline, so on 10 November 2026 I generated test PDFs and PNGs and called client.models.count_tokens() across four Gemini models ( gemini-3.5-flash-lite , gemini-3-flash-preview , gemini-3.6-flash , and gemini-3.8-flash ). Every single…
Breaking down the token costs of Gemini API inputs:
1. PDFs:
- The surprising consensus across four Gemini models is 560 tokens per page, whether blank or full of text.
- Even a page with 40 lines of random words costs 560 tokens.
- 10 pages of text amount to 5,600 tokens, and 10 blank pages also cost 5,600 tokens.
- This contradicts the common "258 tokens per PDF page" rule of thumb.
2. Images:
- Images are priced at roughly 1,090 tokens each, regardless of size.
- Pixel count doesn't affect the token cost significantly. A 3000×2000 image, which has 6 million pixels, costs only 9 tokens less than a 300×300 image.
- The only noticeable token cost difference is between 300×300 and 1536×1536 images, with 1536×1536 costing 9 tokens less.
3. Measuring Real Costs:
- Relying on the 258-token-per-page figure can lead to underestimating costs by 2.17 times.
- To get accurate numbers, use the client.models.count_tokens() function on actual files with the desired Gemini model.
- This function takes one API call per sample file and provides the true token cost for that specific model.
4. Implications for Budgeting:
- Small errors in token estimates can multiply quickly when processing large batches.
- A batch of 200 PDFs with an average of 12 pages (2,400 pages total) would cost 619,200 tokens at the incorrect 258-token estimate, but 1,344,000 tokens using the measured cost.
- For 1,000 PNG images, the cost varies from ~258,000 to ~1,090,000 tokens based on the incorrect and measured figures respectively.
5. Limitations of the Study:
- The tests used synthetic reportlab PDFs and Pillow PNGs generated with default settings.
- The results may not apply to scanned PDFs, JPEG/WebP images, or video/audio files.
- Google could change tokenization rules without notice, so the script should be run on your own files to get accurate data.
In summary, it's crucial to measure token costs with the actual count_tokens function for your specific Gemini model and files, rather than relying on the widely-circulated "258 tokens per PDF page" rule of thumb. The measured values show that PDFs and images cost more than this simplified estimate, and the actual costs can vary significantly based on the file's content and size.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to