Skip to main content
The OpenAI Images Generations API currently supports various image generation models, including the classic dall-e-3, the text rendering enhanced gpt-image-1, the latest generation gpt-image-2, as well as the nano-banana / nano-banana-2 / nano-banana-pro series models accessed through the same interface. All of them can generate high-quality images based on textual descriptions. This document mainly introduces the usage process of the OpenAI Images Generations API, which allows easy access to the OpenAI series image generation capabilities.

Application Process

To use OpenAI Images Generations API, first open the Ace Data Cloud Console and copy your API Token. If you are not logged in, you will be redirected to sign in and brought back to this page automatically. A single API Token works across every service on the platform — no need to subscribe per service. New accounts receive free starter credit; when it runs low you can top up your shared balance in the console.
📘 Full documentation: OpenAI Images Generations API →

GPT-Image-2 Model

gpt-image-2 is the new generation image generation model launched by OpenAI. Compared with dall-e-3 and gpt-image-1, it has significant improvements in the following aspects:
  • Stronger instruction adherence: Able to accurately understand complex composition, counting, positional relationships, and other structured instructions.
  • Clearer text rendering: English and numbers in scenes like posters, menus, infographics, and logos are almost never garbled.
  • Richer style expression: Natively supports various styles such as cinematic portraits, vintage posters, children’s illustrations, product photography, infographics, etc.
  • Native multi-aspect ratio + high-resolution support: Covers 5 aspect ratios (1:1, 4:3, 3:4, 16:9, 9:16) with 3 resolution tiers (1K / 2K / 4K).
The calling method is exactly the same as other models, just set the model field to gpt-image-2. The returned url in the result is a permanently hosted image link on platform.cdn.acedata.cloud, which can be directly opened in a browser or embedded in a webpage.

Supported size Values

gpt-image-2 only validates the format of size. As long as it is not auto or an empty string, it must match the WIDTHxHEIGHT format (e.g., 1024x1024, 2048x1152, 800x600); any other format will return 400. All sizes (1K / 2K / 4K / custom) are charged uniformly per image, with no extra charge for size. Upstream hard constraints for custom sizes: width and height must be multiples of 16, the longer side ≤ 3840, total pixels ≤ 8,294,400. Exceeding these limits will be rejected upstream and return 4xx.
You can also pass size: "auto" or omit the size field, in which case the model will choose the default size automatically. For the 1K tier, upstream output does not guarantee strict pixel alignment — if you pass 1024x1024, you might get 1254x1254, but the aspect ratio is maintained. If you reuse this as size, the billing remains unchanged. 4K single calls usually take 4–8 minutes; it is recommended to use the callback_url asynchronous callback mechanism described later.
About the n parameter gpt-image-2 currently does not support n > 1: this parameter will be silently ignored. Whether you pass n=1 or n=10, only one image will be returned per request and charged as one image. If you need multiple candidate images at once, please make multiple concurrent requests (it is recommended to pass different prompt or different seed values; otherwise, the images may be very similar). This limitation also applies to gpt-image-1 / gpt-image-1.5, and the nano-banana / nano-banana-2 / nano-banana-pro series. dall-e-2 is currently the only model that natively supports n > 1; dall-e-3 only supports n = 1.
Below are several real examples from different perspectives to intuitively experience the capabilities of gpt-image-2.

Scenario 1: Cinematic Portrait

You can use cinematic terms in the prompt (35mm film, shallow depth of field, neon lights, etc.) to precisely control the atmosphere and texture. Python sample code:
Returned result:
Generated image:

Scenario 2: Vintage Travel Poster (with Text Rendering)

gpt-image-2 performs stably in typography and font rendering, making it very suitable for generating posters, menus, greeting cards, and other text-inclusive designs.
The url field in the returned result corresponds to the following image:

The model accurately reproduces the Art Deco poster visual style, and the title texts AMALFI and ITALIA 1958 are rendered clearly and correctly.

Scenario 3: Complex Composition and Counting

The following prompt tests the model’s adherence to structured instructions such as “quantity” and “position”.
Generated image:

The number of books on the three shelves (1 / 3 / 7) matches the prompt exactly, which was difficult to achieve stably in the dall-e-3 era.

Scenario 4: Illustration Style (Landscape)

By specifying artistic media and mood keywords, the model can be guided to produce stylized illustrations.
Generated landscape illustration:

Asynchronous and Callback

gpt-image-2 single calls usually take 60–90 seconds. If you do not want to keep a long connection, you can use the callback_url asynchronous callback mechanism described later. The calling process is the same as other models.

Nano Banana Series Models

The nano-banana series are image generation models based on Gemini, integrated through the same /openai/images/generations interface without switching endpoints. Just change the model to any of the following:
Important: Supported Parameters Nano Banana is integrated via an adaptation layer to the OpenAI protocol and supports only the following parameters compared to gpt-image-*: model, prompt, size.
  • size will be mapped to internal aspect_ratio as per the table below; unlisted sizes default to 1:1:
    • 1024x1024 / 512x512 / 256x2561:1
    • 1792x102416:9
    • 1024x17929:16
  • Does not support n, quality, style, response_format, background, output_format, etc.; these will be ignored if provided.
  • Return structure follows OpenAI format (data[].url), but created is fixed at 0, no b64_json is returned, and revised_prompt always equals the original prompt.

Basic Call

Returned result:
The generated image can be accessed directly via the returned url:

Upgrade to Flagship Model nano-banana-pro

Simply change model to nano-banana-pro, other parameters remain the same:
Example return:

Asynchronous Callback

The callback_url asynchronous callback mechanism also applies to nano-banana. The calling process is the same as other models; see the Asynchronous Callback section below.

Basic Usage

Next, you can fill in the corresponding content on the interface as shown:

When using this interface for the first time, at least three fields need to be filled: one is authorization, which can be selected directly from the dropdown list; another is model, which is the OpenAI DALL-E official model category you want to use (mainly one model here, details can be found in the provided models); the last is prompt, which is the text prompt for image generation. You can also notice that the corresponding call code is generated on the right side. You can copy the code to run directly or click the “Try” button to test.

Python sample call code:
After calling, the returned result is as follows:
Returned results include multiple fields:
  • created: the ID for this image generation, uniquely identifying the task.
  • data: contains the image generation result information.
The data contains detailed information about the generated image, where the url is the link to the generated image, as shown below.

Image Quality Parameter quality

Next, we introduce how to set detailed parameters for image generation results. The image quality parameter quality has two options: the first is standard, which generates standard images; the other is hd, which creates images with finer details and greater consistency. Below is the setting for quality as standard:

You can also notice the corresponding call code generated on the right side, which you can copy to run or click “Try” to test.

Python sample call code:
Returned result:
The returned result is consistent with basic usage. The image generated with quality set to standard is shown below:

Performing the same operation but setting quality to hd yields the following image:

You can see that hd produces images with finer details and greater consistency than standard.

Image Size Parameter size

You can also set the size of the generated image. Below is the setting for image size as 1024x1024:

You can also notice the corresponding call code generated on the right side, which you can copy to run or click “Try” to test.

Python sample call code:
Returned result:
The returned result is consistent with basic usage. The generated image with size 1024x1024 is shown below:

Performing the same operation but setting the size to 1792x1024 yields the following image: You can see the size difference clearly. More sizes can be set; please refer to our official documentation for details.

Image Style Parameter style

The image style parameter style has two options: vivid means the generated image is more vivid, and natural means the generated image is more natural. Below is the setting for style as vivid:

You can also notice the corresponding call code generated on the right side, which you can copy to run or click “Try” to test.

Python sample call code:
Returned result:
The returned result is consistent with basic usage. The image generated with style set to vivid is shown below:

Performing the same operation but setting style to natural yields the following image:

You can see that vivid produces more vivid and lifelike images than natural. The last parameter is the image link format response_format, which has two options: b64_json encodes the image link in Base64, and url is a normal image link that can be viewed directly. Below is the setting for response_format as url:

You can also notice the corresponding call code generated on the right side, which you can copy to run or click “Try” to test.

Python sample call code:
Returned result:
The returned result is consistent with basic usage. The image link with response_format set to url is Image URL, which can be accessed directly. The image is shown below:

Performing the same operation but setting response_format to b64_json returns the Base64 encoded image link, as shown below:

Asynchronous Callback

Because the OpenAI Images Generations API may take relatively long to generate images, if the API does not respond for a long time, the HTTP request will keep the connection open, causing additional system resource consumption. Therefore, this API also supports asynchronous callbacks. The overall process is: when the client initiates a request, it additionally specifies a callback_url field. After the client sends the API request, the API immediately returns a result containing a task_id field representing the current task ID. When the task is completed, the generated image result will be sent to the client’s specified callback_url via POST JSON, including the task_id field, so the task result can be associated by ID. Below is an example to understand the specific operation. First, the webhook callback is a service that can receive HTTP requests. Developers should replace it with their own HTTP server URL. For demonstration, a public webhook sample site https://webhook.site/ is used. Open the site to get a webhook URL, as shown: Copy this URL and use it as the webhook. The example URL is https://webhook.site/3d32690d-6780-4187-a65c-870061e8c8ab. Next, set the callback_url field to the above webhook URL and fill in the corresponding parameters, as in the following code:
Run it, and you will immediately get a result like this:
After a short wait, you can observe the generated image result at the webhook URL, content as follows:
You can see the result contains a task_id field, and the data field contains the same image generation results as synchronous calls. The task_id field allows task association.

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 DALL-E image generation features via the OpenAI Images Generations API. We hope this document helps you better integrate and use this API. If you have any questions, please feel free to contact our technical support team.