Skip to content

feat(google_genai): add generate_images tracing support#161

Open
Abhijeet Prasad (AbhiPrasad) wants to merge 2 commits intomainfrom
abhi-feat-google-genai-generate-images-tracing
Open

feat(google_genai): add generate_images tracing support#161
Abhijeet Prasad (AbhiPrasad) wants to merge 2 commits intomainfrom
abhi-feat-google-genai-generate-images-tracing

Conversation

@AbhiPrasad
Copy link
Copy Markdown
Member

resolves #154

Add tracing for the Google GenAI generate_images API (both sync and async). This includes patchers, input/output serialization, metric extraction, and VCR-based tests with image payload sanitization to keep cassettes small.

Key changes:

  • ModelsGenerateImagesPatcher and AsyncModelsGenerateImagesPatcher
  • _generate_images_wrapper / _async_generate_images_wrapper
  • Output captures image count, sizes, mime types, and safety attrs without storing raw image bytes in spans
  • VCR before_record_response replaces image bytes with a tiny PNG
  • Sync and async test cases validating span structure and metrics

Add tracing for the Google GenAI generate_images API (both sync and
async). Generated image bytes are wrapped in Attachment objects so the
SDK uploads them to object storage and the Braintrust UI can render
them, following the same pattern used for input-side inline_data in
both the google_genai and adk integrations.

Key changes:
- ModelsGenerateImagesPatcher and AsyncModelsGenerateImagesPatcher
- _generate_images_wrapper / _async_generate_images_wrapper
- Output includes image metadata (size, mime type, safety attrs) plus
  an Attachment per generated image in {"image_url": {"url": attachment}}
- VCR before_record_response sanitizes image bytes in cassettes
- Sync and async test cases validate span structure, metrics, and
  Attachment objects
@AbhiPrasad Abhijeet Prasad (AbhiPrasad) force-pushed the abhi-feat-google-genai-generate-images-tracing branch from f60a543 to d1d1108 Compare March 27, 2026 01:31
@AbhiPrasad Abhijeet Prasad (AbhiPrasad) marked this pull request as ready for review March 27, 2026 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Google GenAI: generate_images() (Imagen) not instrumented

1 participant