CountTokensResponse

public final classCountTokensResponse


The model's response to a count tokens request.

Important: The counters in this class do not include billable image, video or other non-text input. SeePricing for details.

Summary

Public fields

final @NonNullList<@NonNullModalityTokenCount>

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

finalInteger

This field is deprecated. This field is deprecated and will be removed in a future version.

final int

The total number of tokens in the input given to the model as a prompt.

Public constructors

CountTokensResponse(
    int totalTokens,
    Integer totalBillableCharacters,
    @NonNullList<@NonNullModalityTokenCount> promptTokensDetails
)

Public fields

promptTokensDetails

public final @NonNullList<@NonNullModalityTokenCountpromptTokensDetails

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

totalTokens

public final int totalTokens

The total number of tokens in the input given to the model as a prompt.

Public constructors

CountTokensResponse

public CountTokensResponse(
    int totalTokens,
    Integer totalBillableCharacters,
    @NonNullList<@NonNullModalityTokenCount> promptTokensDetails
)

Public methods

component1

public final int component1()

component2

public final Integer component2()

component3

public final List<@NonNullModalityTokenCountcomponent3()

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-08-28 UTC.