How Do AI Vision APIs Calculate Token Costs?
When you send an image to GPT-4 Vision, Claude, or Gemini, you are not charged based on the file size in kilobytes. You are charged based on the pixel dimensions of the image — specifically, how many tiles or patches the model needs to process to analyse the full image.
OpenAI's GPT-4 Vision uses a tile-based pricing model. In high detail mode, the image is scaled and divided into tiles, with each tile costing a fixed number of tokens. The exact tile count depends on the image dimensions and the detail mode selected. Larger images produce more tiles and cost more tokens. The key point is that token cost scales with image dimensions — a full-resolution smartphone photo costs significantly more tokens than a resized version of the same photo.
Anthropic's Claude charges based on the image dimensions you send. Sending a smaller image means fewer tokens charged, regardless of what the model does internally with it.
Google's Gemini also charges per image based on dimensions, with larger images consuming more of the context window and costing more tokens per API call.
The AI model does not need your original 12 megapixel photo to understand its content. A 512×512 or 800×600 version contains enough visual information for the model to describe it, extract text from it, or classify it — at a lower token cost.
Why Large Images Waste Your API Budget
Consider a typical workflow where you are sending product photos to GPT-4 Vision for automated description generation. A standard e-commerce product photo from a DSLR camera is 4000×3000 pixels and 3–5 MB as a JPEG.
Sending that image directly to the API can cost a significant number of tokens just for the image portion of the request. If you are processing many product photos per day, the image tokens alone can cost significantly more than the text tokens for your prompts and responses combined.
Now consider the same workflow with images pre-compressed to 200 KB and resized to approximately 800×600 pixels. The same API call will cost significantly fewer tokens for the image portion. The exact reduction depends on the API provider, detail mode, and image content. The model's ability to describe the product accurately is not meaningfully affected, because the visual content is preserved at a resolution the model can fully utilise.
For any workflow processing more than a few hundred images per month, pre-compressing before the API call is worth doing.
A Real Example: What 500 Product Photos Per Day Actually Costs
Say you are building a tool that sends product photos to GPT-4o to automatically write descriptions for an online store. The store has 500 new products per day. Each product photo comes straight from a DSLR camera — around 4000×3000 pixels, 4 MB per file.
GPT-4o in high detail mode works by dividing your image into 32×32 pixel patches and charging per patch. A 4000×3000 image produces a very large number of patches. That is a lot of tokens just for the image, before your prompt or the model’s response is even counted. Do this 500 times a day and image tokens alone become a significant part of your bill.
Now compress each photo to 200 KB with resize enabled before sending. FitPhotoKB resizes the image to roughly 800×600 pixels. That produces around 25 times fewer patches than the original. The model can still read the product, identify the colour, describe the shape, and write an accurate description. The visual information it needs is all still there at 800×600.
At scale, pre-compressing images before your API calls is one of the highest-return optimisations available to any developer running a vision pipeline.
One thing worth knowing about GPT-4o-mini specifically: in low detail mode it charges a flat 2,833 base tokens per image regardless of dimensions. That is actually more than GPT-4o charges for a small image in high detail mode. If you are using GPT-4o-mini and wondering why your image costs seem high even for small files, check which detail mode your code is using — switching from low to high detail on a small pre-compressed image will cost fewer tokens, not more.
Best Practices for AI Image Token Optimization
A few things that reduce token costs without affecting the quality of the model's output:
1. Resize before sending, not after receiving. Pre-scaling images on your side before the API call is always more efficient than relying on the API's internal scaling. You control the exact dimensions and can optimise for your specific use case.
2. Match resolution to task complexity. For tasks like “does this image contain a person?” or “what colour is the background?”, a 400×400 image is sufficient. For tasks like “read the text in this document” or “identify the model number on this label”, you need higher resolution — typically 800×600 or larger.
3. Use JPEG for photographs, not PNG. A PNG version of a photograph is 3–5 times larger than a JPEG at equivalent quality. Larger files take longer to upload and consume more bandwidth, even though the token cost is based on dimensions. Use JPEG for photos and reserve PNG for images with transparency or text.
4. Enable dimension reduction when compressing. When using FitPhotoKB, enable Resize image if needed in Advanced Options. This allows the tool to reduce both quality and dimensions to hit your target, which gives the greatest token savings when the compressed image is sent to an AI API.
5. Batch compress before your pipeline runs. If you have a batch of images to process through a vision API, compress them all first using FitPhotoKB's batch mode (up to 20 at once), then run your API calls. This separates the compression step from the API step and makes it easy to verify the compressed images before spending API credits.
Compressing to 200 KB for the Best Quality-to-Cost Ratio
At 200 KB with dimension reduction enabled, a typical smartphone photo is resized to approximately 800×600 pixels — enough resolution for GPT-4 Vision, Claude, and Gemini to work with for most tasks.
FitPhotoKB's 200 KB preset is specifically designed for this use case. Select your image, click the 200 KB preset, enable Resize image if needed in Advanced Options, and click Compress. The result is a JPEG that is optimised for AI vision API submission — small enough to minimise token costs, large enough to preserve the visual detail the model needs.
For document OCR tasks where text legibility is critical, consider using 500 KB instead of 200 KB. For simple classification or description tasks, 100 KB is often sufficient.
All compression in FitPhotoKB runs 100% locally in your browser. Your images never leave your device before you send them to the API — which matters for workflows involving sensitive or proprietary visual data.
How to Lower AI API Costs Without Changing Your Prompts
Most developers focus on prompt optimisation to reduce API costs. Image size is often overlooked, but for vision workflows it can have a larger impact than prompt length. A shorter prompt saves a few dozen tokens. A smaller image can save hundreds.
The workflow is simple: compress your images to 200 KB with dimension reduction enabled before your API call. No changes to your code, no changes to your prompts. The only change is the image file you pass to the API.
For batch workflows, use FitPhotoKB to compress all images before your pipeline runs. Compress up to 20 at once, download them, then run your API calls on the compressed versions.
Which AI Vision APIs Benefit Most from Pre-Compression
All major vision APIs benefit from pre-compression, but the savings vary by provider and pricing model.
OpenAI GPT-4 Vision uses a tile-based pricing model where token cost scales with image dimensions. Smaller images produce fewer tiles and cost fewer tokens. Pre-compressing to 200 KB with resize enabled significantly reduces the tile count for a standard smartphone photo.
Anthropic Claude scales images internally before processing, but you are still charged based on the original dimensions you send. Pre-compressing means Claude receives a smaller image, processes it faster, and charges fewer tokens.
Google Gemini has a generous free tier but charges for high-volume usage. Pre-compressing images extends how far your free tier goes and reduces costs at paid tiers.
The 200 KB preset in FitPhotoKB is the recommended starting point for all three. Adjust up to 500 KB for document-heavy tasks or down to 100 KB for simple classification tasks where you want maximum cost reduction.
All compression runs 100% locally in your browser — your images never leave your device. Free, no account required.
Try FitPhotoKB Free →