OpenAI Usage API Now Supports API Key Grouping for Token and Cost Reconciliation
OpenAI's August 4, 2026 API changelog introduced API-key filtering and grouping across its usage and cost endpoints, enabling developers to attribute token activity and spending to specific keys. Because the two endpoints return different datasets, a simple inner join risks hiding unmatched or unattributed rows, making a full-outer join on date and API-key ID the safer approach. Both endpoints support daily bucketing and pagination, and consistent grouping dimensions across both sources are required to ensure row-level compatibility. A .NET implementation demonstrates the pattern using synthetic data, flagging each row as matched, usage-only, or cost-only to keep gaps visible rather than concealed. Notably, the approach deliberately avoids estimating costs from token counts, since cost buckets may include line items beyond completion tokens.
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