CountTokensResponse

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 constructors

CountTokensResponse(
    totalTokens: Int,
    totalBillableCharacters: Int?,
    promptTokensDetails: List<ModalityTokenCount>
)

Public functions

operatorInt
operatorInt?
operatorList<ModalityTokenCount>?

Public properties

List<ModalityTokenCount>

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

Int?

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

Int

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

Public constructors

CountTokensResponse

CountTokensResponse(
    totalTokens: Int,
    totalBillableCharacters: Int? = null,
    promptTokensDetails: List<ModalityTokenCount> = emptyList()
)

Public functions

component1

operator fun component1(): Int

component2

operator fun component2(): Int?

component3

operator fun component3(): List<ModalityTokenCount>?

Public properties

promptTokensDetails

val promptTokensDetailsList<ModalityTokenCount>

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

totalTokens

val totalTokensInt

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

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.