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 accessible through the same interface. All of these can generate high-quality images based on textual descriptions.
This document mainly introduces the usage process of the OpenAI Images Generations API, enabling easy access to the OpenAI series image generation features.
Application Process
To use the OpenAI Images Generations API, first visit the OpenAI Images Generations API page and click the “Acquire” button to obtain the credentials required for requests:
If you are not logged in or registered, you will be automatically redirected to the login page to register and log in. After logging in or registering, you will be automatically returned to the current page.
A free quota is granted upon the first application, allowing free use of this API.
GPT-Image-2 Model
gpt-image-2 is a new generation image generation model launched by OpenAI. Compared to dall-e-3 and gpt-image-1, it has significant improvements in the following aspects:
- Stronger instruction adherence: Accurately understands complex composition, counting, positional relationships, and other structured instructions.
- Clearer text rendering: English and numbers in posters, menus, infographics, logos, etc., are almost free of errors.
- Richer style expression: Natively supports various styles such as cinematic portraits, vintage posters, children’s illustrations, product photography, and infographics.
- 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).
model field to gpt-image-2. The returned url in the result is a permanently hosted image link on platform.cdn.xhuoapi.ai, which can be opened directly in a browser or embedded in a webpage.
Supported size Values and Billing Tiers
gpt-image-2 only validates the format of size. As long as it is not auto or an empty string, it must match WIDTHxHEIGHT (e.g., 1024x1024, 2048x1152, 800x600); any other format will return 400. Billing is divided into two tiers:
- 1K Standard Price: Input matches any 1K recommended size in the table below or common 1K output aliases from upstream (
1254x1254,1672x941,941x1672— these are actual sizes returned upstream under the 1K tier; reusing them assizewill not cause price jumps). - Other Tiers (1.5×): Any size not in the above 1K set, including the recommended 2K / 4K presets in the table below and any custom
WIDTHxHEIGHTyou provide.
| Aspect Ratio | 1K (Standard Price) | 2K Recommended (×1.5) | 4K Recommended (×1.5) |
|---|---|---|---|
| 1:1 | 1024x1024 | 2048x2048 | 2880x2880 |
| 4:3 | 1536x1024 | 2048x1536 | 3264x2448 |
| 3:4 | 1024x1536 | 1536x2048 | 2448x3264 |
| 16:9 | 1792x1024 | 2048x1152 | 3840x2160 |
| 9:16 | 1024x1792 | 1152x2048 | 2160x3840 |
You can also passsize: "auto"or omit thesizefield, in which case the model will select the default size itself and charge at the 1K standard price. Upstream output under the 1K tier does not guarantee strict pixel alignment — if you pass1024x1024, you might receive1254x1254with the same aspect ratio. If you reuse that assize, it will still be charged at the 1K tier. 4K single calls usually take 4–8 minutes; it is recommended to use thecallback_urlasynchronous callback mechanism described later.
About theBelow are several real examples from different perspectives to intuitively experience the capabilities ofnparametergpt-image-2currently does not supportn > 1: this parameter will be silently ignored. Whether you passn=1orn=10, only one image will be returned per request and charged as one image. If you need multiple candidate images at once, please concurrently send multiple requests (it is recommended to pass differentpromptorseedvalues simultaneously; otherwise, the images may be very similar). This restriction also applies togpt-image-1/gpt-image-1.5and thenano-banana/nano-banana-2/nano-banana-proseries.dall-e-2is currently the only model that natively supportsn > 1;dall-e-3only supportsn = 1.
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 call code:
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-included designs.
url corresponds to the following image:

AMALFI and ITALIA 1958.
Scenario 3: Complex Composition and Counting
This prompt tests the model’s ability to follow structured instructions like “quantity” and “position.”
dall-e-3 era.
Scenario 4: Illustration Style (Landscape)
By specifying artistic media and mood keywords, you can guide the model to produce stylized illustrations.
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 introduced later. The calling process is exactly the same as other models.
Nano Banana Series Models
Thenano-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 one in the table below.
| Model | Billing (Credits / call) | Suitable Scenarios |
|---|---|---|
nano-banana | 0.14 | General image generation, fastest speed, lowest cost |
nano-banana-2 | 0.28 | Significant quality and detail improvement |
nano-banana-pro | 0.35 | Flagship of the series, best composition, detail, and text |
Important: Supported Parameters Nano Banana is adapted to the OpenAI protocol via an adapter layer and supports only the following parameters compared togpt-image-*:model,prompt,size.
sizeis mapped to internalaspect_ratioas per the table below; unspecified sizes degrade to1:1:
1024x1024/512x512/256x256→1:11792x1024→16:91024x1792→9:16- Does not support
n,quality,style,response_format,background,output_format, etc.; these will be ignored if provided.- Returns follow OpenAI format (
data[].url), butcreatedis fixed at0, nob64_jsonreturned, andrevised_promptalways equals the originalprompt.
Basic Call
url:

Upgrade to Flagship Model nano-banana-pro
Simply change model to nano-banana-pro, with all other parameters unchanged:

Asynchronous Callback
Thecallback_url asynchronous callback mechanism also applies to nano-banana; the calling process is exactly 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:
authorization, which can be selected directly from the dropdown list; another is model, which is the OpenAI DALL-E official model category you choose to use. Here we mainly have one model; details can be seen in our provided models. The last parameter is prompt, which is the text prompt for image generation.
You can also notice the corresponding generated call code on the right side, which you can copy and run directly or click the “Try” button to test.

created: the ID representing this image generation task, used to uniquely identify this task.data: contains the image generation result information.
data contains the specific information of the generated image by the model; its url is the detail link of the generated image, as shown below.

Image Quality Parameter quality
Next, we introduce how to set detailed parameters for the image generation result. The image quality parameter quality includes two options: standard means generating a standard image, and hd means creating an image with finer details and greater consistency.
Below is the setting for the image quality parameter as standard, as shown:


quality set to standard is shown below:

hd yields the following image:

hd generates images with finer details and greater consistency compared to standard.
Image Size Parameter size
You can also set the size of the generated image. Below is the setting for image size as 1024 * 1024, as shown:


1024 * 1024 is shown below:

1792 * 1024 yields the following image:
The image size is obviously different. You can also set more sizes; for details, refer to our official documentation.
Image Style Parameter style
The image style parameter style includes two options: vivid means the generated image is more vivid, and natural means the generated image is more natural.
Below is the setting for the image style parameter as vivid, as shown:


style set to vivid is shown below:

natural yields the following image:

vivid generates images that are more vivid and lifelike compared to natural.
Image Link Format Parameter response_format
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 the image link format parameter as url, as shown:


response_format set to url is Image URL and can be accessed directly. The image is shown below:

b64_json yields the Base64 encoded image link result, as shown below:
Asynchronous Callback
Because the OpenAI Images Generations API may take a relatively long time 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 acallback_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 correlated 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. Opening this site provides a Webhook URL, as shown:
Copy this URL, which can be used as a Webhook. The example here 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:
task_id field, and the data field includes the same image generation results as synchronous calls. The task_id field enables task correlation.
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.

