cli/resources/images/methods/edit/index.md +0 −239 deleted
File Deleted View Diff
1## Create image edit
2
3`$ openai images edit`
4
5**post** `/images/edits`
6
7Creates 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`.
8
9### Parameters
10
11- `--image: string or array of string`
12
13 The image(s) to edit. Must be a supported image file or an array of images.
14
15 For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`,
16 `gpt-image-1.5`, `gpt-image-2`, `gpt-image-2-2026-04-21`, and
17 `chatgpt-image-latest`), each image should be a `png`, `webp`, or
18 `jpg` file less than 50MB. You can provide up to 16 images.
19
20 For `dall-e-2`, you can only provide one image, and it should be a
21 square `png` file less than 4MB.
22
23- `--prompt: string`
24
25 A text description of the desired image(s). The maximum length is 1000 characters for `dall-e-2`, and 32000 characters for the GPT image models.
26
27- `--background: optional "transparent" or "opaque" or "auto"`
28
29 Allows to set transparency for the background of the generated image(s).
30 This parameter is only supported for GPT image models that support
31 transparent backgrounds. Must be one of `transparent`, `opaque`, or
32 `auto` (default value). When `auto` is used, the model will
33 automatically determine the best background for the image.
34
35 `gpt-image-2` and `gpt-image-2-2026-04-21` do not support
36 transparent backgrounds. Requests with `background` set to
37 `transparent` will return an error for these models; use `opaque` or
38 `auto` instead.
39
40 If `transparent`, the output format needs to support transparency,
41 so it should be set to either `png` (default value) or `webp`.
42
43- `--input-fidelity: optional "high" or "low"`
44
45 Control how much effort the model will exert to match the style and features, especially facial features, of input images. This parameter is only supported for `gpt-image-1` and `gpt-image-1.5` and later models, unsupported for `gpt-image-1-mini`. Supports `high` and `low`. Defaults to `low`.
46
47- `--mask: optional string`
48
49 An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where `image` should be edited. If there are multiple images provided, the mask will be applied on the first image. Must be a valid PNG file, less than 4MB, and have the same dimensions as `image`.
50
51- `--model: optional string or ImageModel`
52
53 The model to use for image generation. One of `dall-e-2` or a GPT image model (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`, `gpt-image-2-2026-04-21`, or `chatgpt-image-latest`). Defaults to `gpt-image-1.5`.
54
55- `--n: optional number`
56
57 The number of images to generate. Must be between 1 and 10.
58
59- `--output-compression: optional number`
60
61 The compression level (0-100%) for the generated images. This parameter
62 is only supported for the GPT image models with the `webp` or `jpeg` output
63 formats, and defaults to 100.
64
65- `--output-format: optional "png" or "jpeg" or "webp"`
66
67 The format in which the generated images are returned. This parameter is
68 only supported for the GPT image models. Must be one of `png`, `jpeg`, or `webp`.
69 The default value is `png`.
70
71- `--partial-images: optional number`
72
73 The number of partial images to generate. This parameter is used for
74 streaming responses that return partial images. Value must be between 0 and 3.
75 When set to 0, the response will be a single image sent in one streaming event.
76
77 Note that the final image may be sent before the full number of partial images
78 are generated if the full image is generated more quickly.
79
80- `--quality: optional "standard" or "low" or "medium" or 2 more`
81
82 The quality of the image that will be generated for GPT image models. Defaults to `auto`.
83
84- `--response-format: optional "url" or "b64_json"`
85
86 The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated. This parameter is only supported for `dall-e-2` (default is `url` for `dall-e-2`), as GPT image models always return base64-encoded images.
87
88- `--size: optional string or "256x256" or "512x512" or "1024x1024" or 3 more`
89
90 The size of the generated images. For `gpt-image-2` and `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as `WIDTHxHEIGHT` strings, for example `1536x864`. Width and height must both be divisible by 16 and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above `2560x1440` are experimental, and the maximum supported resolution is `3840x2160`. The requested size must also satisfy the model's current pixel and edge limits. The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are supported by the GPT image models; `auto` is supported for models that allow automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or `1024x1792`.
91
92- `--user: optional string`
93
94 A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
95
96### Returns
97
98- `images_response: object { created, background, data, 4 more }`
99
100 The response from the image generation endpoint.
101
102 - `created: number`
103
104 The Unix timestamp (in seconds) of when the image was created.
105
106 - `background: optional "transparent" or "opaque"`
107
108 The background parameter used for the image generation. Either `transparent` or `opaque`.
109
110 - `"transparent"`
111
112 - `"opaque"`
113
114 - `data: optional array of Image`
115
116 The list of generated images.
117
118 - `b64_json: optional string`
119
120 The base64-encoded JSON of the generated image. Returned by default for the GPT image models, and only present if `response_format` is set to `b64_json` for `dall-e-2` and `dall-e-3`.
121
122 - `revised_prompt: optional string`
123
124 For `dall-e-3` only, the revised prompt that was used to generate the image.
125
126 - `url: optional string`
127
128 When using `dall-e-2` or `dall-e-3`, the URL of the generated image if `response_format` is set to `url` (default value). Unsupported for the GPT image models.
129
130 - `output_format: optional "png" or "webp" or "jpeg"`
131
132 The output format of the image generation. Either `png`, `webp`, or `jpeg`.
133
134 - `"png"`
135
136 - `"webp"`
137
138 - `"jpeg"`
139
140 - `quality: optional "low" or "medium" or "high"`
141
142 The quality of the image generated. Either `low`, `medium`, or `high`.
143
144 - `"low"`
145
146 - `"medium"`
147
148 - `"high"`
149
150 - `size: optional "1024x1024" or "1024x1536" or "1536x1024"`
151
152 The size of the image generated. Either `1024x1024`, `1024x1536`, or `1536x1024`.
153
154 - `"1024x1024"`
155
156 - `"1024x1536"`
157
158 - `"1536x1024"`
159
160 - `usage: optional object { input_tokens, input_tokens_details, output_tokens, 2 more }`
161
162 For `gpt-image-1` only, the token usage information for the image generation.
163
164 - `input_tokens: number`
165
166 The number of tokens (images and text) in the input prompt.
167
168 - `input_tokens_details: object { image_tokens, text_tokens }`
169
170 The input tokens detailed information for the image generation.
171
172 - `image_tokens: number`
173
174 The number of image tokens in the input prompt.
175
176 - `text_tokens: number`
177
178 The number of text tokens in the input prompt.
179
180 - `output_tokens: number`
181
182 The number of output tokens generated by the model.
183
184 - `total_tokens: number`
185
186 The total number of tokens (images and text) used for the image generation.
187
188 - `output_tokens_details: optional object { image_tokens, text_tokens }`
189
190 The output token details for the image generation.
191
192 - `image_tokens: number`
193
194 The number of image output tokens generated by the model.
195
196 - `text_tokens: number`
197
198 The number of text output tokens generated by the model.
199
200### Example
201
202```cli
203openai images edit \
204 --api-key 'My API Key' \
205 --image 'Example data' \
206 --prompt 'A cute baby sea otter wearing a beret'
207```
208
209#### Response
210
211```json
212{
213 "created": 0,
214 "background": "transparent",
215 "data": [
216 {
217 "b64_json": "b64_json",
218 "revised_prompt": "revised_prompt",
219 "url": "https://example.com"
220 }
221 ],
222 "output_format": "png",
223 "quality": "low",
224 "size": "1024x1024",
225 "usage": {
226 "input_tokens": 0,
227 "input_tokens_details": {
228 "image_tokens": 0,
229 "text_tokens": 0
230 },
231 "output_tokens": 0,
232 "total_tokens": 0,
233 "output_tokens_details": {
234 "image_tokens": 0,
235 "text_tokens": 0
236 }
237 }
238}
239```