Skip to content

feat(genai): migrate ImageGenWithText to gemini-2.5-flash-image - #10335

Draft
Kef131 wants to merge 2 commits into
mainfrom
feat-genai-imagegen-with-text-gemini-flash
Draft

feat(genai): migrate ImageGenWithText to gemini-2.5-flash-image#10335
Kef131 wants to merge 2 commits into
mainfrom
feat-genai-imagegen-with-text-gemini-flash

Conversation

@Kef131

@Kef131 Kef131 commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #
b/549909475

  • Migrate ImageGenWithText.java from deprecated Imagen (imagen-4.0-generate-001 via client.models.generateImages) to gemini-2.5-flash-image using client.models.generateContent with responseModalities("TEXT", "IMAGE").
  • Update ImageGenerationIT.java to support configurable BUCKET_NAME, add safe error handling in @AfterClass cleanup(), and validate testImageGenWithText against gemini-2.5-flash-image.
  • Temporarily mark remaining deprecated Imagen capability tests with @Ignore pending multimodal migration in follow-up PR.

Checklist

Testing

  • I have tested this change on a live environment and verified it works as intended.
  • Tests pass: mvn clean verify required
  • Lint passes: mvn -P lint checkstyle:check required
  • Static Analysis: mvn -P lint clean compile pmd:cpd-check spotbugs:check advisory only

Compliance & Style

  • I have followed Sample Format Guide
  • pom.xml parent set to latest shared-configuration
  • Appropriate changes to README are included in PR
  • This sample adds a new sample directory, and I updated the CODEOWNERS file with the codeowners for this sample
  • This sample adds a new Product API, and I updated the Blunderbuss issue/PR auto-assigner with the codeowners for this sample

Post-Approval Actions

  • Please merge this PR for me once it is approved

- Update ImageGenWithText to use client.models.generateContent with gemini-2.5-flash-image
- Update ImageGenerationIT with configurable bucket, safe cleanup, and testImageGenWithText validation
- Temporarily ignore remaining deprecated Imagen capability tests pending migration
@product-auto-label product-auto-label Bot added the samples Issues that are directly related to samples. label Aug 24, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request migrates the image generation sample and its integration tests from using the deprecated Imagen model to the Gemini model (gemini-2.5-flash-image) via the generateContent API. It also updates the integration tests to handle GCS cleanup errors gracefully and temporarily ignores tests associated with deprecated Imagen models. The reviewer suggested using the %d format specifier instead of %s when printing the image byte length to ensure proper type-safe formatting.

Comment thread genai/snippets/src/main/java/genai/imagegeneration/ImageGenWithText.java Outdated
…hText.java

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@Kef131 Kef131 self-assigned this Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant