When building multimodal AI applications, calculating input costs is significantly more complicated than simply counting words. How many tokens is a 4K image? How is a 2-minute voice note priced? How does a 30-second MP4 video translate into billed tokens?
Here is the exact mathematical breakdown of how OpenAI, Google Gemini, and Anthropic meter and price multimodal media.
1. Image Token Calculation Formulas
Google Gemini (Flat Tile Model)
Regardless of image dimensions, Gemini automatically rescales inputs to fit inside a standardized bounding grid:
- Flat Rate: 258 tokens per image
- At Gemini 2.5 Flash pricing ($0.075 / 1M tokens), each image costs: \(ext{Cost per Image} = rac{258}{1,000,000} imes \$0.075 = \$0.00001935 ext{ (over 51,000 images per dollar!)}\)
OpenAI GPT-4o (Dynamic Patch Model)
- Fit image within a 2048×2048 bounding box.
- Scale shortest side to 768px.
- Calculate number of 512×512 tiles needed:
\(ext{Tokens} = ( ext{Tiles} imes 170) + 85 ext{ (base tokens)}\)
- A 1080×1920 smartphone screenshot requires 4 tiles:
- $(4 imes 170) + 85 = \mathbf{765 ext{ tokens}}$ (~$0.0019 per screenshot).
2. Audio Token Calculation
┌────────────────────────────────────────────────────────┐
│ AUDIO TOKEN GENERATION FORMULA │
├────────────────────────────────────────────────────────┤
│ Audio Sample Rate: 16kHz Mono PCM │
│ Token Factor: ~32 tokens per second of speech │
│ 1 Minute Voice: 60 sec × 32 tokens = 1,920 tokens │
└────────────────────────────────────────────────────────┘
At $0.075/M tokens, one hour of continuous speech costs just $0.0086 (less than one cent!).
3. Video Processing Math
When you submit a video to Gemini API, the client SDK extracts 1 frame per second (fps) alongside the audio track:
\[ext{Total Video Tokens} = ( ext{Duration in Seconds} imes 258 ext{ tokens/frame}) + ( ext{Seconds} imes 32 ext{ audio tokens})\]For a standard 60-second viral Short:
- Visual Frames: $60 imes 258 = 15,480 ext{ tokens}$
- Audio Track: $60 imes 32 = 1,920 ext{ tokens}$
- Total: 17,400 tokens (~$0.0013 per video analysis).
Download the 2026 AI API Cost Optimization Spreadsheet
A complete, ready-to-use template to model, calculate, and project your API bills for Gemini, OpenAI, Grok, and Claude.