Google Gemini charges 258 tokens for any image up to 384 × 384 px. If an image exceeds that size, Gemini adds another 258-token charge for each 768 × 768 px tile. A 500 × 500 px picture therefore costs the same as a 384 × 384 px one, while a 1920 × 1080 px frame spans six tiles and uses 1,548 tokens. For developers who pay per token, crossing the 768-pixel boundary can swing the cost by 75 %.
How Gemini prices images
Gemini treats pictures as a grid of visual patches. A 384-pixel square breaks into 256 patches; two extra tokens mark the start and end of the visual sequence, giving the flat 258-token price. Anything larger triggers a tiling step: the system slices the image into 768-pixel tiles, evaluates each tile independently, and bills each at 258 tokens.
The token count scales with the number of tiles, not raw pixels. A 1280 × 720 px photo occupies two tiles (258 × 2 = 516 tokens). A 3840 × 2160 px 4K frame covers fifteen tiles, costing 3,870 tokens. The rule is simple—count the 768-pixel squares the image occupies, multiply by 258, and you have the token bill.
Why the rule matters
Gemini’s token model translates directly into API expenses.
Practical ways to shrink the bill
- Stay under the tile limit. An 800 × 800 px image splits into four 768-pixel tiles, costing 1,032 tokens—four times the price of a 768 × 768 px picture. Resize to the exact tile boundary and save 75 %.
- Trim empty space. Large white margins still generate patches that count toward the token total. Cropping those margins can cut costs by two-thirds.
- Mind OCR readability. Gemini reads text only when characters are roughly 15–20 px tall. Downscale a document below that threshold and the model misses words, forcing a fallback to text input that may be more expensive.
- Apply a height-per-line rule. For plain-text documents, aim for a total image height equal to the number of lines multiplied by 25 px. This “golden formula” keeps line spacing readable while staying within a single tile.
- Prefer images for dense data. A screenshot of a large spreadsheet or a LaTeX equation often packs more information per token than typing out the same data. When density is high, the image’s 258-token cost can be cheaper than the equivalent text payload.
When images beat text
The token economy flips in favor of pictures for several kinds of content:
- Non-Latin scripts. Hindi, Chinese, Arabic and similar scripts require many characters to convey a short idea; each character still becomes a token in text mode, while the same visual fits in a single image tile.
- Complex mathematical notation. LaTeX formulas balloon in token count. A rendered image of the formula stays within one tile, often costing less than the raw LaTeX string.
- Large UI layouts or tables. Rendering a full-screen UI mockup or a multi-page table as an image sidesteps the need to describe each element in prose, compressing the information into a handful of tiles.
The trade-off
Cutting image size indiscriminately can backfire. If characters shrink below the 15-pixel minimum, Gemini’s OCR fails and developers must fall back to sending raw text—potentially inflating the token bill. Overly aggressive cropping might also cut off context the model needs to answer correctly. The sweet spot is a modest resize that respects the tile boundary while preserving legibility.
Bottom line
Understanding Gemini’s image token arithmetic turns a hidden cost into a controllable variable. Keep images at or below 768 px, trim unnecessary whitespace, and ensure text remains readable to shave tens or hundreds of tokens from each request. For data-dense content—non-Latin scripts, math, tables—images often deliver the same insight for a fraction of the token price. Smart preprocessing, not blind downscaling, is the key to a lean Gemini integration.
Source: dev.to/kushaagr
