spring-projects / spring-projects/spring-ai
Add support for Google GenAI Image Generation (Gemini) in Spring AI
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.9k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 5
Description
Please do a quick search on GitHub issues first, the feature you are about to request might have already been requested.
Add support for Google GenAI Image Generation (Gemini) in Spring AI
Expected Behavior
Spring AI should provide first-class support for Google GenAI (Gemini) image generation models (gemini-2.5-flash-image, gemini-3-pro-image-preview, etc.) as a model type, similar to existing support for text and embeddings. Ideally support should include:
- A new
ImageModelimplementation for Gemini image generation - A Spring Boot starter and auto-configuration
- Mapping Gemini image responses into
ImageResponse - A prompt abstraction supporting:
- text instructions
- inline base64 images
- aspect ratio / resolution parameters
- Configuration properties for defaults
Example (illustrative):
GoogleGenAiImagePrompt prompt = GoogleGenAiImagePrompt.builder()
.text("Add happy pug to the picture of the man.")
.addImage(existingBase64Image, "image/jpeg")
.build();
ImageResponse images = imageModel.call(prompt);
Current Behavior
Spring AI currently supports Google GenAI for:
- Chat (text)
- Embeddings
but not for image generation. Developers must call the Google GenAI Java SDK directly, bypassing Spring AI abstractions. There is no unified integration with:
ImageModelImagePromptImageResponse- Spring Boot configuration properties
Context
I am building a Spring Boot application that uses Gemini image generation. While the GenAI Java SDK works directly, an official Spring AI integration would:
- improve DX
- align with existing
ImageModelimplementations - support multimodal Gemini use cases
- leverage Spring Boot starters and configuration
There are no reasonable workarounds that reuse Spring AI abstractions without reimplementing core pieces of the framework.
I am willing to contribute a PR. I already have a working implementation of:
GoogleGenAiImageModelGoogleGenAiImageApi(low-level SDK adapter)GoogleGenAiImageOptions- Spring Boot auto-configuration
- unit tests
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 reviewing Spring AI's existing ImageModel, ImagePrompt, and ImageResponse integrations, along with the current Google GenAI chat and embedding support. Compare the proposed GoogleGenAiImageModel, GoogleGenAiImageApi, GoogleGenAiImageOptions, auto-configuration, and unit tests with those patterns. Done means Gemini image generation works through the Spring AI abstractions and configuration described in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring-boot
- Domain
- ai, backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100