Images and vision-token formulas
How image tokens are counted: OpenAI 32x32 patches with a 2,500 budget, Claude 28x28 patches in two tiers, and Gemini 3 media_resolution budgets.
The browser reads image dimensions locally and never uploads pixels. Each provider family then converts that geometry into tokens with its own published formula. The three formulas have nothing in common, so the same image can cost 1,120 tokens on one model and 4,784 on another.
Local image pipeline
- Read the file's intrinsic width and height in the browser.
- Select the rule for that model family and generation.
- Apply the documented resize, patch, tile, or budget step.
- Add the visual tokens to the text and extracted-file tokens.
Compressed file size is never part of any formula. A 1600 × 900 PNG and a 1600 × 900 JPEG cost the same number of tokens even when one file is ten times larger.
OpenAI: 32 × 32 patches
Current OpenAI models cut the image into 32-pixel squares and bill the patch count times a multiplier. The patch count is capped at 2,500 and the multiplier is 1.2.
- Raw patches:
ceil(width / 32) × ceil(height / 32). - If that exceeds 2,500, shrink the image by
sqrt(2500 × 32² / (width × height)), then snap the width down to a whole number of patches and recount. - Tokens:
patches × 1.2, rounded up.
OpenAI's two worked examples both reproduce exactly: a 1024 × 1024 image is 1,024 patches and 1,229 tokens; a 2048 × 2048 image shrinks to 1600 × 1600, hits the 2,500-patch cap, and costs 3,000 tokens. There is no low-detail shortcut on a patch model, so the detail field changes nothing.
The older tile rule—85 base tokens plus 170 per 512-pixel tile, with a flat 85 for low detail—still applies to the GPT-4o and GPT-5 generations. It stays available in the npm package for anyone measuring those models.
Claude: 28 × 28 patches
Anthropic counts ceil(width / 28) × ceil(height / 28) after resizing the image to fit two limits: a maximum edge length and a maximum token count. Claude 4.7 and later carry the larger budget, the same release boundary as Anthropic's newer tokenizer.
| Dimensions | Claude 4.6 and earlier 1,568-token tier | Claude 4.7 and later 4,784-token tier |
|---|---|---|
| 200 × 200 | 64 | 64 |
| 1000 × 1000 | 1,296 | 1,296 |
| 1092 × 1092 | 1,521 | 1,521 |
| 1920 × 1080 | 1,560 | 2,691 |
| 2000 × 1500 | 1,564 | 3,888 |
| 3840 × 2160 | 1,560 | 4,784 |
Every row is Anthropic's own published figure, and each one is covered by a test in this repository. Notice the shape of the table: below about 1.5 megapixels the two tiers agree, because nothing needs resizing. Above that, the older tier flattens at roughly 1,560 tokens while the newer tier keeps climbing to 4,784. A 4K screenshot therefore costs three times more on Claude Sonnet 5.5 than on Claude Haiku 4.5.
Gemini: fixed budgets
Gemini 3 ignores image dimensions. Each image spends a fixed budget set by the media_resolution parameter.
media_resolution | Tokens per image |
|---|---|
low | 280 |
medium | 560 |
high and the default | 1,120 |
ultra_high | 2,240 |
This calculator uses 1,120 tokens, Google's default, and 280 when the detail control is set to low. Gemini 2.x models are not part of this scheme: they charge 258 tokens for an image with both sides under 384 pixels, and otherwise tile the image into 768-pixel squares at 258 tokens each, after scaling it to fit 3072 × 3072.
What is not priced
Two cases are reported rather than guessed:
- Models with no published image rule. Qwen, Kimi, GLM, Grok, and Meta accept images, but publish no token formula for them. These models show "image input unavailable" instead of a number borrowed from another vendor.
- GPT-6 Sol, GPT-6.1 Sol, and GPT-6 Luna. OpenAI's patch table does not list them. They are counted with the GPT-6 Astra rule, and the result is labelled an estimate with that reason attached.
Verification
Reconcile any preflight number against the usage block of a real API response. Record the model ID, the exact dimensions you sent, the detail or media-resolution setting, and the date. Image rules change with model generations more often than text prices change.
Read the full provider comparison, or see audio, video, and PDF pages for the other non-text inputs.