Token Usage
Tokens are the base unit models use to process text. The actual count depends on the model tokenizer and the full request context.
Reading Usage from Responses
Non-streaming responses return input, output, and total tokens in the usage field. Whether streaming requests return usage depends on the upstream model and request parameters.
{
"usage": {
"prompt_tokens": 128,
"completion_tokens": 42,
"total_tokens": 170
}
}