Class GoogleGenAiUsage
java.lang.Object
org.springframework.ai.chat.metadata.DefaultUsage
org.springframework.ai.google.genai.metadata.GoogleGenAiUsage
- All Implemented Interfaces:
Usage
Extended usage metadata for Google GenAI responses that includes thinking tokens,
cached content, tool-use tokens, and modality breakdowns.
- Since:
- 1.1.0
- Author:
- Dan Dobrin
-
Constructor Summary
ConstructorsConstructorDescriptionGoogleGenAiUsage(Integer promptTokens, Integer completionTokens, Integer totalTokens, Integer thoughtsTokenCount, Integer cachedContentTokenCount, Integer toolUsePromptTokenCount, List<GoogleGenAiModalityTokenCount> promptTokensDetails, List<GoogleGenAiModalityTokenCount> candidatesTokensDetails, List<GoogleGenAiModalityTokenCount> cacheTokensDetails, List<GoogleGenAiModalityTokenCount> toolUsePromptTokensDetails, GoogleGenAiTrafficType trafficType, com.google.genai.types.GenerateContentResponseUsageMetadata nativeUsage) Creates a new GoogleGenAiUsage instance with all extended metadata. -
Method Summary
Modifier and TypeMethodDescriptionstatic GoogleGenAiUsagefrom(com.google.genai.types.GenerateContentResponseUsageMetadata usageMetadata) Creates a GoogleGenAiUsage instance from the Google GenAI SDK response metadata.Returns the number of tokens in the cached content.Returns the list of modalities of the cached content in the request input.Returns the list of modalities that were returned in the response.Returns the list of modalities that were processed in the request input.Returns the number of tokens present in thoughts output for thinking-enabled models.Returns the number of tokens present in tool-use prompts.Returns the list of modalities that were processed for tool-use request inputs.Returns the traffic type showing whether a request consumes Pay-As-You-Go or Provisioned Throughput quota.toString()Methods inherited from class org.springframework.ai.chat.metadata.DefaultUsage
equals, fromJson, getCompletionTokens, getNativeUsage, getPromptTokens, getTotalTokens, hashCode
-
Constructor Details
-
GoogleGenAiUsage
public GoogleGenAiUsage(Integer promptTokens, Integer completionTokens, Integer totalTokens, @Nullable Integer thoughtsTokenCount, @Nullable Integer cachedContentTokenCount, @Nullable Integer toolUsePromptTokenCount, @Nullable List<GoogleGenAiModalityTokenCount> promptTokensDetails, @Nullable List<GoogleGenAiModalityTokenCount> candidatesTokensDetails, @Nullable List<GoogleGenAiModalityTokenCount> cacheTokensDetails, @Nullable List<GoogleGenAiModalityTokenCount> toolUsePromptTokensDetails, @Nullable GoogleGenAiTrafficType trafficType, @Nullable com.google.genai.types.GenerateContentResponseUsageMetadata nativeUsage) Creates a new GoogleGenAiUsage instance with all extended metadata.
-
-
Method Details
-
from
public static GoogleGenAiUsage from(com.google.genai.types.GenerateContentResponseUsageMetadata usageMetadata) Creates a GoogleGenAiUsage instance from the Google GenAI SDK response metadata.- Parameters:
usageMetadata- the usage metadata from the Google GenAI SDK- Returns:
- a new GoogleGenAiUsage instance with all available metadata
-
getThoughtsTokenCount
Returns the number of tokens present in thoughts output for thinking-enabled models.- Returns:
- the thoughts token count, or null if not available
-
getCachedContentTokenCount
Returns the number of tokens in the cached content.- Returns:
- the cached content token count, or null if not available
-
getToolUsePromptTokenCount
Returns the number of tokens present in tool-use prompts.- Returns:
- the tool-use prompt token count, or null if not available
-
getPromptTokensDetails
Returns the list of modalities that were processed in the request input.- Returns:
- the prompt tokens details by modality, or null if not available
-
getCandidatesTokensDetails
Returns the list of modalities that were returned in the response.- Returns:
- the candidates tokens details by modality, or null if not available
-
getCacheTokensDetails
Returns the list of modalities of the cached content in the request input.- Returns:
- the cache tokens details by modality, or null if not available
-
getToolUsePromptTokensDetails
Returns the list of modalities that were processed for tool-use request inputs.- Returns:
- the tool-use prompt tokens details by modality, or null if not available
-
getTrafficType
Returns the traffic type showing whether a request consumes Pay-As-You-Go or Provisioned Throughput quota.- Returns:
- the traffic type, or null if not available
-
toString
- Overrides:
toStringin classDefaultUsage
-