Images count as tokens, and a large image can cost thousands of them. OpenAI vision models tokenize images with 32 by 32 pixel patches: the patch count is the ceiling of width over 32 times the ceiling of height over 32, then multiplied by a model multiplier, 1.2 for recent models. Claude processes images in 28 by 28 pixel patches, so an image costs the ceiling of width over 28 times the ceiling of height over 28 visual tokens. Count before you send, or the image can push the request over the context limit.
What you need
- The images you plan to send, with their pixel dimensions
- The model and detail level you will use
- The context window size and the text token count
Step 1: Compute the image tokens from the size
For an OpenAI model, compute the patch count and multiply by the model multiplier: a 1024 by 1024 image at high detail needs 32 by 32, or 1024 patches, and 1229 billable tokens at a 1.2 multiplier. For Claude, a 1000 by 1000 image costs 1296 visual tokens.
Step 2: Add the image tokens to the text tokens
Add the image token count to the prompt text tokens and the expected output tokens, and compare the total with the model context window. Remember that images also count toward tokens-per-minute limits.
Step 3: Resize or downsample when the total is too large
If the total would overflow, resize the image, lower the detail level, or send fewer images. Claude downsamples oversized images automatically, which caps the cost but can make small text illegible, so pre-resizing is better.
Worked example: synthetic vision token count for 4 images
The table below is a synthetic example. It shows the expected result of counting image tokens; no request was sent.
| Image | Size | Image tokens |
|---|---|---|
| Photo A | 1024 x 1024 | About 1229 |
| Photo B | 2048 x 2048 | About 3000 |
| Screenshot | 4096 x 512 | About 2458 |
| Thumbnail | 200 x 200 | About 64 |
Expected result (UNTESTED). the four images cost about 1229, 3000, 2458 and 64 tokens, and the total must fit with the text inside the context window. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- Token counts are estimates: floating-point rounding in billing can make the final count differ by one token.
- OpenAI rejects an image that needs more than 30,000 patches after processing; it is not resized to fit.
- Claude caps images at 8000 by 8000 pixels, and a request with more than 20 images has a stricter per-image limit.
- Detail level changes the token cost: low detail does not always use fewer tokens than high detail.
