-
-
Notifications
You must be signed in to change notification settings - Fork 234
Description
The dart_openai SDK has inconsistent handling of image sizes for image.edit (/v1/images/edits):
Bug 1 — SDK rejects a valid size before sending request
When using:
size: OpenAIImageSize.fromValue("1024x1536"),
The SDK throws a local validation error:
Invalid argument(s): Invalid value for OpenAIImageSize: 1024x1536
However, the server does accept "1024x1536" for /v1/images/edits.
So the SDK incorrectly prevents valid requests.
Bug 2 — SDK exposes unsupported values
The SDK exposes:
OpenAIImageSize.size1792Vertical // "1024x1792"
But the server rejects it:
Invalid value: '1024x1792'.
Supported values are: '1024x1024', '1024x1536', '1536x1024', and 'auto'.
Meaning the SDK suggests a size the API does not support.
Code Sample
final response = await OpenAI.instance.image.edit(
model: "gpt-image-1",
image: imageFile,
prompt: "Test",
size: OpenAIImageSize.fromValue("1024x1536"), // or size1792Vertical
);
Observed Errors
(1) SDK-side validation error
Invalid argument(s): Invalid value for OpenAIImageSize: 1024x1536
(2) Server-side rejection
400 - Invalid value: '1024x1792'.
Supported values are: '1024x1024', '1024x1536', '1536x1024', and 'auto'.
Expected behavior
OpenAIImageSize.fromValue("1024x1536") should work because the API accepts it.
SDK should not expose sizes that the API itself rejects.
SDK should ideally validate based on endpoint rules, or allow raw values without blocking.
Actual behavior
Valid size "1024x1536" is blocked by client-side validation.
Invalid size "1024x1792" is allowed by the SDK but rejected by the server.
Developers must bypass the SDK with a manual multipart request to use valid portrait sizes.
Suggested Fixes
Allow "1024x1536" and "1536x1024" in fromValue().
Remove or mark size1792Vertical & size1792Horizontal as generation-only or unsupported for edits.
Improve size validation so it matches the server capabilities per endpoint.
Document supported sizes for each image endpoint.
Environment
dart_openai version: 6.1.1
Flutter/Dart version: 3.32.2
Endpoint: /v1/images/edits
Model: gpt-image-1