UsageMetadata interface

Usage metadata about aGenerateContentResponse.

Signature:

exportinterfaceUsageMetadata

Properties

PropertyTypeDescription
cachedContentTokenCountnumberThe number of tokens in the prompt that were served from the cache. If implicit caching is not active or no content was cached, this will be 0.
cacheTokensDetailsModalityTokenCount[]Detailed breakdown of the cached tokens by modality (for example, text or image). This list provides granular insight into which parts of the content were cached.
candidatesTokenCountnumber
candidatesTokensDetailsModalityTokenCount[]
promptTokenCountnumber
promptTokensDetailsModalityTokenCount[]
thoughtsTokenCountnumberThe number of tokens used by the model's internal "thinking" process.
toolUsePromptTokenCountnumberThe number of tokens used by tools.
toolUsePromptTokensDetailsModalityTokenCount[]A list of tokens used by tools, broken down by modality.
totalTokenCountnumber

UsageMetadata.cachedContentTokenCount

The number of tokens in the prompt that were served from the cache. If implicit caching is not active or no content was cached, this will be 0.

Signature:

cachedContentTokenCount?:number;

UsageMetadata.cacheTokensDetails

Detailed breakdown of the cached tokens by modality (for example, text or image). This list provides granular insight into which parts of the content were cached.

Signature:

cacheTokensDetails?:ModalityTokenCount[];

UsageMetadata.candidatesTokenCount

Signature:

candidatesTokenCount:number;

UsageMetadata.candidatesTokensDetails

Signature:

candidatesTokensDetails?:ModalityTokenCount[];

UsageMetadata.promptTokenCount

Signature:

promptTokenCount:number;

UsageMetadata.promptTokensDetails

Signature:

promptTokensDetails?:ModalityTokenCount[];

UsageMetadata.thoughtsTokenCount

The number of tokens used by the model's internal "thinking" process.

Signature:

thoughtsTokenCount?:number;

UsageMetadata.toolUsePromptTokenCount

The number of tokens used by tools.

Signature:

toolUsePromptTokenCount?:number;

UsageMetadata.toolUsePromptTokensDetails

A list of tokens used by tools, broken down by modality.

Signature:

toolUsePromptTokensDetails?:ModalityTokenCount[];

UsageMetadata.totalTokenCount

Signature:

totalTokenCount:number;

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-05 UTC.