A technical article explains how AI gateway providers can silently under-report token usage, leading to discrepancies between usage panels and invoices. The issue stems from the optional 'usage' field in OpenAI-compatible API responses, which is often omitted for streaming requests by default. When streaming is enabled with specific options, a special chunk containing usage data is sent, but gateway proxies may skip this chunk if it contains an empty 'choices' array. The article provides three curl commands to help users diagnose if their gateway is under-reporting token counts, highlighting the potential for reconciliation gaps and difficulties in accurately tracking input versus output token costs. AI
IMPACT Highlights potential discrepancies in AI API billing and provides tools for developers to verify token usage.
RANK_REASON Technical article detailing a specific implementation detail and diagnostic method for AI API usage reporting.
AI-generated summary · Google Gemini · from 1 sources. How we write summaries →