Usage metadata for a message, such as token counts.
This is a standard representation of token usage that is consistent across models.
UsageMetadata()| Name | Type |
|---|---|
| input_tokens | int |
| output_tokens | int |
| total_tokens | int |
| input_token_details | NotRequired[InputTokenDetails] |
| output_token_details | NotRequired[OutputTokenDetails] |
| input_cost | NotRequired[float] |
| output_cost | NotRequired[float] |
| total_cost | NotRequired[float] |
| input_cost_details | NotRequired[InputCostDetails] |
| output_cost_details | NotRequired[OutputCostDetails] |
Count of input (or prompt) tokens. Sum of all input token types.
Count of output (or completion) tokens. Sum of all output token types.
Total token count. Sum of input_tokens + output_tokens.
Breakdown of input token counts.
Does not need to sum to full input token count. Does not need to have all keys.
Breakdown of output token counts.
Does not need to sum to full output token count. Does not need to have all keys.
The cost of the input tokens.
The cost of the output tokens.
The total cost of the tokens.
The cost details of the input tokens.
The cost details of the output tokens.