Zenaique

Why must image tokens be accounted for in the context budget separately from text tokens?

Flashcard·Easy·4.0 · 0·~30s·Asked atAmdBasetenEvenup
Attempt it
TL;DR

Images consume real tokens via provider-specific tiling rules, often 1000+ for a high-resolution image, so a text-only budget calculator under-reports prompt length and triggers silent overflow or truncation.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Imagine a suitcase that has a weight limit. You weigh all your clothes carefully and pack everything to the line. Then you remember you also packed a heavy book, but you never weighed it. The suitcase is now over the limit and the airline starts removing things at the gate, and you do not know which. Images in a prompt are like that book. They take up real space in the context window even though they are not text. If your budget only weighs text, you go over without realizing it, and the model silently drops content.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

Multimodal context engineering breaks the moment you stop tracking image tokens. The context window is a single physical resource, and images consume it just as text does, with per-image costs that often exceed a long paragraph of text. A budget calculator that only counts text tokens silently under-reports the real prompt length and creates failure modes that range from visible API errors to invisible quality degradation. This deep dive walks through the provider-specific token math, the three failure modes, the right accounting architecture, and the operational controls that production teams ship in 2026.

The token math by provider

Image tokenization is provider-specific in 2026, and the numbers differ enough that you cannot guess across providers.

Anthropic's Claude Opus 4.7 computes image tokens as approximately (width * height) / 750, capped near 1600 tokens per image. A 1568x1568 image is the canonical near-max example at about 1600 tokens. A 512x512 image is about 350 tokens. The formula gives a clean rule of thumb: about a megapixel and a half hits the cap, anything smaller scales proportionally.

OpenAI's GPT-5.5 uses a tile-based formula. In detail-high mode, the cost is a baseline of 85 tokens plus 170 tokens per 512x512 tile that the image is divided into. A 2048x2048 image is approximately 16 tiles plus baseline, around 2800 tokens. In detail-low mode, the cost is a fixed 85 tokens regardless of resolution. The detail mode is selectable at the per-image level.

Google's Gemini 3.1 Pro uses approximately 258 tokens per image at typical resolutions, with adjustments at the extremes. The model handles high-resolution inputs by tiling internally but the token cost stays relatively flat for most practical sizes.

The variance matters in practice. The same image, sent at the same resolution, can cost dramatically different amounts across providers. A 2048x2048 image is 1600 tokens on Claude, 2800 on GPT-5.5 high-detail, and 258 on Gemini. Multi-provider products need per-provider calculators.

Three failure modes when you do not count image tokens
The separate accounting line architecture
Downscaling and detail modes as controls
Instrumentation and operational discipline
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.

Real products, models, and research that use this idea.

  • Anthropic's vision documentation publishes the exact per-image token formula for Claude Opus 4.7
  • OpenAI's vision documentation publishes the tile-based formula for GPT-5.5 with detail-high and detail-low modes
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QHow would you decide between downscaling an image and sending it at full resolution?
A

Run an eval at both resolutions for your task and compare quality. If quality is equivalent, downscale to save tokens. If quality degrades at lower resolution (often the case for OCR, chart-reading, fine-detail), keep full resolution and accept the token cost. The decision is workload-specific and should be made with data.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Building a token-budget calculator that only counts text tokens, then watching the model truncate or behave strangely after a high-resolution image is added to the prompt.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • State that images consume tokens computed by provider-specific formulas

  • Give an order of magnitude figure for image token cost (1k+ for high-res)

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
Pick the most effective intervention when an agent's context grows by 8KB every iteration
MCQ·Medium