Skip to content

Commit 14b8afc

Browse files
fix(api): fix imagegen size enum regression
1 parent 99b9c42 commit 14b8afc

7 files changed

Lines changed: 83 additions & 31 deletions

File tree

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 233
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-feda36af0554900ba4ab2b74d82db104f65cfcddf1eef391c55fec82182414f3.yml
3-
openapi_spec_hash: b2df68d6233a18b475590978f5682c04
4-
config_hash: 632ca30e38686c90bef7622b1a2009ce
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-84d31411083374ec6cdb4a722f8b8b83c1230741157306b1ca7ba1a3cf246672.yml
3+
openapi_spec_hash: 051fce676f959b8207e2317225ec4bdc
4+
config_hash: a2916f18a94ff65c8116ca2fe3256f10

src/openai/resources/images.py

Lines changed: 64 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ def edit(
141141
partial_images: Optional[int] | Omit = omit,
142142
quality: Optional[Literal["standard", "low", "medium", "high", "auto"]] | Omit = omit,
143143
response_format: Optional[Literal["url", "b64_json"]] | Omit = omit,
144-
size: Optional[str] | Omit = omit,
144+
size: Union[str, Literal["256x256", "512x512", "1024x1024", "1536x1024", "1024x1536", "auto"], None]
145+
| Omit = omit,
145146
stream: Optional[Literal[False]] | Omit = omit,
146147
user: str | Omit = omit,
147148
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -271,7 +272,8 @@ def edit(
271272
partial_images: Optional[int] | Omit = omit,
272273
quality: Optional[Literal["standard", "low", "medium", "high", "auto"]] | Omit = omit,
273274
response_format: Optional[Literal["url", "b64_json"]] | Omit = omit,
274-
size: Optional[str] | Omit = omit,
275+
size: Union[str, Literal["256x256", "512x512", "1024x1024", "1536x1024", "1024x1536", "auto"], None]
276+
| Omit = omit,
275277
user: str | Omit = omit,
276278
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
277279
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -400,7 +402,8 @@ def edit(
400402
partial_images: Optional[int] | Omit = omit,
401403
quality: Optional[Literal["standard", "low", "medium", "high", "auto"]] | Omit = omit,
402404
response_format: Optional[Literal["url", "b64_json"]] | Omit = omit,
403-
size: Optional[str] | Omit = omit,
405+
size: Union[str, Literal["256x256", "512x512", "1024x1024", "1536x1024", "1024x1536", "auto"], None]
406+
| Omit = omit,
404407
user: str | Omit = omit,
405408
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
406409
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -528,7 +531,8 @@ def edit(
528531
partial_images: Optional[int] | Omit = omit,
529532
quality: Optional[Literal["standard", "low", "medium", "high", "auto"]] | Omit = omit,
530533
response_format: Optional[Literal["url", "b64_json"]] | Omit = omit,
531-
size: Optional[str] | Omit = omit,
534+
size: Union[str, Literal["256x256", "512x512", "1024x1024", "1536x1024", "1024x1536", "auto"], None]
535+
| Omit = omit,
532536
stream: Optional[Literal[False]] | Literal[True] | Omit = omit,
533537
user: str | Omit = omit,
534538
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -596,7 +600,12 @@ def generate(
596600
partial_images: Optional[int] | Omit = omit,
597601
quality: Optional[Literal["standard", "hd", "low", "medium", "high", "auto"]] | Omit = omit,
598602
response_format: Optional[Literal["url", "b64_json"]] | Omit = omit,
599-
size: Optional[str] | Omit = omit,
603+
size: Union[
604+
str,
605+
Literal["auto", "1024x1024", "1536x1024", "1024x1536", "256x256", "512x512", "1792x1024", "1024x1792"],
606+
None,
607+
]
608+
| Omit = omit,
600609
stream: Optional[Literal[False]] | Omit = omit,
601610
style: Optional[Literal["vivid", "natural"]] | Omit = omit,
602611
user: str | Omit = omit,
@@ -718,7 +727,12 @@ def generate(
718727
partial_images: Optional[int] | Omit = omit,
719728
quality: Optional[Literal["standard", "hd", "low", "medium", "high", "auto"]] | Omit = omit,
720729
response_format: Optional[Literal["url", "b64_json"]] | Omit = omit,
721-
size: Optional[str] | Omit = omit,
730+
size: Union[
731+
str,
732+
Literal["auto", "1024x1024", "1536x1024", "1024x1536", "256x256", "512x512", "1792x1024", "1024x1792"],
733+
None,
734+
]
735+
| Omit = omit,
722736
style: Optional[Literal["vivid", "natural"]] | Omit = omit,
723737
user: str | Omit = omit,
724738
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -839,7 +853,12 @@ def generate(
839853
partial_images: Optional[int] | Omit = omit,
840854
quality: Optional[Literal["standard", "hd", "low", "medium", "high", "auto"]] | Omit = omit,
841855
response_format: Optional[Literal["url", "b64_json"]] | Omit = omit,
842-
size: Optional[str] | Omit = omit,
856+
size: Union[
857+
str,
858+
Literal["auto", "1024x1024", "1536x1024", "1024x1536", "256x256", "512x512", "1792x1024", "1024x1792"],
859+
None,
860+
]
861+
| Omit = omit,
843862
style: Optional[Literal["vivid", "natural"]] | Omit = omit,
844863
user: str | Omit = omit,
845864
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -959,7 +978,12 @@ def generate(
959978
partial_images: Optional[int] | Omit = omit,
960979
quality: Optional[Literal["standard", "hd", "low", "medium", "high", "auto"]] | Omit = omit,
961980
response_format: Optional[Literal["url", "b64_json"]] | Omit = omit,
962-
size: Optional[str] | Omit = omit,
981+
size: Union[
982+
str,
983+
Literal["auto", "1024x1024", "1536x1024", "1024x1536", "256x256", "512x512", "1792x1024", "1024x1792"],
984+
None,
985+
]
986+
| Omit = omit,
963987
stream: Optional[Literal[False]] | Literal[True] | Omit = omit,
964988
style: Optional[Literal["vivid", "natural"]] | Omit = omit,
965989
user: str | Omit = omit,
@@ -1122,7 +1146,8 @@ async def edit(
11221146
partial_images: Optional[int] | Omit = omit,
11231147
quality: Optional[Literal["standard", "low", "medium", "high", "auto"]] | Omit = omit,
11241148
response_format: Optional[Literal["url", "b64_json"]] | Omit = omit,
1125-
size: Optional[str] | Omit = omit,
1149+
size: Union[str, Literal["256x256", "512x512", "1024x1024", "1536x1024", "1024x1536", "auto"], None]
1150+
| Omit = omit,
11261151
stream: Optional[Literal[False]] | Omit = omit,
11271152
user: str | Omit = omit,
11281153
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -1252,7 +1277,8 @@ async def edit(
12521277
partial_images: Optional[int] | Omit = omit,
12531278
quality: Optional[Literal["standard", "low", "medium", "high", "auto"]] | Omit = omit,
12541279
response_format: Optional[Literal["url", "b64_json"]] | Omit = omit,
1255-
size: Optional[str] | Omit = omit,
1280+
size: Union[str, Literal["256x256", "512x512", "1024x1024", "1536x1024", "1024x1536", "auto"], None]
1281+
| Omit = omit,
12561282
user: str | Omit = omit,
12571283
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
12581284
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -1381,7 +1407,8 @@ async def edit(
13811407
partial_images: Optional[int] | Omit = omit,
13821408
quality: Optional[Literal["standard", "low", "medium", "high", "auto"]] | Omit = omit,
13831409
response_format: Optional[Literal["url", "b64_json"]] | Omit = omit,
1384-
size: Optional[str] | Omit = omit,
1410+
size: Union[str, Literal["256x256", "512x512", "1024x1024", "1536x1024", "1024x1536", "auto"], None]
1411+
| Omit = omit,
13851412
user: str | Omit = omit,
13861413
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
13871414
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -1509,7 +1536,8 @@ async def edit(
15091536
partial_images: Optional[int] | Omit = omit,
15101537
quality: Optional[Literal["standard", "low", "medium", "high", "auto"]] | Omit = omit,
15111538
response_format: Optional[Literal["url", "b64_json"]] | Omit = omit,
1512-
size: Optional[str] | Omit = omit,
1539+
size: Union[str, Literal["256x256", "512x512", "1024x1024", "1536x1024", "1024x1536", "auto"], None]
1540+
| Omit = omit,
15131541
stream: Optional[Literal[False]] | Literal[True] | Omit = omit,
15141542
user: str | Omit = omit,
15151543
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -1577,7 +1605,12 @@ async def generate(
15771605
partial_images: Optional[int] | Omit = omit,
15781606
quality: Optional[Literal["standard", "hd", "low", "medium", "high", "auto"]] | Omit = omit,
15791607
response_format: Optional[Literal["url", "b64_json"]] | Omit = omit,
1580-
size: Optional[str] | Omit = omit,
1608+
size: Union[
1609+
str,
1610+
Literal["auto", "1024x1024", "1536x1024", "1024x1536", "256x256", "512x512", "1792x1024", "1024x1792"],
1611+
None,
1612+
]
1613+
| Omit = omit,
15811614
stream: Optional[Literal[False]] | Omit = omit,
15821615
style: Optional[Literal["vivid", "natural"]] | Omit = omit,
15831616
user: str | Omit = omit,
@@ -1699,7 +1732,12 @@ async def generate(
16991732
partial_images: Optional[int] | Omit = omit,
17001733
quality: Optional[Literal["standard", "hd", "low", "medium", "high", "auto"]] | Omit = omit,
17011734
response_format: Optional[Literal["url", "b64_json"]] | Omit = omit,
1702-
size: Optional[str] | Omit = omit,
1735+
size: Union[
1736+
str,
1737+
Literal["auto", "1024x1024", "1536x1024", "1024x1536", "256x256", "512x512", "1792x1024", "1024x1792"],
1738+
None,
1739+
]
1740+
| Omit = omit,
17031741
style: Optional[Literal["vivid", "natural"]] | Omit = omit,
17041742
user: str | Omit = omit,
17051743
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -1820,7 +1858,12 @@ async def generate(
18201858
partial_images: Optional[int] | Omit = omit,
18211859
quality: Optional[Literal["standard", "hd", "low", "medium", "high", "auto"]] | Omit = omit,
18221860
response_format: Optional[Literal["url", "b64_json"]] | Omit = omit,
1823-
size: Optional[str] | Omit = omit,
1861+
size: Union[
1862+
str,
1863+
Literal["auto", "1024x1024", "1536x1024", "1024x1536", "256x256", "512x512", "1792x1024", "1024x1792"],
1864+
None,
1865+
]
1866+
| Omit = omit,
18241867
style: Optional[Literal["vivid", "natural"]] | Omit = omit,
18251868
user: str | Omit = omit,
18261869
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -1940,7 +1983,12 @@ async def generate(
19401983
partial_images: Optional[int] | Omit = omit,
19411984
quality: Optional[Literal["standard", "hd", "low", "medium", "high", "auto"]] | Omit = omit,
19421985
response_format: Optional[Literal["url", "b64_json"]] | Omit = omit,
1943-
size: Optional[str] | Omit = omit,
1986+
size: Union[
1987+
str,
1988+
Literal["auto", "1024x1024", "1536x1024", "1024x1536", "256x256", "512x512", "1792x1024", "1024x1792"],
1989+
None,
1990+
]
1991+
| Omit = omit,
19441992
stream: Optional[Literal[False]] | Literal[True] | Omit = omit,
19451993
style: Optional[Literal["vivid", "natural"]] | Omit = omit,
19461994
user: str | Omit = omit,

src/openai/types/image_edit_params.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class ImageEditParamsBase(TypedDict, total=False):
114114
base64-encoded images.
115115
"""
116116

117-
size: Optional[str]
117+
size: Union[str, Literal["256x256", "512x512", "1024x1024", "1536x1024", "1024x1536", "auto"], None]
118118
"""The size of the generated images.
119119
120120
For `gpt-image-2` and `gpt-image-2-2026-04-21`, arbitrary resolutions are

src/openai/types/image_generate_params.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ class ImageGenerateParamsBase(TypedDict, total=False):
100100
models, which always return base64-encoded images.
101101
"""
102102

103-
size: Optional[str]
103+
size: Union[
104+
str,
105+
Literal["auto", "1024x1024", "1536x1024", "1024x1536", "256x256", "512x512", "1792x1024", "1024x1792"],
106+
None,
107+
]
104108
"""The size of the generated images.
105109
106110
For `gpt-image-2` and `gpt-image-2-2026-04-21`, arbitrary resolutions are

src/openai/types/responses/tool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ class ImageGeneration(BaseModel):
315315
One of `low`, `medium`, `high`, or `auto`. Default: `auto`.
316316
"""
317317

318-
size: Optional[str] = None
318+
size: Union[str, Literal["1024x1024", "1024x1536", "1536x1024", "auto"], None] = None
319319
"""The size of the generated images.
320320
321321
For `gpt-image-2` and `gpt-image-2-2026-04-21`, arbitrary resolutions are

src/openai/types/responses/tool_param.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ class ImageGeneration(TypedDict, total=False):
314314
One of `low`, `medium`, `high`, or `auto`. Default: `auto`.
315315
"""
316316

317-
size: str
317+
size: Union[str, Literal["1024x1024", "1024x1536", "1536x1024", "auto"]]
318318
"""The size of the generated images.
319319
320320
For `gpt-image-2` and `gpt-image-2-2026-04-21`, arbitrary resolutions are

tests/api_resources/test_images.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def test_method_edit_with_all_params_overload_1(self, client: OpenAI) -> None:
8383
partial_images=1,
8484
quality="high",
8585
response_format="url",
86-
size="1024x1024",
86+
size="256x256",
8787
stream=False,
8888
user="user-1234",
8989
)
@@ -140,7 +140,7 @@ def test_method_edit_with_all_params_overload_2(self, client: OpenAI) -> None:
140140
partial_images=1,
141141
quality="high",
142142
response_format="url",
143-
size="1024x1024",
143+
size="256x256",
144144
user="user-1234",
145145
)
146146
image_stream.response.close()
@@ -192,7 +192,7 @@ def test_method_generate_with_all_params_overload_1(self, client: OpenAI) -> Non
192192
partial_images=1,
193193
quality="medium",
194194
response_format="url",
195-
size="1024x1024",
195+
size="auto",
196196
stream=False,
197197
style="vivid",
198198
user="user-1234",
@@ -245,7 +245,7 @@ def test_method_generate_with_all_params_overload_2(self, client: OpenAI) -> Non
245245
partial_images=1,
246246
quality="medium",
247247
response_format="url",
248-
size="1024x1024",
248+
size="auto",
249249
style="vivid",
250250
user="user-1234",
251251
)
@@ -348,7 +348,7 @@ async def test_method_edit_with_all_params_overload_1(self, async_client: AsyncO
348348
partial_images=1,
349349
quality="high",
350350
response_format="url",
351-
size="1024x1024",
351+
size="256x256",
352352
stream=False,
353353
user="user-1234",
354354
)
@@ -405,7 +405,7 @@ async def test_method_edit_with_all_params_overload_2(self, async_client: AsyncO
405405
partial_images=1,
406406
quality="high",
407407
response_format="url",
408-
size="1024x1024",
408+
size="256x256",
409409
user="user-1234",
410410
)
411411
await image_stream.response.aclose()
@@ -457,7 +457,7 @@ async def test_method_generate_with_all_params_overload_1(self, async_client: As
457457
partial_images=1,
458458
quality="medium",
459459
response_format="url",
460-
size="1024x1024",
460+
size="auto",
461461
stream=False,
462462
style="vivid",
463463
user="user-1234",
@@ -510,7 +510,7 @@ async def test_method_generate_with_all_params_overload_2(self, async_client: As
510510
partial_images=1,
511511
quality="medium",
512512
response_format="url",
513-
size="1024x1024",
513+
size="auto",
514514
style="vivid",
515515
user="user-1234",
516516
)

0 commit comments

Comments
 (0)