Skip to content

Conversation

@apappascs
Copy link
Contributor

@apappascs apappascs commented Oct 9, 2025

Add support for OpenAI's new GPT-Image models (gpt-image-1 and gpt-image-1-mini) with streaming image generation capabilities and all new model-specific parameters according to the official API specification.

Changes:

Core Interface & API Layer:

  • Add StreamingImageModel interface to spring-ai-model for progressive image generation
  • Implement streamImage() method in OpenAiImageApi using WebClient for SSE support
  • Add OpenAiImageStreamEvent record to handle streaming events (partial_image and completed)
  • Add dynamic API key resolution pattern to fix test failures
  • Add GPT_IMAGE_1 and GPT_IMAGE_1_MINI to ImageModel enum
  • Update OpenAiImageApi constructor to accept WebClient.Builder for streaming support

Model Layer:

  • Implement StreamingImageModel interface in OpenAiImageModel
  • Add stream() method with automatic stream parameter setting
  • Add validation to restrict streaming to GPT-Image models only
  • Add comprehensive error handling for non-streaming models

Parameters & Options:

  • Add 6 new gpt-image-1 specific parameters to OpenAiImageRequest and OpenAiImageOptions:
    • background: transparency control (transparent/opaque/auto)
    • moderation: content moderation level (low/auto)
    • outputCompression: compression level 0-100% for webp/jpeg
    • outputFormat: output format (png/jpeg/webp)
    • partialImages: streaming partial images support (0-3, documented limit)
    • stream: enable streaming mode
  • Add size() builder method to OpenAiImageOptions.Builder
  • Update OpenAiImageOptions with new fields, getters/setters, and builder methods

Testing:

  • Add OpenAiImageApiStreamingIT with 4 comprehensive streaming tests
  • Add OpenAiImageModelStreamingIT with 6 end-to-end streaming tests
  • Update OpenAiImageApiIT with tests for all models and new parameters
  • Add parameterized tests for all ImageModel enum values
  • Fix partialImages parameter values to respect ≤3 limit
  • Update observation tests to use GPT_IMAGE_1_MINI

Auto-configuration & CI:

  • Update OpenAiImageAutoConfiguration to inject WebClient.Builder
  • Update .github/workflows/pr-check.yml to build spring-ai-model first
  • Add separate test jobs for API and Model integration tests
  • Add reactor-test dependency to pom.xml for streaming tests

Documentation:

  • Add StreamingImageModel interface documentation to imageclient.adoc
  • Document streaming support and limitations in openai-image.adoc
  • Add comprehensive streaming examples with partial images
  • Document all new parameters with model-specific constraints
  • Clarify that DALL-E models do not support streaming

Reference: https://platform.openai.com/docs/models
https://platform.openai.com/docs/api-reference/images-streaming
https://platform.openai.com/docs/guides/image-generation?image-generation-model=gpt-image-1&api=image

@apappascs apappascs changed the title feat: add OpenAI gpt-image-1 and gpt-image-1-mini models with new par… feat: add OpenAI image models with new parameters Oct 9, 2025
@apappascs apappascs changed the title feat: add OpenAI image models with new parameters feat: add streaming support and new GPT-Image models for OpenAI Oct 14, 2025
@apappascs apappascs force-pushed the feat/openai-image-models branch 2 times, most recently from cfae97b to c5b45fb Compare October 20, 2025 17:00
…ameters Add support for OpenAI's new GPT Image models (gpt-image-1 and gpt-image-1-mini) with all new model-specific parameters according to the official API specification. Changes: - Add GPT_IMAGE_1 and GPT_IMAGE_1_MINI to ImageModel enum - Update default image model from DALL_E_3 to GPT_IMAGE_1_MINI - Add 6 new gpt-image-1 specific parameters to OpenAiImageRequest: * background: transparency control (transparent/opaque/auto) * moderation: content moderation level (low/auto) * outputCompression: compression level 0-100% for webp/jpeg * outputFormat: output format (png/jpeg/webp) * partialImages: streaming partial images support (0-3) * stream: enable streaming mode - Update OpenAiImageOptions with new fields, getters/setters, and builder methods - Update documentation to reflect model-specific parameter support - Add comprehensive integration tests (OpenAiImageApiIT) with parameterized tests - Update existing tests to use new default model Breaking Changes: - OpenAiImageRequest constructor signature updated with 6 new parameters Reference: https://platform.openai.com/docs/models Signed-off-by: Alexandros Pappas <apappascs@gmail.com>
@apappascs apappascs marked this pull request as ready for review October 20, 2025 17:01
*/
@AutoConfiguration(after = { RestClientAutoConfiguration.class, WebClientAutoConfiguration.class,
SpringAiRetryAutoConfiguration.class })
@ConditionalOnClass(OpenAiApi.class)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ilayaperumalg it seems this one was not updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2 participants