OpenAI and Anthropic report token usage differently, particularly concerning cached tokens. OpenAI includes cached tokens within its total `prompt_tokens`, with `cached_tokens` indicating the number of cache hits. In contrast, Anthropic separates cached tokens, reporting them under `cache_read_input_tokens` and `cache_creation_input_tokens`, with `input_tokens` only reflecting new, non-cached input. This discrepancy can lead to significant undercounting or overcharging if not handled correctly. The article proposes a standardized `Tokens` data structure to normalize usage reporting across both providers, ensuring accurate cost calculations. AI
IMPACT Developers must adapt their cost-tracking scripts to account for differing token usage reporting between OpenAI and Anthropic to avoid billing errors.
RANK_REASON The item explains a technical nuance in how two major AI providers report token usage, offering a solution for developers to standardize this reporting for cost management.
- Anthropic
- cache_creation_input_tokens
- cached_tokens
- cache_read_input_tokens
- input_tokens
- OpenAI
- prompt_tokens
- total_tokens
AI-generated summary · Google Gemini · from 1 sources. How we write summaries →