@@ -119,12 +119,14 @@ def edit(
119
119
* ,
120
120
image : Union [FileTypes , List [FileTypes ]],
121
121
prompt : str ,
122
+ background : Optional [Literal ["transparent" , "opaque" , "auto" ]] | NotGiven = NOT_GIVEN ,
122
123
mask : FileTypes | NotGiven = NOT_GIVEN ,
123
124
model : Union [str , ImageModel , None ] | NotGiven = NOT_GIVEN ,
124
125
n : Optional [int ] | NotGiven = NOT_GIVEN ,
125
126
quality : Optional [Literal ["standard" , "low" , "medium" , "high" , "auto" ]] | NotGiven = NOT_GIVEN ,
126
127
response_format : Optional [Literal ["url" , "b64_json" ]] | NotGiven = NOT_GIVEN ,
127
- size : Optional [Literal ["256x256" , "512x512" , "1024x1024" ]] | NotGiven = NOT_GIVEN ,
128
+ size : Optional [Literal ["256x256" , "512x512" , "1024x1024" , "1536x1024" , "1024x1536" , "auto" ]]
129
+ | NotGiven = NOT_GIVEN ,
128
130
user : str | NotGiven = NOT_GIVEN ,
129
131
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
130
132
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -139,14 +141,25 @@ def edit(
139
141
This endpoint only supports `gpt-image-1` and `dall-e-2`.
140
142
141
143
Args:
142
- image: The image(s) to edit. Must be a supported image file or an array of images. For
143
- `gpt-image-1`, each image should be a `png`, `webp`, or `jpg` file less than
144
- 25MB. For `dall-e-2`, you can only provide one image, and it should be a square
145
- `png` file less than 4MB.
144
+ image: The image(s) to edit. Must be a supported image file or an array of images.
145
+
146
+ For `gpt-image-1`, each image should be a `png`, `webp`, or `jpg` file less than
147
+ 25MB. You can provide up to 16 images.
148
+
149
+ For `dall-e-2`, you can only provide one image, and it should be a square `png`
150
+ file less than 4MB.
146
151
147
152
prompt: A text description of the desired image(s). The maximum length is 1000
148
153
characters for `dall-e-2`, and 32000 characters for `gpt-image-1`.
149
154
155
+ background: Allows to set transparency for the background of the generated image(s). This
156
+ parameter is only supported for `gpt-image-1`. Must be one of `transparent`,
157
+ `opaque` or `auto` (default value). When `auto` is used, the model will
158
+ automatically determine the best background for the image.
159
+
160
+ If `transparent`, the output format needs to support transparency, so it should
161
+ be set to either `png` (default value) or `webp`.
162
+
150
163
mask: An additional image whose fully transparent areas (e.g. where alpha is zero)
151
164
indicate where `image` should be edited. If there are multiple images provided,
152
165
the mask will be applied on the first image. Must be a valid PNG file, less than
@@ -187,6 +200,7 @@ def edit(
187
200
{
188
201
"image" : image ,
189
202
"prompt" : prompt ,
203
+ "background" : background ,
190
204
"mask" : mask ,
191
205
"model" : model ,
192
206
"n" : n ,
@@ -429,12 +443,14 @@ async def edit(
429
443
* ,
430
444
image : Union [FileTypes , List [FileTypes ]],
431
445
prompt : str ,
446
+ background : Optional [Literal ["transparent" , "opaque" , "auto" ]] | NotGiven = NOT_GIVEN ,
432
447
mask : FileTypes | NotGiven = NOT_GIVEN ,
433
448
model : Union [str , ImageModel , None ] | NotGiven = NOT_GIVEN ,
434
449
n : Optional [int ] | NotGiven = NOT_GIVEN ,
435
450
quality : Optional [Literal ["standard" , "low" , "medium" , "high" , "auto" ]] | NotGiven = NOT_GIVEN ,
436
451
response_format : Optional [Literal ["url" , "b64_json" ]] | NotGiven = NOT_GIVEN ,
437
- size : Optional [Literal ["256x256" , "512x512" , "1024x1024" ]] | NotGiven = NOT_GIVEN ,
452
+ size : Optional [Literal ["256x256" , "512x512" , "1024x1024" , "1536x1024" , "1024x1536" , "auto" ]]
453
+ | NotGiven = NOT_GIVEN ,
438
454
user : str | NotGiven = NOT_GIVEN ,
439
455
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
440
456
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -449,14 +465,25 @@ async def edit(
449
465
This endpoint only supports `gpt-image-1` and `dall-e-2`.
450
466
451
467
Args:
452
- image: The image(s) to edit. Must be a supported image file or an array of images. For
453
- `gpt-image-1`, each image should be a `png`, `webp`, or `jpg` file less than
454
- 25MB. For `dall-e-2`, you can only provide one image, and it should be a square
455
- `png` file less than 4MB.
468
+ image: The image(s) to edit. Must be a supported image file or an array of images.
469
+
470
+ For `gpt-image-1`, each image should be a `png`, `webp`, or `jpg` file less than
471
+ 25MB. You can provide up to 16 images.
472
+
473
+ For `dall-e-2`, you can only provide one image, and it should be a square `png`
474
+ file less than 4MB.
456
475
457
476
prompt: A text description of the desired image(s). The maximum length is 1000
458
477
characters for `dall-e-2`, and 32000 characters for `gpt-image-1`.
459
478
479
+ background: Allows to set transparency for the background of the generated image(s). This
480
+ parameter is only supported for `gpt-image-1`. Must be one of `transparent`,
481
+ `opaque` or `auto` (default value). When `auto` is used, the model will
482
+ automatically determine the best background for the image.
483
+
484
+ If `transparent`, the output format needs to support transparency, so it should
485
+ be set to either `png` (default value) or `webp`.
486
+
460
487
mask: An additional image whose fully transparent areas (e.g. where alpha is zero)
461
488
indicate where `image` should be edited. If there are multiple images provided,
462
489
the mask will be applied on the first image. Must be a valid PNG file, less than
@@ -497,6 +524,7 @@ async def edit(
497
524
{
498
525
"image" : image ,
499
526
"prompt" : prompt ,
527
+ "background" : background ,
500
528
"mask" : mask ,
501
529
"model" : model ,
502
530
"n" : n ,
0 commit comments