Image Inputs Are Tokens Too: Budgeting Multimodal Requests
How to estimate image token cost, when downscaling is safe, and how to stop re-sending identical screenshots on every conversation turn.
TL;DR
Treat every image in a vision request as a block of input tokens whose size depends on resolution and detail settings, not on the file's byte size. Budget multimodal requests by estimating image tokens up front, downscaling only when the task allows it, and deduplicating screenshots across turns.
How image tokens are counted
Vision models do not read pixels directly. They tile or resize the image into patches and encode each patch as tokens, which are then charged like text input. That means the cost driver is the processed image geometry plus the detail setting you request, not the PNG's file size on disk. A heavily compressed screenshot and a lossless one of the same dimensions can cost the same in tokens.
The exact counting rule differs by provider and model, and it changes as models are updated. Do not hardcode a formula you read once. Read the provider's vision guide for the model you are actually calling, and confirm current model behavior in the live catalog at https://admesh.ai/models. If you need a per-image number for budgeting, measure it: send the same image at several resolutions and detail settings, and read the prompt-token count from the response usage field.
- Tokens scale with the image as processed, not with file bytes.
- Detail settings change how many patches the model sees.
- Counting rules are model-specific and change over time; verify against docs.
- Measure with the usage field instead of guessing.
Resolution and detail tradeoffs
Downscaling is a cost lever, but it is a lossy one. The safe rule is to match resolution to the smallest feature the task must resolve. If the model only needs to know whether a page has a sidebar, a login button, or an error banner, a small image is usually enough. If it must read a serial number, a chart axis label, or a dense table cell, shrinking the image can silently destroy the answer while the request still succeeds and still costs tokens.
Detail settings are the second lever. A higher detail mode typically gives the model more patches, which helps with small text and fine UI elements but raises token count. A lower mode is cheaper but can miss exactly the details you care about. The failure mode to watch for is a confident wrong answer: the model does not tell you the text was illegible after downscaling, it guesses. Test each task at the resolution you plan to ship, with a handful of hard examples, before you lock in a downscale factor.
Caching and deduplicating screenshots
The most common multimodal cost leak is not resolution, it is repetition. In a multi-turn agent that inspects a UI, developers often append the current screenshot to the message history on every turn. After ten turns the same unchanged screen may be sent many times, and each copy is billed again as input. The model gains nothing from seeing an identical image twice.
Fix this at the message-assembly layer, not at the prompt. Keep images out of the persistent history and attach them only to the turn where they are new or changed. If a screenshot is unchanged, reference it in text or omit it and let the earlier turn stand. When you do resend, hash the image bytes and deduplicate within the request. Provider-side prompt caching can also help when a long stable prefix is reused, but caching behavior and eligibility vary, so confirm it in the provider docs rather than assuming every image is cached.
A multimodal request budget
- Classify each image by the smallest feature the task must resolve: coarse layout, medium UI, or fine text.
- Pick a resolution and detail setting per class, then measure actual prompt tokens using the usage field on a few representative images.
- Compute per-request image tokens as image count times measured tokens per image at that class, and add text tokens.
- Cap image count per request and per conversation; reject or summarize when the cap is hit instead of silently appending.
- Deduplicate images by hash before sending, and drop unchanged screenshots from later turns.
- Log image tokens separately from text tokens so regressions in resolution or duplication show up in dashboards.
- Re-measure after any model or detail-setting change, since counting rules are not stable across versions.
Failure modes to design around
- Silent illegibility: downscaled text becomes unreadable and the model guesses instead of failing.
- History bloat: identical screenshots accumulate across turns and inflate input tokens.
- Wrong formula: a hardcoded token estimate drifts after a model update and your budget is wrong.
- Detail mismatch: paying for high detail on tasks that only need layout, or the reverse.
- Unbounded fan-out: agents that capture a new screenshot per step with no cap.
How to apply this with Admesh
Admesh exposes an OpenAI-compatible base URL at https://api.admesh.ai/v1 and an Anthropic-compatible endpoint at https://api.admesh.ai/v1/messages, so you can point existing vision clients at it with minimal changes. One API key and one balance cover multiple model families, including OpenAI, Anthropic, Google, DeepSeek, Qwen, Moonshot, Zhipu, and MiniMax. That makes it practical to A/B the same image at different resolutions and detail settings across model families and compare measured image tokens side by side.
Start by reading the model catalog at https://admesh.ai/models and the docs at https://docs.admesh.ai to confirm which models accept image input and how detail settings are exposed. Then run your measurement pass: send a few representative screenshots at two or three resolutions through the OpenAI-compatible endpoint and record the prompt-token usage from each response. Use those measured numbers, not a guessed formula, as the constants in your budget.
Finally, wire the deduplication and per-request caps into your message-assembly code before you scale traffic. Track image tokens separately in your logs, and review pricing at https://admesh.ai/pricing and in the console at https://console.admesh.ai so cost dashboards reflect current rates rather than stale assumptions.
FAQ
FAQ
Does compressing an image reduce token cost?
Is it safe to always downscale screenshots?
Why does my agent's cost grow every turn?
Where do I find the exact image token formula?
References
Call these models through one gateway
Admesh provides a unified OpenAI-compatible API: one Base URL and one key for Claude, GPT, DeepSeek and more. New accounts get trial credit that never expires.
