ImageOptions is Spring AI’s request-configuration object for image generation. It separates image parameters from application logic and lets an ImageModel request specify dimensions, response format, style, model, and image count. section 8.3 section 8.3.1
Configure the generated image with:
- width(Integer) and height(Integer), which are required at minimum and commonly produce a 1024 × 1024 image. section 8.3
- responseFormat(String), choosing url for a retrievable image URL or b64_json for Base64-encoded image data. section 8.3
- style(String), selecting vivid or natural output; natural produces a more photorealistic result. section 8.3.1
- model(String) and n(Integer), selecting the model and number of generated images. section 8.3.1
- Provider-specific options such as OpenAI quality and user, or Azure OpenAI deploymentName. section 8.3.1
Configure a high-definition natural image
ImageOptions options = OpenAiImageOptions.builder() .height(1024) .width(1024) .responseFormat(format) .style("natural") .quality("hd") .build(); The same values can become application defaults through properties such as spring.ai.openai.image.options.height, width, style, and quality. An image service can then pass these options with an ImagePrompt to an ImageModel, returning either a URL or image bytes. section 8.3.1 section 8.3
Table 8.1 ImageOptionsBuilder methods for setting image options
|
Method
|
Description
|
|---|---|
height(Integer)
|
The height of the image
|
model(String)
|
The name of the model to use. Either
dall-e-2 or
dall-e-3. Default:
dall-e-3.
|
N(Integer)
|
The number of images to generate
|
responseFormat(String)
|
The format of the returned image. Either
url or
b64_json. Default:
url.
|
style(String)
|
The image style. Either
vivid or
natural.
|
width(Integer)
|
The width of the image
|
Browse the ImageOptionsBuilder method table for dimensions, model selection, image count, response format, and style. section 8.3.1
