Creates an edited or extended image given one or more source images and a prompt. This endpoint supports GPT Image models (`gpt-image-1.5`, `gpt-image-1`, `gpt-image-1-mini`, and `chatgpt-image-latest`) and `dall-e-2`. Args: image: The image(s) to edit. Mu
(
self,
*,
image: Union[FileTypes, SequenceNotStr[FileTypes]],
prompt: str,
background: Optional[Literal["transparent", "opaque", "auto"]] | Omit = omit,
input_fidelity: Optional[Literal["high", "low"]] | Omit = omit,
mask: FileTypes | Omit = omit,
model: Union[str, ImageModel, None] | Omit = omit,
n: Optional[int] | Omit = omit,
output_compression: Optional[int] | Omit = omit,
output_format: Optional[Literal["png", "jpeg", "webp"]] | Omit = omit,
partial_images: Optional[int] | Omit = omit,
quality: Optional[Literal["standard", "low", "medium", "high", "auto"]] | Omit = omit,
response_format: Optional[Literal["url", "b64_json"]] | Omit = omit,
size: Union[str, Literal["256x256", "512x512", "1024x1024", "1536x1024", "1024x1536", "auto"], None]
| Omit = omit,
stream: Optional[Literal[False]] | Omit = omit,
user: str | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
)
| 1132 | |
| 1133 | @overload |
| 1134 | async def edit( |
| 1135 | self, |
| 1136 | *, |
| 1137 | image: Union[FileTypes, SequenceNotStr[FileTypes]], |
| 1138 | prompt: str, |
| 1139 | background: Optional[Literal["transparent", "opaque", "auto"]] | Omit = omit, |
| 1140 | input_fidelity: Optional[Literal["high", "low"]] | Omit = omit, |
| 1141 | mask: FileTypes | Omit = omit, |
| 1142 | model: Union[str, ImageModel, None] | Omit = omit, |
| 1143 | n: Optional[int] | Omit = omit, |
| 1144 | output_compression: Optional[int] | Omit = omit, |
| 1145 | output_format: Optional[Literal["png", "jpeg", "webp"]] | Omit = omit, |
| 1146 | partial_images: Optional[int] | Omit = omit, |
| 1147 | quality: Optional[Literal["standard", "low", "medium", "high", "auto"]] | Omit = omit, |
| 1148 | response_format: Optional[Literal["url", "b64_json"]] | Omit = omit, |
| 1149 | size: Union[str, Literal["256x256", "512x512", "1024x1024", "1536x1024", "1024x1536", "auto"], None] |
| 1150 | | Omit = omit, |
| 1151 | stream: Optional[Literal[False]] | Omit = omit, |
| 1152 | user: str | Omit = omit, |
| 1153 | # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 1154 | # The extra values given here take precedence over values defined on the client or passed to this method. |
| 1155 | extra_headers: Headers | None = None, |
| 1156 | extra_query: Query | None = None, |
| 1157 | extra_body: Body | None = None, |
| 1158 | timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 1159 | ) -> ImagesResponse: |
| 1160 | """Creates an edited or extended image given one or more source images and a |
| 1161 | prompt. |
| 1162 | |
| 1163 | This endpoint supports GPT Image models (`gpt-image-1.5`, `gpt-image-1`, |
| 1164 | `gpt-image-1-mini`, and `chatgpt-image-latest`) and `dall-e-2`. |
| 1165 | |
| 1166 | Args: |
| 1167 | image: The image(s) to edit. Must be a supported image file or an array of images. |
| 1168 | |
| 1169 | For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, |
| 1170 | `gpt-image-2`, `gpt-image-2-2026-04-21`, and `chatgpt-image-latest`), each image |
| 1171 | should be a `png`, `webp`, or `jpg` file less than 50MB. You can provide up to |
| 1172 | 16 images. |
| 1173 | |
| 1174 | For `dall-e-2`, you can only provide one image, and it should be a square `png` |
| 1175 | file less than 4MB. |
| 1176 | |
| 1177 | prompt: A text description of the desired image(s). The maximum length is 1000 |
| 1178 | characters for `dall-e-2`, and 32000 characters for the GPT image models. |
| 1179 | |
| 1180 | background: Allows to set transparency for the background of the generated image(s). This |
| 1181 | parameter is only supported for GPT image models that support transparent |
| 1182 | backgrounds. Must be one of `transparent`, `opaque`, or `auto` (default value). |
| 1183 | When `auto` is used, the model will automatically determine the best background |
| 1184 | for the image. |
| 1185 | |
| 1186 | `gpt-image-2` and `gpt-image-2-2026-04-21` do not support transparent |
| 1187 | backgrounds. Requests with `background` set to `transparent` will return an |
| 1188 | error for these models; use `opaque` or `auto` instead. |
| 1189 | |
| 1190 | If `transparent`, the output format needs to support transparency, so it should |
| 1191 | be set to either `png` (default value) or `webp`. |
nothing calls this directly
no test coverage detected