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-datafile uploads,gpt-image-2also 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
imagefield 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
sizeparameter, 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. Supportsn > 1(returns multiple images at once) and true 2K / 4K, charged per image, with a unit price twice that of the defaultgpt-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 defaultgpt-image-2(reverse route), with unchanged pricing.
The restrictions mentioned below regarding thenparameter only apply to the default / reverse routes;gpt-image-2:officialsupportsn > 1and 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 is1024x1024, whensizeis passed as2048x2048, the model will redraw according to the editing instructions and output a 2K image; whensizeis passed as3840x2160, it will output a 4K landscape image; passingautoor omitting it will allow the model to choose. The billing for all three is the same.
About theBelow are two different real examples to experience the editing capabilities ofnParameter Thegpt-image-2editing interface currently does not supportn > 1: this parameter will be silently ignored, whethern=1orn=10is 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 togpt-image-1/gpt-image-1.5, as well as thenano-banana/nano-banana-2-lite/nano-banana-2/nano-banana-proseries.dall-e-2is currently the only model that natively supportsn > 1for editing.
gpt-image-2.
Calling Method One: JSON + Image URL (Recommended)
Directly send a request inapplication/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:


Tip: Theimagefield 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: Theimage(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 withgpt-image-2):

task_id: e9544dba-727e-44a2-81e1-223d49869380):

Calling Method Three: multipart/form-data (Compatible with OpenAI SDK)
If you are already using the official OpenAI Python SDK, the existingmultipart/form-data upload method is also applicable, just change the model to gpt-image-2:
OPENAI_BASE_URL to https://api.acedata.cloud/openai, and OPENAI_API_KEY to the token you obtained:
Nano Banana Series Models
Thenano-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.
imagecan be uploaded as a file viamultipart/form-data(the worker will convert it todata:<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), butcreatedis fixed at0, andb64_jsonwill not be returned;revised_promptwill always equal the originalprompt.
Calling via Form + Image URL

Calling via Form + Local File
Asynchronous Callback
Thecallback_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: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:

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:
gift-basket.png will be generated in the current directory, and the specific result is as follows:

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 additionalcallback_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:
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.

