Skip to main content
OpenAI image editing service allows you to input any number of images and instructions, outputting modified images. Currently, the interface supports dall-e-2, gpt-image-1, the latest gpt-image-2, as well as the nano-banana / nano-banana-2-lite / nano-banana-2 / nano-banana-pro series models through the same interface. This document mainly introduces the usage process of the OpenAI Images Edits API, allowing us to easily utilize the official OpenAI image editing features.

Application Process

To use the OpenAI Images Edits API, first go to the Ace Data Cloud Console to obtain your API Token for backup. If you are not logged in or registered, you will be automatically redirected to the login page inviting you to register and log in, and after completion, you will be automatically returned to the current page. One API Token can call all services on the platform without needing to apply separately for each service. The first application will grant a free quota for a trial experience; when the quota is insufficient, you can recharge the general balance in the console.
📘 Complete documentation: OpenAI Images Edits API →

GPT-Image-2 Model

gpt-image-2 has significant improvements in image editing scenarios compared to gpt-image-1:
  • Structure remains more stable: Changing skin, color, or background almost does not damage the original layout and composition.
  • Text retention is more accurate: Images containing text such as infographics, posters, and menus remain clear and readable after editing.
  • Supports direct URL input: In addition to traditional multipart/form-data file uploads, gpt-image-2 also supports passing image URLs in JSON format, eliminating the need to download images locally first, making it very suitable for server-side pipeline integration.
  • Supports base64 direct input: Consistent with the official, the image field can also directly accept base64 (data:image/png;base64,... or raw base64), allowing local images to be edited without first uploading to an image hosting service.
  • Supports high-resolution redrawing: You can input a 1K original image and request 2K / 4K output through the size parameter, with the model completing the enlargement during the editing process.

Official Relay / Reverse Variant (:official / :reverse)

gpt-image-2 defaults to the reverse route. You can explicitly select the route by appending the model name suffix:
  • gpt-image-2:official: Official relay route. Supports n > 1 (returns multiple images at once) and true 2K / 4K, charged per image, with a unit price twice that of the default gpt-image-2. Currently only provided by the openai-hk channel; if the route is unavailable, it will return an error directly and will not downgrade to the reverse route.
  • gpt-image-2:reverse: Completely equivalent to the default gpt-image-2 (reverse route), with unchanged pricing.
The restrictions mentioned below regarding the n parameter only apply to the default / reverse routes; gpt-image-2:official supports n > 1 and charges per image.

Supported size Values

The constraints on size for the editing interface are completely consistent with the generation interface—gpt-image-2 only requires size to be auto, empty, or in the WIDTHxHEIGHT format; any other form will return 400. All sizes (1K / 2K / 4K / custom) are charged uniformly per image, regardless of the original image resolution and the size request value. Upstream constraints on custom sizes also apply: both width and height must be multiples of 16, long side ≤ 3840, total pixel count ≤ 8,294,400.
For example: if the original image is 1024x1024, when size is passed as 2048x2048, the model will redraw according to the editing instructions and output a 2K image; when size is passed as 3840x2160, it will output a 4K landscape image; passing auto or omitting it will allow the model to choose. The billing for all three is the same.
About the n Parameter The gpt-image-2 editing interface currently does not support n > 1: this parameter will be silently ignored, whether n=1 or n=10 is passed, a single request will only return 1 image and will only be charged for 1 image. If you need to obtain multiple candidate editing results at once, please initiate multiple requests concurrently. This limitation also applies to gpt-image-1 / gpt-image-1.5, as well as the nano-banana / nano-banana-2-lite / nano-banana-2 / nano-banana-pro series. dall-e-2 is currently the only model that natively supports n > 1 for editing.
Below are two different real examples to experience the editing capabilities of gpt-image-2. Directly send a request in application/json format, filling the image field with the URL of an image, and the model will fetch that image and edit it according to the prompt. For example, the original image below is a science popularization illustration generated using gpt-image-2:

We hope to change it to a “night mode” color scheme. It can be called like this:
Or use Python:
The response is as follows:
The edited image is as follows:

It can be seen that the module structure, information partition, and font layout have been strictly preserved, with only the color scheme inverted to a dark theme.
Tip: The image field also supports passing an array, for example, "image": ["url1", "url2", "url3"], allowing up to 16 reference images to be passed simultaneously for the model to reference multiple images for editing.
Base64 direct transmission: The image (and each item in the array) can also be base64 — data:image/png;base64,... or raw base64 is acceptable, suitable for local images that you do not want to upload to an image hosting service first. For example:

Calling Method Two: JSON + Multiple Reference Images

gpt-image-2 supports referencing multiple images simultaneously to generate the final result, for example, combining multiple product photos into a single gift basket:

Scenario Example: Change Style + Maintain Structure

Here is another example, replacing a wooden bookshelf with a modern floating shelf while strictly preserving the number and arrangement of books on each shelf. Original image (wooden bookshelf generated with gpt-image-2):

Call:
Editing result (task_id: e9544dba-727e-44a2-81e1-223d49869380):

It can be seen that the style and environment have been completely replaced according to the prompt, but the number of books on each shelf (1 / 3 / 7) has still been strictly preserved, and a potted succulent has been added as requested.

Calling Method Three: multipart/form-data (Compatible with OpenAI SDK)

If you are already using the official OpenAI Python SDK, the existing multipart/form-data upload method is also applicable, just change the model to gpt-image-2:
When using the SDK, you need to import two environment variables first, set OPENAI_BASE_URL to https://api.acedata.cloud/openai, and OPENAI_API_KEY to the token you obtained:

Nano Banana Series Models

The nano-banana series also connects to /openai/images/edits in editing scenarios, just change the model to any of those listed in the table below.
Important: Supported Parameter Range Nano Banana connects to the OpenAI protocol through an adaptation layer, supporting only the following parameters: model, prompt, image.
  • image can be uploaded as a file via multipart/form-data (the worker will convert it to data:<mime>;base64,... for upstream), or it can be passed directly as an image URL string through a form field.
  • Parameters such as mask, n, size, response_format, etc., are not supported; if filled, they will be ignored.
  • The return structure follows the OpenAI format (data[].url), but created is fixed at 0, and b64_json will not be returned; revised_prompt will always equal the original prompt.

Calling via Form + Image URL

The return result is as follows:
Edited image:

Calling via Form + Local File

Asynchronous Callback

The callback_url asynchronous callback mechanism is also effective for nano-banana, and the calling process is completely consistent with other models. For details, see the section Asynchronous Callback.

Basic Usage

Next, you can use code to make calls. Below is a call using CURL:
When using this interface for the first time, we need to fill in at least four pieces of information: one is authorization, which can be selected directly from the dropdown list. The other parameter is model, which is the category of OpenAI models we choose to use; here we mainly have one model, details can be found in the models we provide. Another parameter is prompt, which is the input prompt for generating the image. The last parameter is image, which requires the path of the image to be edited, as shown in the image below:

The equivalent Python sample call code:
To use Python for the call, we need to import two environment variables: one is OPENAI_BASE_URL, which can be set to https://api.acedata.cloud/openai, and the other is the credential variable OPENAI_API_KEY, which is the value obtained from authorization. On Mac OS, you can set the environment variables with the following commands:
After the call, we find that an image gift-basket.png will be generated in the current directory, and the specific result is as follows:

Thus, we have completed the image editing operation. Currently, the Edits interface supports three models: dall-e-2, gpt-image-1, and gpt-image-2, among which gpt-image-2 is the currently recommended model. For details, see the section GPT-Image-2 Model.

Asynchronous Callback

Since the OpenAI Images Edits API may take a relatively long time to edit images, if the API does not respond for a long time, the HTTP request will keep the connection open, leading to additional system resource consumption. Therefore, this API also provides support for asynchronous callbacks. The overall process is: when the client initiates a request, an additional callback_url field is specified. After the client initiates the API request, the API will immediately return a result containing a task_id field, representing the current task ID. When the task is completed, the result of the edited image will be sent to the client-specified callback_url in the form of a POST JSON, which also includes the task_id field, allowing the task result to be associated by ID. Let’s understand how to operate specifically through an example. First, the Webhook callback is a service that can receive HTTP requests, and developers should replace it with the URL of their own HTTP server. For demonstration purposes, we use a public Webhook sample site https://webhook.site/, where you can open the site to get a Webhook URL, as shown in the image: Copy this URL, and it can be used as a Webhook. The example here is https://webhook.site/3d32690d-6780-4187-a65c-870061e8c8ab. Next, we can set the field callback_url to the above Webhook URL, while filling in the corresponding parameters, as shown in the following code:
After the call, you will immediately receive a result, as follows:
After a moment, we can observe the result of the image editing at the Webhook URL, as follows:
You can see that the result contains a task_id field, and the data field includes the same image editing result as the synchronous call, allowing task association through the task_id field.

Error Handling

When calling the API, if an error occurs, the API will return the corresponding error code and message. For example:
  • 400 token_mismatched: Bad request, possibly due to missing or invalid parameters.
  • 400 api_not_implemented: Bad request, possibly due to missing or invalid parameters.
  • 401 invalid_token: Unauthorized, invalid or missing authorization token.
  • 429 too_many_requests: Too many requests, you have exceeded the rate limit.
  • 500 api_error: Internal server error, something went wrong on the server.

Error Response Example

Conclusion

Through this document, you have learned how to easily use the official OpenAI image editing features with the OpenAI Images Edits API. We hope this document helps you better integrate and use the API. If you have any questions, please feel free to contact our technical support team.