From acebc7b7266f6d9e15bf864fac53f1b2f5bed322 Mon Sep 17 00:00:00 2001 From: Google Team Member Date: Wed, 22 Apr 2026 14:50:01 -0700 Subject: [PATCH] feat(interaction-api): Add grounding tool usage breakdown to Interaction Usage. PiperOrigin-RevId: 904057715 --- google/genai/_interactions/types/usage.py | 14 ++++++++++++++ google/genai/_interactions/types/usage_param.py | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/google/genai/_interactions/types/usage.py b/google/genai/_interactions/types/usage.py index 61cf506a6..576f393cd 100644 --- a/google/genai/_interactions/types/usage.py +++ b/google/genai/_interactions/types/usage.py @@ -23,6 +23,7 @@ __all__ = [ "Usage", "CachedTokensByModality", + "GroundingToolCount", "InputTokensByModality", "OutputTokensByModality", "ToolUseTokensByModality", @@ -39,6 +40,16 @@ class CachedTokensByModality(BaseModel): """Number of tokens for the modality.""" +class GroundingToolCount(BaseModel): + """The number of grounding tool counts.""" + + count: Optional[int] = None + """The number of grounding tool counts.""" + + type: Optional[Literal["google_search", "google_map", "your_data"]] = None + """The grounding tool type associated with the count.""" + + class InputTokensByModality(BaseModel): """The token count for a single response modality.""" @@ -75,6 +86,9 @@ class Usage(BaseModel): cached_tokens_by_modality: Optional[List[CachedTokensByModality]] = None """A breakdown of cached token usage by modality.""" + grounding_tool_count: Optional[List[GroundingToolCount]] = None + """Grounding tool count.""" + input_tokens_by_modality: Optional[List[InputTokensByModality]] = None """A breakdown of input token usage by modality.""" diff --git a/google/genai/_interactions/types/usage_param.py b/google/genai/_interactions/types/usage_param.py index b2806aae5..8c1703ea7 100644 --- a/google/genai/_interactions/types/usage_param.py +++ b/google/genai/_interactions/types/usage_param.py @@ -23,6 +23,7 @@ __all__ = [ "UsageParam", "CachedTokensByModality", + "GroundingToolCount", "InputTokensByModality", "OutputTokensByModality", "ToolUseTokensByModality", @@ -39,6 +40,16 @@ class CachedTokensByModality(TypedDict, total=False): """Number of tokens for the modality.""" +class GroundingToolCount(TypedDict, total=False): + """The number of grounding tool counts.""" + + count: int + """The number of grounding tool counts.""" + + type: Literal["google_search", "google_map", "your_data"] + """The grounding tool type associated with the count.""" + + class InputTokensByModality(TypedDict, total=False): """The token count for a single response modality.""" @@ -75,6 +86,9 @@ class UsageParam(TypedDict, total=False): cached_tokens_by_modality: Iterable[CachedTokensByModality] """A breakdown of cached token usage by modality.""" + grounding_tool_count: Iterable[GroundingToolCount] + """Grounding tool count.""" + input_tokens_by_modality: Iterable[InputTokensByModality] """A breakdown of input token usage by modality."""