Skip to content

Python: Accept gpt-image-1 landscape and portrait sizes in OpenAITextToImageExecutionSettings - #14798

Open
Abhishek Acharya (abhishekacharya200) wants to merge 1 commit into
microsoft:mainfrom
abhishekacharya200:fix-gpt-image-sizes
Open

Abhishek Acharya (abhishekacharya200) wants to merge 1 commit into
microsoft:mainfrom
abhishekacharya200:fix-gpt-image-sizes

Conversation

@abhishekacharya200

Copy link
Copy Markdown

Motivation and Context

The OpenAI text-to-image connector now targets gpt-image-1 (quality is limited to high/medium/low and style was removed), but the size check still only allows the DALL-E sizes. Passing 1536x1024 or 1024x1536, both supported by gpt-image-1, fails before any request is sent:

OpenAITextToImageExecutionSettings(size=ImageSize(width=1536, height=1024))
# ServiceInvalidExecutionSettingsError: Invalid image size: 1536x1024.

Description

Add (1536, 1024) and (1024, 1536) to VALID_IMAGE_SIZES. The existing sizes are kept so DALL-E deployments are unaffected.

Added a unit test that calls generate_images with both sizes against a mocked images.generate and checks the size sent in the request. It fails without the change.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the SK Contribution Guidelines and the pre-submission formatting script raises no violations
  • All unit tests pass, and I have added new tests where possible
  • I didn't break anyone 😄

Copilot AI balanced review requested due to automatic review settings November 16, 2026 04:04
@semantic-kernel-automation semantic-kernel-automation Bot added the python Pull requests for the Python Semantic Kernel label Nov 16, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues were identified for the change adding landscape and portrait image sizes to the Python OpenAI text-to-image connector.

No open issues 🎉

What changed in this PR

Updates the Python OpenAI text-to-image connector to accept gpt-image-1 landscape and portrait sizes while retaining the existing DALL-E sizes.

Changes:

  • Adds 1536x1024 and 1024x1536 to the allowed image sizes.
  • Adds a parameterized unit test verifying both sizes are accepted and forwarded to the mocked image-generation API.
File Description
python/​tests/​unit/​connectors/​ai/​open_ai/​services/​test_openai_text_to_image.py Tests generation requests for both gpt-image-1 sizes.
python/​semantic_kernel/​connectors/​ai/​open_ai/​prompt_execution_settings/​open_ai_text_to_image_execution_settings.py Extends the valid image-size list without removing existing sizes.

Review effort: Balanced

This branch was successfully deployed

1 active deployment
github-app-auth — 3743c494 Deployed Nov 16, 2026 by abhishekacharya200 via add_label #29699
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Pull requests for the Python Semantic Kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants