Skip to content

feat: add gpt-image-1-mini model for OpenAI image generation#70

Merged
Kamilbenkirane merged 3 commits into
mainfrom
models/gpt-image-1-mini
Dec 11, 2025
Merged

feat: add gpt-image-1-mini model for OpenAI image generation#70
Kamilbenkirane merged 3 commits into
mainfrom
models/gpt-image-1-mini

Conversation

@Kamilbenkirane

Copy link
Copy Markdown
Member

Summary

Adds the new GPT Image 1 Mini model (gpt-image-1-mini) to the OpenAI image generation provider.

Changes

  • Added gpt-image-1-mini model with appropriate parameter constraints:
    • Streaming: Supported
    • Partial Images: 0-3
    • Aspect Ratio: 1024x1024, 1024x1536, 1536x1024, auto
    • Quality: low, medium, high, auto

Model Details

  • Model ID: gpt-image-1-mini
  • Display Name: GPT Image 1 Mini
  • Provider: OpenAI
  • Status: Cost-efficient version of GPT-Image-1

Validation

  • Model validated in playground
  • Parameter constraints verified against OpenAI API documentation

@claude

claude Bot commented Dec 11, 2025

Copy link
Copy Markdown

Code Review: Add gpt-image-1-mini Model

Thank you for this contribution! Overall, the PR follows the existing patterns well. Here's my detailed review:

Code Quality & Best Practices

Positives:

  • Code follows the established pattern for model definitions in this codebase
  • Proper use of type hints and data structures (Model, Choice, Range)
  • Consistent formatting and style with existing models
  • Clear and descriptive display name

Observations:

  • The model definition is nearly identical to gpt-image-1 (lines 30-43). While this appears intentional for a "mini" variant, consider if these models should share any configuration to reduce duplication in the future.

⚠️ Potential Issues

1. Streaming Support Validation (CRITICAL)

The model is marked with streaming=True, but the streaming implementation in client.py:117-119 has a hardcoded check:

if self.model.id != "gpt-image-1":
    msg = f"Streaming not supported for model '{self.model.id}'. Only 'gpt-image-1' supports streaming."
    raise ValueError(msg)

Issue: If gpt-image-1-mini supports streaming, this check needs to be updated to:

if self.model.id not in ("gpt-image-1", "gpt-image-1-mini"):

Recommendation: Please verify with OpenAI's documentation whether gpt-image-1-mini actually supports streaming. If it does, update the validation logic in packages/image-generation/src/celeste_image_generation/providers/openai/client.py:117-119.

2. Aspect Ratio Ordering Inconsistency

  • gpt-image-1: ["1024x1024", "1536x1024", "1024x1536", "auto"]
  • gpt-image-1-mini: ["1024x1024", "1024x1536", "1536x1024", "auto"]

The order of aspect ratios differs between the two models (notice 1024x1536 and 1536x1024 are swapped). Unless this reflects actual API differences, consider using consistent ordering for maintainability.

🧪 Test Coverage

Missing:

  • No unit tests added for the new model
  • No integration tests for gpt-image-1-mini

Recommendations:

  1. Add integration test in packages/image-generation/tests/integration_tests/test_image_generation/test_generate.py:
    (Provider.OPENAI, "gpt-image-1-mini", {"aspect_ratio": "1024x1024"}),
  2. If streaming is supported, add streaming tests
  3. Consider adding tests to verify parameter constraints are properly enforced

🔒 Security Concerns

No security issues identified. The changes are purely declarative configuration.

Performance Considerations

No performance concerns. As a "mini" model, this is likely intended to be more cost-efficient than gpt-image-1, which is appropriate for the use case.

📋 Action Items

Before merging:

  1. Verify streaming support - Confirm with OpenAI docs whether gpt-image-1-mini supports streaming
  2. Update streaming validation - If streaming is supported, update the check in client.py:117-119
  3. Fix aspect ratio ordering - Align with gpt-image-1 unless API differs
  4. Add tests - At minimum, add the model to integration tests

Nice to have:

  • Add a comment or documentation explaining the differences between gpt-image-1 and gpt-image-1-mini
  • Consider extracting shared configuration if more GPT Image variants are expected

📝 Summary

The code quality is good and follows existing patterns. The main concern is the streaming validation hardcoded to only allow gpt-image-1, which will cause runtime errors if users try to stream with gpt-image-1-mini. Please verify the streaming capability and update the validation accordingly.

Great work overall! 🎉

…eration

The base Client.stream() method already validates self.model.streaming before calling _make_stream_request, making the hardcoded model ID check redundant. This allows any model with streaming=True to use streaming functionality.
@claude

claude Bot commented Dec 11, 2025

Copy link
Copy Markdown

PR Review: Add GPT Image 1 Mini Model

Summary

This PR adds support for the new gpt-image-1-mini model to the OpenAI image generation provider and removes a redundant streaming validation check. Overall, the implementation is solid and well-structured. The changes are minimal, focused, and follow existing patterns in the codebase.


✅ Strengths

  1. Excellent Code Consistency: The new model definition follows the exact same pattern as the existing gpt-image-1 model, making it easy to understand and maintain.

  2. Smart Refactoring: Removing the hardcoded model ID check in client.py:114-117 is a good improvement. The base Client.stream() method already validates self.model.streaming at line 91-92 in src/celeste/client.py, making this check redundant.

  3. Clear Documentation: The PR description and commit messages are well-written and explain the changes clearly.

  4. Minimal Surface Area: The changes touch only the necessary files, reducing risk.


🔍 Code Quality Observations

Model Definition (models.py:44-58)

The new model is correctly configured with:

  • ✅ Appropriate streaming support
  • ✅ Correct parameter constraints matching gpt-image-1
  • ✅ Proper display name

Aspect Ratio Constraint

I notice the gpt-image-1-mini has slightly different aspect ratios than gpt-image-1:

  • gpt-image-1: ["1024x1024", "1536x1024", "1024x1536", "auto"]
  • gpt-image-1-mini: ["1024x1024", "1024x1536", "1536x1024", "auto"]

The order is different (1024x1536 and 1536x1024 are swapped). This is likely intentional but worth confirming:

  • Question: Is this order difference intentional or should it match gpt-image-1 for consistency?

🧪 Test Coverage

Concern: No tests were added or modified for the new model.

Recommendations:

  1. Add the new model to the integration test in packages/image-generation/tests/integration_tests/test_image_generation/test_generate.py:

    (Provider.OPENAI, "gpt-image-1-mini", {"aspect_ratio": "1024x1024"}),
  2. If streaming is a key feature, consider adding a streaming test (though this may already be covered by existing tests).

While the existing test suite will likely catch major issues, explicitly testing the new model would:

  • Validate the model works correctly with the API
  • Prevent regressions
  • Document expected behavior

🔒 Security Considerations

✅ No security concerns identified. The changes:

  • Don't introduce new input validation requirements
  • Don't modify authentication/authorization logic
  • Don't change error handling behavior
  • Leverage existing validation through parameter constraints

⚡ Performance Considerations

✅ No performance concerns. The changes:

  • Don't add new loops or complex operations
  • Don't change request/response handling
  • The removed validation actually marginally improves performance by eliminating a redundant check

🐛 Potential Issues

Minor Documentation Inconsistency (parameters.py:77):
The docstring was updated from:

"""Map quality parameter for DALL-E 3 and gpt-image-1."""

to:

"""Map quality parameter"""

While the method docstring (lines 87-93) still lists all models, the class docstring is now less informative. Consider:

"""Map quality parameter for DALL-E 3, gpt-image-1, and gpt-image-1-mini."""

📋 Recommendations

Must Have:

  • Verify the aspect ratio order for gpt-image-1-mini against OpenAI's API documentation

Should Have:

  • Add integration test for the new model
  • Update QualityMapper class docstring to list all supported models

Nice to Have:

  • If this is a cost-efficient model (as mentioned in the PR description), consider documenting this in a comment or the model's metadata

✨ Final Verdict

Approved with minor suggestions. The code is production-ready, but adding tests would significantly improve confidence in the implementation. The refactoring of the streaming validation is a welcome improvement.

Great work maintaining consistency with existing patterns! 🚀

@Kamilbenkirane Kamilbenkirane merged commit 863befd into main Dec 11, 2025
11 checks passed
@claude

claude Bot commented Dec 11, 2025

Copy link
Copy Markdown

PR Review: Add gpt-image-1-mini Model

✅ Summary

This PR successfully adds the gpt-image-1-mini model to the OpenAI image generation provider. The implementation follows existing patterns well and improves code maintainability by removing an overly restrictive streaming check.


🎯 Code Quality & Best Practices

Strengths:

  • ✅ Consistent with existing model definitions (follows the same pattern as gpt-image-1)
  • ✅ Properly uses type-safe parameter constraints with Range and Choice
  • ✅ Good use of the unified API design pattern
  • ✅ Clean removal of hardcoded model check in client.py:114-117 - this is a positive change that makes the code more maintainable

Observations:

  1. Aspect Ratio Order Inconsistency (models.py:52)

    • gpt-image-1: ["1024x1024", "1536x1024", "1024x1536", "auto"]
    • gpt-image-1-mini: ["1024x1024", "1024x1536", "1536x1024", "auto"]

    The order differs between the two models. While functionally this doesn't matter (both are valid Choice options), consistency would be better for maintainability. Consider matching the order used in gpt-image-1.

  2. Documentation Updates (parameters.py:77, 89-92)

    • The docstring updates correctly reflect that streaming is no longer limited to one model
    • Good job removing outdated "gpt-image-1 only" comments
    • The quality mapper documentation is comprehensive and clear

🐛 Potential Bugs or Issues

None identified. The code changes are safe:

  • The removal of the streaming model check is actually an improvement - it was overly restrictive and would have required maintenance for each new streaming-capable model
  • The model now properly declares streaming=True, which the system will respect
  • Parameter constraints are properly defined and will be validated by the framework

⚡ Performance Considerations

No concerns. The changes are purely declarative (model metadata) and don't introduce any performance overhead.


🔒 Security Concerns

None identified. The changes:

  • Don't introduce any new attack vectors
  • Properly validate parameters through the constraint system
  • Don't modify authentication or authorization logic

🧪 Test Coverage

Observation: No tests were added for the new model. Consider:

  1. Integration Test Addition - The file packages/image-generation/tests/integration_tests/test_image_generation/test_generate.py has a parametrized test that includes other OpenAI models:

    @pytest.mark.parametrize(
        ("provider", "model", "parameters"),
        [
            (Provider.OPENAI, "dall-e-2", {}),
            # Consider adding:
            # (Provider.OPENAI, "gpt-image-1-mini", {"aspect_ratio": "1024x1024"}),
        ],
    )
  2. Streaming Test - Since this model supports streaming (streaming=True), consider adding a streaming test if one doesn't already exist for OpenAI image generation models.

However, given that:

  • The PR description mentions "Model validated in playground"
  • The implementation exactly mirrors gpt-image-1
  • The framework will enforce parameter constraints automatically

The lack of automated tests is acceptable for this change, though adding them would increase confidence in future refactoring.


📝 Recommendations

Minor improvements (optional):

  1. Consider standardizing aspect ratio order in models.py:52 to match line 37:

    options=["1024x1024", "1536x1024", "1024x1536", "auto"]
  2. Consider adding the model to integration tests for better coverage

Otherwise, this PR is well-structured and ready to merge! The code follows existing patterns, improves maintainability by removing the hardcoded streaming check, and properly implements the new model with appropriate constraints.


🎉 Overall Assessment

Approve with minor suggestions. This is a clean, straightforward addition that improves the codebase. The removal of the streaming model check is actually a positive refactor that makes the code more maintainable for future model additions.

Great work! 🚀

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.

1 participant