spring-projects / spring-projects/spring-ai
Migrate Google Vertex AI integration from google-cloud-vertexai to google-genai (Imagen & Gemini)
Open
Nobody has claimed this yet.
status: waiting-for-triage
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.9k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 6
Description
Proposal: Migrate Google Vertex AI integration from google-cloud-vertexai to google-genai (Imagen & Gemini)
Summary
- Current state: The
google-cloud-vertexaidependency is no longer the recommended path for Generative AI. In practice it’s convenient for Gemini chat flows but does not provide a first-class, maintainable path for Google’s Imagen image generation in Spring AI. - Issue: With
google-cloud-vertexai, Spring AI can wire up Gemini conversations, but cannot cleanly support Google’s Imagen image models via a portableImageModelimplementation. - Proposal: Migrate the Google provider in Spring AI to Google Gen AI SDK (
com.google.genai:google-genai) as the primary integration for both Gemini (chat/multimodal) and Imagen (image generation).
Reference repo for the current Vertex AI library:
https://github.com/googleapis/google-cloud-java/tree/main/java-vertexai
Background & Rationale
- Google recommends using the Google Gen AI SDK going forward.
- The
google-genaiSDK offers a unifiedClientthat can target Gemini API or Vertex AI backends and includes built-in, high-level support for Imagen. - Aligning Spring AI with
google-genaiimproves feature coverage (Imagen), reduces low-level request handling, and fits Spring AI’sImageModelabstraction.
Problem Statement
- The existing Spring AI adapter based on
google-cloud-vertexaiis oriented to Gemini chat and relies on low-levelPredictionServiceClient#predictto hit image endpoints. This leads to ad-hoc request construction and an inconsistent developer experience versus other Spring AI models. - We need a portable, first-class image generation flow for Google models (Imagen) in Spring AI.
Proposed Change
- Introduce
google-genaiimplementations- Add
ImagenImageApi,ImagenImageOptions, andImagenImageModelpowered bycom.google.genai:google-genai. - Expose Imagen parameters such as
imageSize,aspectRatio, watermarking, language, safety filtering, and output formats through Spring AI’s options.
- Add
- Update Gemini support
- Provide a
google-genai-based Gemini path for parity and consistency.
- Provide a
- Documentation & samples
- Document the migration and add end-to-end samples (Imagen generation with
ImagePrompt→ImageResponse).
- Document the migration and add end-to-end samples (Imagen generation with
Compatibility & Migration
- Low-risk migration path: Keep the current
google-cloud-vertexaiadapter available for a transition period, but recommendgoogle-genaifor new development—especially for Imagen. - Longer term: Prefer
google-genaias the primary implementation and discourage adding new features on top ofgoogle-cloud-vertexaifor image generation.
Alternatives Considered
- Continue on
google-cloud-vertexaiwith custom wrappers aroundPredictionServiceClient#predictfor Imagen.- Cons: Higher maintenance overhead, poorer developer experience, and not aligned with the recommended SDK direction.
References
- Vertex AI library repo (current): https://github.com/googleapis/google-cloud-java/tree/main/java-vertexai
- Google Gen AI SDK for Java (target):
com.google.genai:google-genai
Tasks
- Add
google-genai-based Imagen implementation (API/Options/Model). - Update Gemini integration to use
google-genai. - Provide migration notes and samples.
- Add tests and documentation (Imagen generation, backend selection).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting the existing google-cloud-vertexai adapter and its use of PredictionServiceClient#predict. Then review the proposed ImagenImageApi, ImagenImageOptions, and ImagenImageModel entry points alongside the ImagePrompt → ImageResponse flow. Done means the google-genai Imagen path, Gemini support, migration notes, samples, tests, and backend-selection documentation are provided.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- google-cloud, java
- Domain
- ai, backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100