Am I getting free tokens?
Last time I wrote about why one line of code needed an SDK. It ended on a small rule: a missing field comes back undefined, never 0, because a 0 looks like a real number. I'd love to say I came up with that rule by being clever. I came up with it after my own dashboard showed $0 on 176 requests that weren't free.
An integration sent its requests with the provider set to "gemini". My price table filed those models under "google". The lookup found nothing, so the cost was stored as $0 and the status as Success. Nothing logged an error, because as far as the code knew, nothing had gone wrong. Cost is calculated once, when a request lands, so adding the missing price afterwards didn't touch those rows either. They stayed at zero.
(Quick confession for anyone keeping score: before this, I'd have told you the scary bug in a cost tool is overcharging. I had it the wrong way round.)
An overcharge is loud. Someone sees a number that's too high and asks why. A zero is quiet. Your total comes out lower than reality, a feature looks cheaper than it is, and you find out when the provider's invoice disagrees with your dashboard.

If you log usage yourself, it's worth asking what your code does when it can't find a price. Mine does three things now:
Provider names go through a short, written-down alias list. gemini maps to google, claude to anthropic, gpt to openai. What you sent is still stored as you sent it.
An unknown model gets an Unpriced badge. Its cost stays empty, and the dashboard counts how many of those you have.
Model names are never matched by guesswork. gpt-4o is a prefix of gpt-4o-mini, and they're priced differently. A wrong price is worse than no price.
Replies
Be the first to reply
Have a question or a thought to share? Add a comment above to start the conversation.