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,
)
| 127 | |
| 128 | @overload |
| 129 | def edit( |
| 130 | self, |
| 131 | *, |
| 132 | image: Union[FileTypes, SequenceNotStr[FileTypes]], |
| 133 | prompt: str, |
| 134 | background: Optional[Literal[class="st">"transparent", class="st">"opaque", class="st">"auto"]] | Omit = omit, |
| 135 | input_fidelity: Optional[Literal[class="st">"high", class="st">"low"]] | Omit = omit, |
| 136 | mask: FileTypes | Omit = omit, |
| 137 | model: Union[str, ImageModel, None] | Omit = omit, |
| 138 | n: Optional[int] | Omit = omit, |
| 139 | output_compression: Optional[int] | Omit = omit, |
| 140 | output_format: Optional[Literal[class="st">"png", class="st">"jpeg", class="st">"webp"]] | Omit = omit, |
| 141 | partial_images: Optional[int] | Omit = omit, |
| 142 | quality: Optional[Literal[class="st">"standard", class="st">"low", class="st">"medium", class="st">"high", class="st">"auto"]] | Omit = omit, |
| 143 | response_format: Optional[Literal[class="st">"url", class="st">"b64_json"]] | Omit = omit, |
| 144 | size: Union[str, Literal[class="st">"256x256", class="st">"512x512", class="st">"1024x1024", class="st">"1536x1024", class="st">"1024x1536", class="st">"auto"], None] |
| 145 | | Omit = omit, |
| 146 | stream: Optional[Literal[False]] | Omit = omit, |
| 147 | user: str | Omit = omit, |
| 148 | class="cm"># Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 149 | class="cm"># The extra values given here take precedence over values defined on the client or passed to this method. |
| 150 | extra_headers: Headers | None = None, |
| 151 | extra_query: Query | None = None, |
| 152 | extra_body: Body | None = None, |
| 153 | timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 154 | ) -> ImagesResponse: |
| 155 | class="st">"""Creates an edited or extended image given one or more source images and a |
| 156 | prompt. |
| 157 | |
| 158 | This endpoint supports GPT Image models (`gpt-image-1.5`, `gpt-image-1`, |
| 159 | `gpt-image-1-mini`, and `chatgpt-image-latest`) and `dall-e-2`. |
| 160 | |
| 161 | Args: |
| 162 | image: The image(s) to edit. Must be a supported image file or an array of images. |
| 163 | |
| 164 | For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, |
| 165 | `gpt-image-2`, `gpt-image-2-2026-04-21`, and `chatgpt-image-latest`), each image |
| 166 | should be a `png`, `webp`, or `jpg` file less than 50MB. You can provide up to |
| 167 | 16 images. |
| 168 | |
| 169 | For `dall-e-2`, you can only provide one image, and it should be a square `png` |
| 170 | file less than 4MB. |
| 171 | |
| 172 | prompt: A text description of the desired image(s). The maximum length is 1000 |
| 173 | characters for `dall-e-2`, and 32000 characters for the GPT image models. |
| 174 | |
| 175 | background: Allows to set transparency for the background of the generated image(s). This |
| 176 | parameter is only supported for GPT image models that support transparent |
| 177 | backgrounds. Must be one of `transparent`, `opaque`, or `auto` (default value). |
| 178 | When `auto` is used, the model will automatically determine the best background |
| 179 | for the image. |
| 180 | |
| 181 | `gpt-image-2` and `gpt-image-2-2026-04-21` do not support transparent |
| 182 | backgrounds. Requests with `background` set to `transparent` will return an |
| 183 | error for these models; use `opaque` or `auto` instead. |
| 184 | |
| 185 | If `transparent`, the output format needs to support transparency, so it should |
| 186 | be set to either `png` (default value) or `webp`. |
nothing calls this directly
no test coverage detected