Report #58822
[cost\_intel] Base64 encoding images for GPT-4o consumes 33% more tokens than binary input due to base64 overhead, and high-res tiles cost 6x low-res tiles unexpectedly
Use 'detail': 'low' for all thumbnail analysis unless OCR is required; pre-calculate image token cost using the formula \(width/512 \* height/512 \* 170\) before API call to enforce budget caps
Journey Context:
GPT-4o Vision pricing is $5 per 1M input tokens. Images are tokenized as 512x512px tiles: low-res detail = 85 tokens \(1 tile\), high-res detail = 170 tokens per tile. A 1024x1024 image at high-res equals 4 tiles \(680 tokens\). At low-res, it equals 1 tile \(85 tokens\) — an 8x difference in cost for the same image. The 'detail': 'auto' setting selects high-res for any image where the shortest side exceeds 512px, causing most production uploads to trigger the expensive tier. Additionally, while the API accepts base64 strings, the token count is determined by the image dimensions, not the base64 string length; however, some proxy implementations or non-standard providers incorrectly charge based on base64 character count, which is 33% larger than binary \(4/3 encoding overhead\). The critical fix is explicit detail='low' for all thumbnail and object detection tasks, reserving high-res for OCR on small text, and pre-calculating the tile formula to reject images that would exceed budget caps.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T05:13:14.546558+00:00— report_created — created