Developer shows double-counting bug in LLM cost estimates from reasoning tokens
A developer found that a cost-tracking function for OpenAI reasoning models overstated costs because it added reasoning tokens to output tokens that already included them. OpenAI's Responses API reports all generated tokens, including hidden reasoning, under output_tokens, with reasoning_tokens serving only as a breakdown. In a made-up example, the faulty version overestimated cost by 58 percent, a mistake that is easy to miss because both figures look plausible. The article notes that Google's Gemini API structures its token fields differently, so omitting its thinking tokens would undercount costs, meaning no single formula fits all providers. It advises checking each provider's token definitions and storing raw usage data before writing cost formulas.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in