Class UsageMetadata.Builder

java.lang.Object
com.google.genai.types.UsageMetadata.Builder
Enclosing class:
UsageMetadata

public abstract static class UsageMetadata.Builder extends Object
Builder for UsageMetadata.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • promptTokenCount

      public abstract UsageMetadata.Builder promptTokenCount(Integer promptTokenCount)
      Setter for promptTokenCount.

      promptTokenCount: The total number of tokens in the prompt. This includes any text, images, or other media provided in the request. When `cached_content` is set, this also includes the number of tokens in the cached content.

    • clearPromptTokenCount

      @CanIgnoreReturnValue public UsageMetadata.Builder clearPromptTokenCount()
      Clears the value of promptTokenCount field.
    • cachedContentTokenCount

      public abstract UsageMetadata.Builder cachedContentTokenCount(Integer cachedContentTokenCount)
      Setter for cachedContentTokenCount.

      cachedContentTokenCount: Output only. The number of tokens in the cached content that was used for this request.

    • clearCachedContentTokenCount

      @CanIgnoreReturnValue public UsageMetadata.Builder clearCachedContentTokenCount()
      Clears the value of cachedContentTokenCount field.
    • responseTokenCount

      public abstract UsageMetadata.Builder responseTokenCount(Integer responseTokenCount)
      Setter for responseTokenCount.

      responseTokenCount: Total number of tokens across all the generated response candidates.

    • clearResponseTokenCount

      @CanIgnoreReturnValue public UsageMetadata.Builder clearResponseTokenCount()
      Clears the value of responseTokenCount field.
    • toolUsePromptTokenCount

      public abstract UsageMetadata.Builder toolUsePromptTokenCount(Integer toolUsePromptTokenCount)
      Setter for toolUsePromptTokenCount.

      toolUsePromptTokenCount: Output only. The number of tokens in the results from tool executions, which are provided back to the model as input, if applicable.

    • clearToolUsePromptTokenCount

      @CanIgnoreReturnValue public UsageMetadata.Builder clearToolUsePromptTokenCount()
      Clears the value of toolUsePromptTokenCount field.
    • thoughtsTokenCount

      public abstract UsageMetadata.Builder thoughtsTokenCount(Integer thoughtsTokenCount)
      Setter for thoughtsTokenCount.

      thoughtsTokenCount: Output only. The number of tokens that were part of the model's generated "thoughts" output, if applicable.

    • clearThoughtsTokenCount

      @CanIgnoreReturnValue public UsageMetadata.Builder clearThoughtsTokenCount()
      Clears the value of thoughtsTokenCount field.
    • totalTokenCount

      public abstract UsageMetadata.Builder totalTokenCount(Integer totalTokenCount)
      Setter for totalTokenCount.

      totalTokenCount: The total number of tokens for the entire request. This is the sum of `prompt_token_count`, `candidates_token_count`, `tool_use_prompt_token_count`, and `thoughts_token_count`.

    • clearTotalTokenCount

      @CanIgnoreReturnValue public UsageMetadata.Builder clearTotalTokenCount()
      Clears the value of totalTokenCount field.
    • promptTokensDetails

      public abstract UsageMetadata.Builder promptTokensDetails(List<ModalityTokenCount> promptTokensDetails)
      Setter for promptTokensDetails.

      promptTokensDetails: Output only. A detailed breakdown of the token count for each modality in the prompt.

    • promptTokensDetails

      @CanIgnoreReturnValue public UsageMetadata.Builder promptTokensDetails(ModalityTokenCount... promptTokensDetails)
      Setter for promptTokensDetails.

      promptTokensDetails: Output only. A detailed breakdown of the token count for each modality in the prompt.

    • promptTokensDetails

      @CanIgnoreReturnValue public UsageMetadata.Builder promptTokensDetails(ModalityTokenCount.Builder... promptTokensDetailsBuilders)
      Setter for promptTokensDetails builder.

      promptTokensDetails: Output only. A detailed breakdown of the token count for each modality in the prompt.

    • clearPromptTokensDetails

      @CanIgnoreReturnValue public UsageMetadata.Builder clearPromptTokensDetails()
      Clears the value of promptTokensDetails field.
    • cacheTokensDetails

      public abstract UsageMetadata.Builder cacheTokensDetails(List<ModalityTokenCount> cacheTokensDetails)
      Setter for cacheTokensDetails.

      cacheTokensDetails: Output only. A detailed breakdown of the token count for each modality in the cached content.

    • cacheTokensDetails

      @CanIgnoreReturnValue public UsageMetadata.Builder cacheTokensDetails(ModalityTokenCount... cacheTokensDetails)
      Setter for cacheTokensDetails.

      cacheTokensDetails: Output only. A detailed breakdown of the token count for each modality in the cached content.

    • cacheTokensDetails

      @CanIgnoreReturnValue public UsageMetadata.Builder cacheTokensDetails(ModalityTokenCount.Builder... cacheTokensDetailsBuilders)
      Setter for cacheTokensDetails builder.

      cacheTokensDetails: Output only. A detailed breakdown of the token count for each modality in the cached content.

    • clearCacheTokensDetails

      @CanIgnoreReturnValue public UsageMetadata.Builder clearCacheTokensDetails()
      Clears the value of cacheTokensDetails field.
    • responseTokensDetails

      public abstract UsageMetadata.Builder responseTokensDetails(List<ModalityTokenCount> responseTokensDetails)
      Setter for responseTokensDetails.

      responseTokensDetails: List of modalities that were returned in the response.

    • responseTokensDetails

      @CanIgnoreReturnValue public UsageMetadata.Builder responseTokensDetails(ModalityTokenCount... responseTokensDetails)
      Setter for responseTokensDetails.

      responseTokensDetails: List of modalities that were returned in the response.

    • responseTokensDetails

      @CanIgnoreReturnValue public UsageMetadata.Builder responseTokensDetails(ModalityTokenCount.Builder... responseTokensDetailsBuilders)
      Setter for responseTokensDetails builder.

      responseTokensDetails: List of modalities that were returned in the response.

    • clearResponseTokensDetails

      @CanIgnoreReturnValue public UsageMetadata.Builder clearResponseTokensDetails()
      Clears the value of responseTokensDetails field.
    • toolUsePromptTokensDetails

      public abstract UsageMetadata.Builder toolUsePromptTokensDetails(List<ModalityTokenCount> toolUsePromptTokensDetails)
      Setter for toolUsePromptTokensDetails.

      toolUsePromptTokensDetails: Output only. A detailed breakdown by modality of the token counts from the results of tool executions, which are provided back to the model as input.

    • toolUsePromptTokensDetails

      @CanIgnoreReturnValue public UsageMetadata.Builder toolUsePromptTokensDetails(ModalityTokenCount... toolUsePromptTokensDetails)
      Setter for toolUsePromptTokensDetails.

      toolUsePromptTokensDetails: Output only. A detailed breakdown by modality of the token counts from the results of tool executions, which are provided back to the model as input.

    • toolUsePromptTokensDetails

      @CanIgnoreReturnValue public UsageMetadata.Builder toolUsePromptTokensDetails(ModalityTokenCount.Builder... toolUsePromptTokensDetailsBuilders)
      Setter for toolUsePromptTokensDetails builder.

      toolUsePromptTokensDetails: Output only. A detailed breakdown by modality of the token counts from the results of tool executions, which are provided back to the model as input.

    • clearToolUsePromptTokensDetails

      @CanIgnoreReturnValue public UsageMetadata.Builder clearToolUsePromptTokensDetails()
      Clears the value of toolUsePromptTokensDetails field.
    • trafficType

      public abstract UsageMetadata.Builder trafficType(TrafficType trafficType)
      Setter for trafficType.

      trafficType: Output only. The traffic type for this request. This field is not supported in Gemini API.

    • clearTrafficType

      @CanIgnoreReturnValue public UsageMetadata.Builder clearTrafficType()
      Clears the value of trafficType field.
    • trafficType

      @CanIgnoreReturnValue public UsageMetadata.Builder trafficType(TrafficType.Known knownType)
      Setter for trafficType given a known enum.

      trafficType: Output only. The traffic type for this request. This field is not supported in Gemini API.

    • trafficType

      @CanIgnoreReturnValue public UsageMetadata.Builder trafficType(String trafficType)
      Setter for trafficType given a string.

      trafficType: Output only. The traffic type for this request. This field is not supported in Gemini API.

    • serviceTier

      public abstract UsageMetadata.Builder serviceTier(ServiceTier serviceTier)
      Setter for serviceTier.

      serviceTier: Output only. Service tier of the request. This field is not supported in Vertex AI.

    • clearServiceTier

      @CanIgnoreReturnValue public UsageMetadata.Builder clearServiceTier()
      Clears the value of serviceTier field.
    • serviceTier

      @CanIgnoreReturnValue public UsageMetadata.Builder serviceTier(ServiceTier.Known knownType)
      Setter for serviceTier given a known enum.

      serviceTier: Output only. Service tier of the request. This field is not supported in Vertex AI.

    • serviceTier

      @CanIgnoreReturnValue public UsageMetadata.Builder serviceTier(String serviceTier)
      Setter for serviceTier given a string.

      serviceTier: Output only. Service tier of the request. This field is not supported in Vertex AI.

    • build

      public abstract UsageMetadata build()