Watching the Cost of Every Photo

image cost and batching

Part of: Receipt Scanner

Text is cheap to send. A few hundred words is a few hundred tokens. Photos don't work that way. A full-resolution image can cost more tokens than a page of text, and once this scanner is meant to work through a shoebox of receipts rather than one at a time, that adds up quickly. This lesson is about seeing the cost coming and running a batch so one bad file doesn't take down the rest. Estimating image cost Vision APIs bill image tokens by pixel count, not file size in bytes. A rough rule of thumb some providers use is about one token per 750 pixels: The exact formula shifts by provider and model, but the point holds either way. A 4000x3000 photo straight off a phone camera costs far more than the same receipt scaled down to something readable like 1000x750. Before you send an image, ask whether you really need full camera resolution to read a receipt. You almost never do. Resizing before you send A quick resize with an imaging library cuts the cost with almost no loss in what the model has to read: Capping the longest side at 1200 pixels keeps receipt text legible while cutting the token bill well below an uncompressed phone photo. Batching without one failure taking down the rest

Challenge: Batch Bill