Skip to content

feat: include token usage count in GoogleGenAIChatGenerator response metadata#2851

Open
davidsbatista wants to merge 17 commits intomainfrom
feat/token-usage-count-in-metadata
Open

feat: include token usage count in GoogleGenAIChatGenerator response metadata#2851
davidsbatista wants to merge 17 commits intomainfrom
feat/token-usage-count-in-metadata

Conversation

@davidsbatista
Copy link
Contributor

@davidsbatista davidsbatista commented Feb 17, 2026

Related Issues

Proposed Changes:

  • Introduces a new component, theGoogleGenAICacheCreator to create context caches, returns cache_name for pass to a GoogleGenAIChatGenerator with the generation_kwargs={"cached_content": cache_name}.

  • GoogleGenAIChatGenerator response now includes ["_meta"]["usage"]["cached_content_token_count"]

  • Converted some methods to static

How did you test it?

  • Unit tests for the new component

  • added an Integration – test_live_run_with_cache: creates a cache, runs the chat generator with cached_content, asserts one reply, model, finish_reason, and usage (including cached_content_token_count).

Checklist

@github-actions github-actions bot added the type:documentation Improvements or additions to documentation label Feb 17, 2026
@davidsbatista davidsbatista marked this pull request as ready for review February 17, 2026 16:56
@davidsbatista davidsbatista requested a review from a team as a code owner February 17, 2026 16:56
@davidsbatista davidsbatista requested review from anakin87 and removed request for a team February 17, 2026 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration:google-genai type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant