Application Process
To use the OpenAI Images Edits API, you can first visit the OpenAI Images Edits API page and click the “Acquire” button to obtain the credentials needed for the request:
If you are not logged in or registered, you will be automatically redirected to the login page inviting you to register and log in. After logging in or registering, you will be automatically returned to the current page.
Upon the first application, there will be a free quota provided, allowing you to use the API for free.
Basic Usage
Next, you can use code to make calls; below is an example using CURL:authorization, which can be selected directly from the dropdown list. The other parameter is model, which is the category of the OpenAI official model 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 another variable for the credential 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, with the specific result as follows:

dall-e-2 and gpt-image-1.
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 POST JSON format, 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 convenience, we use a public Webhook sample site https://webhook.site/; opening this site will give you a Webhook URL, as shown in the image:
Copy this URL, and it can be used as a Webhook; the sample here is https://webhook.site/3d32690d-6780-4187-a65c-870061e8c8ab.
Next, we can set the callback_url field to the above Webhook URL and fill 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 the task to be associated 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.

