UsageMetadata#

class langchain_core.messages.ai.UsageMetadata[source]#

Usage metadata for a message, such as token counts.

This is a standard representation of token usage that is consistent across models.

Example

{
    "input_tokens": 10,
    "output_tokens": 20,
    "total_tokens": 30
}
input_tokens: int#

Count of input (or prompt) tokens.

output_tokens: int#

Count of output (or completion) tokens.

total_tokens: int#

Total token count.