Docs · Input pipeline 03

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.

Workflow mapVision-token calculation
01Image filePNG, JPEG, WebP, GIF
02Read dimensionsPixels stay local
03Select ruleBy model family
04Patches, tiles, or budgetProvider formula
05Vision tokensAdded to text
Image dimensions—not compressed file size—drive the patch, tile, or fixed-budget rule selected for the model family.

Local image pipeline

  1. Read the file's intrinsic width and height in the browser.
  2. Select the rule for that model family and generation.
  3. Apply the documented resize, patch, tile, or budget step.
  4. 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.

  1. Raw patches: ceil(width / 32) × ceil(height / 32).
  2. 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.
  3. 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.

DimensionsClaude 4.6 and earlier
1,568-token tier
Claude 4.7 and later
4,784-token tier
200 × 2006464
1000 × 10001,2961,296
1092 × 10921,5211,521
1920 × 10801,5602,691
2000 × 15001,5643,888
3840 × 21601,5604,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_resolutionTokens per image
low280
medium560
high and the default1,120
ultra_high2,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.