UsageMetadata

public final classUsageMetadata


Usage metadata about response(s).

Summary

Public fields

finalInteger

Number of tokens in the response(s).

final @NonNullList<@NonNullModalityTokenCount>

The breakdown, by modality, of how many tokens are consumed by the candidates.

final int

Number of tokens in the request.

final @NonNullList<@NonNullModalityTokenCount>

The breakdown, by modality, of how many tokens are consumed by the prompt.

final int

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

final int

The number of tokens used by tools.

final @NonNullList<@NonNullModalityTokenCount>

The breakdown, by modality, of how many tokens are consumed by tools.

final int

Total number of tokens.

Public constructors

UsageMetadata(
    int promptTokenCount,
    Integer candidatesTokenCount,
    int totalTokenCount,
    @NonNullList<@NonNullModalityTokenCount> promptTokensDetails,
    @NonNullList<@NonNullModalityTokenCount> candidatesTokensDetails,
    int thoughtsTokenCount
)

This method is deprecated. Not intended for public use

Public fields

candidatesTokenCount

public final Integer candidatesTokenCount

Number of tokens in the response(s).

candidatesTokensDetails

public final @NonNullList<@NonNullModalityTokenCountcandidatesTokensDetails

The breakdown, by modality, of how many tokens are consumed by the candidates.

promptTokenCount

public final int promptTokenCount

Number of tokens in the request.

promptTokensDetails

public final @NonNullList<@NonNullModalityTokenCountpromptTokensDetails

The breakdown, by modality, of how many tokens are consumed by the prompt.

thoughtsTokenCount

public final int thoughtsTokenCount

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

toolUsePromptTokenCount

public final int toolUsePromptTokenCount

The number of tokens used by tools.

toolUsePromptTokensDetails

public final @NonNullList<@NonNullModalityTokenCounttoolUsePromptTokensDetails

The breakdown, by modality, of how many tokens are consumed by tools.

totalTokenCount

public final int totalTokenCount

Total number of tokens.

Public constructors

UsageMetadata

public UsageMetadata(
    int promptTokenCount,
    Integer candidatesTokenCount,
    int totalTokenCount,
    @NonNullList<@NonNullModalityTokenCount> promptTokensDetails,
    @NonNullList<@NonNullModalityTokenCount> candidatesTokensDetails,
    int thoughtsTokenCount
)
This method is deprecated.
Not intended for public use

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 2025-10-09 UTC.