spring-projects / spring-projects/spring-ai

Add support for Google GenAI Image Generation (Gemini) in Spring AI

Open
#5,289 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
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 ImageModel implementation 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:

  • ImageModel
  • ImagePrompt
  • ImageResponse
  • 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 ImageModel implementations
  • 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:

  • GoogleGenAiImageModel
  • GoogleGenAiImageApi (low-level SDK adapter)
  • GoogleGenAiImageOptions
  • Spring Boot auto-configuration
  • unit tests

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.