Skip to content

Conversation

@kuntal1461
Copy link
Contributor

Summary

This PR contributes to issue #326 by improving the API design of org.springframework.ai.image:
Introduces a new ImageResponseFormat enum for strongly typed response formats.
Aligns ImageOptions across providers (OpenAI, Azure OpenAI, Stability, ZhiPuAi).
Updates tests accordingly.
Enhances documentation to reflect the new type-safe format property.
Ensures observation and response metadata consistency.
This aligns image models with improved usability and type safety.

Testing

  • ./mvnw -q -DskipITs -DskipNpm -Dgpg.skip=true -Dmaven.javadoc.skip=true test

…nseFormat (spring-projects#326)

Signed-off-by: Kuntal Maity <kuntal.1461@gmail.com>
…nseFormat (spring-projects#326)

Signed-off-by: Kuntal Maity <kuntal.1461@gmail.com>
Copy link
Member

@ericbottard ericbottard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I would typically be in favor of such strongly typed changes, I wonder if this is really desirable.
Do all providers really agree on values? For example, you changed one test value from base64 to b64_json. Was it intentional? Or was it an oversight exactly because a strong type gives you confidence?

Moreover, do all providers really support (and will they always) support all values of the enum?

.width(1920)
.style("sketch")
.responseFormat("base64")
.responseFormat(ImageResponseFormat.B64_JSON)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a change of semantics here

@Override
public String getResponseFormat() {
return this.responseFormat;
return (this.responseFormat != null) ? this.responseFormat.getValue() : null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming we carry through with this change (see my overall comment on the benefits of this PR), could we try to push the null check inside the enum (for example having ImageResponseFormat.NULL a value, and setting all options to that)

@ericbottard ericbottard self-assigned this Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants