Skip to content

Commit e1969be

Browse files
committed
update docs and format
Signed-off-by: Alexandros Pappas <[email protected]>
1 parent 07c07e6 commit e1969be

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

models/spring-ai-openai/src/main/java/org/springframework/ai/openai/OpenAiImageModel.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -253,20 +253,11 @@ public Flux<ImageResponse> stream(ImagePrompt imagePrompt) {
253253

254254
// Convert streaming events to ImageResponse
255255
return eventStream.map(event -> {
256-
// Create an Image from the event
257256
Image image = new Image(null, event.b64Json());
258-
259-
// Create metadata
260257
OpenAiImageGenerationMetadata metadata = new OpenAiImageGenerationMetadata(null);
261-
262-
// Create ImageGeneration
263258
ImageGeneration generation = new ImageGeneration(image, metadata);
264-
265-
// Create ImageResponseMetadata with created timestamp and usage info
266259
ImageResponseMetadata responseMetadata = event.createdAt() != null
267260
? new ImageResponseMetadata(event.createdAt()) : new ImageResponseMetadata(null);
268-
269-
// Return ImageResponse with single generation
270261
return new ImageResponse(List.of(generation), responseMetadata);
271262
});
272263
}

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/image/openai-image.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ The prefix `spring.ai.openai.image` is the property prefix that lets you configu
134134
| spring.ai.openai.image.organization-id | Optionally you can specify which organization used for an API request. | -
135135
| spring.ai.openai.image.project-id | Optionally, you can specify which project is used for an API request. | -
136136
| spring.ai.openai.image.options.n | The number of images to generate. Must be between 1 and 10. For dall-e-3 and gpt-image models, only n=1 is supported. | -
137-
| spring.ai.openai.image.options.model | The model to use for image generation. Available models: `gpt-image-1-mini` (default), `gpt-image-1`, `dall-e-3`, `dall-e-2`. | gpt-image-1-mini
137+
| spring.ai.openai.image.options.model | The model to use for image generation. Available models: `dall-e-3` (default), `dall-e-2`, `gpt-image-1`, `gpt-image-1-mini`. | dall-e-3
138138
| spring.ai.openai.image.options.quality | The quality of the image. For gpt-image-1: `high`, `medium`, `low`, or `auto` (default). For dall-e-3: `hd` or `standard`. | -
139139
| spring.ai.openai.image.options.response_format | The format in which the generated images are returned. Must be one of `url` or `b64_json`. Only supported for dall-e-2 and dall-e-3. GPT-Image models always return base64-encoded images. | -
140140
| `spring.ai.openai.image.options.size` | The size of the generated images. For gpt-image-1: `1024x1024`, `1536x1024`, `1024x1536`, or `auto` (default). For dall-e-2: `256x256`, `512x512`, or `1024x1024`. For dall-e-3: `1024x1024`, `1792x1024`, or `1024x1792`. | -

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/imageclient.adoc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,23 @@ public interface ImageModel extends Model<ImagePrompt, ImageResponse> {
2828
}
2929
----
3030

31+
=== Streaming Image Model
32+
33+
For models that support streaming image generation, Spring AI provides the link:https://github.com/spring-projects/spring-ai/blob/main/spring-ai-model/src/main/java/org/springframework/ai/image/StreamingImageModel.java[StreamingImageModel] interface:
34+
35+
[source,java]
36+
----
37+
public interface StreamingImageModel extends StreamingModel<ImagePrompt, ImageResponse> {
38+
39+
Flux<ImageResponse> stream(ImagePrompt prompt);
40+
41+
}
42+
----
43+
44+
The `StreamingImageModel` interface allows AI models to generate images progressively, emitting partial images as they are being created. This provides a better user experience by showing incremental progress rather than waiting for the final image.
45+
46+
NOTE: Streaming image generation is currently only supported by certain models like OpenAI's GPT-Image models (gpt-image-1 and gpt-image-1-mini). Traditional models like DALL-E do not support streaming.
47+
3148
=== ImagePrompt
3249

3350
The https://github.com/spring-projects/spring-ai/blob/main/spring-ai-model/src/main/java/org/springframework/ai/image/ImagePrompt.java[ImagePrompt] is a `ModelRequest` that encapsulates a list of https://github.com/spring-projects/spring-ai/blob/main/spring-ai-model/src/main/java/org/springframework/ai/image/ImageMessage.java[ImageMessage] objects and optional model request options.

0 commit comments

Comments
 (0)