Image generation produces images from textual instructions. Spring AI exposes this capability through the ImageModel interface, with implementations for OpenAI, Azure OpenAI, Stability AI, and ZhiPuAI. section 8.3
A service can inject ImageModel and return either a generated image URL or the image bytes. ImagePrompt and ImageOptions support provider requests, while Spring Boot autoconfiguration supplies the selected implementation. section 8.3
A typical integration proceeds as follows:
- Add the provider starter when using Azure OpenAI, Stability AI, or ZhiPuAI; OpenAI requires no additional dependency in the described setup. section 8.3
- Expose generation through application code, returning a URL for browser access or bytes that can be saved as a PNG file. section 8.3
Generating Burger Battle artwork
A REST controller builds instructions for a named burger and delegates generation to ImageService. Calling /burgerBattleArt?burger=Cowboy returns a generated image URL; requesting image/png can save the Sunrise result to sunrise.png.





