ReferenceReference
Usage fields
The exact shape of usage in each protocol.
By the end: You can read token counts from any response format.
The shape of usage depends on the protocol, not on the model vendor.
OpenAI — Chat Completions
"usage": {
"prompt_tokens": 28,
"completion_tokens": 54,
"total_tokens": 82,
"prompt_tokens_details": { "cached_tokens": 0 }
}OpenAI — Responses
"usage": {
"input_tokens": 28,
"output_tokens": 54,
"total_tokens": 82
}Anthropic — Messages
"usage": {
"input_tokens": 28,
"output_tokens": 54,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0
}Anthropic's
input_tokens excludes cache reads and writes. The gateway adds them back so the billed input is the true total, and prices the cached portion at the cached rate.Gemini
"usageMetadata": {
"promptTokenCount": 28,
"candidatesTokenCount": 54,
"totalTokenCount": 82,
"cachedContentTokenCount": 0
}Whatever the field names, the deduction is computed as described in usage fields and metering.