Nano Banana Images API Integration Guide
This document introduces the integration and use of the Nano Banana Images API. The API supports two capabilities: image generation (generate) and image editing (edit).
¶ Application Process
To use the Nano Banana Images API, first obtain your API Token from the Ace Data Cloud Console and keep it for later use.

If you have not yet logged in or registered, you will be automatically redirected to the login page to register and log in. Once completed, you will be automatically returned to the current page.
A general-purpose application's API Key can be used for services enabled for the account; a dedicated application's Key is used within that application's service scope. Please check the Key's permissions, validity period, and limits, and confirm that the application balance is sufficient to pay for this request. Available trial credits are subject to what is shown in your account. If the balance is insufficient, click the "Recharge" button.
📘 Full documentation: Nano Banana Images API →
¶ API Overview
- Base URL:
https://api.acedata.cloud - Endpoint:
POST /nano-banana/images - Authentication: Include
authorization: Bearer {token}in the HTTP Header - Request headers:
accept: application/jsoncontent-type: application/json
- Actions (action):
generate: Generate images based on a text promptedit: Edit based on given images
- Models (model) (optional):
nano-banana(default): Based on Gemini 2.5 Flash Image, fast and low-costnano-banana-2-lite: Based on Gemini 3.1 Flash Lite Image, supports only 1K, with fast generationnano-banana-2: Based on Gemini 3.1 Flash Image Preview, Pro-level quality + Flash speednano-banana-2.1: A new-generation efficient image model that supports image generation and editing in 1K, 2K, and 4Knano-banana-pro: Based on Gemini 3 Pro Image Preview, highest qualitynano-banana:official,nano-banana-2-lite:official,nano-banana-2:official,nano-banana-pro:official: Official-channel versions of the corresponding models, with better image quality and stability and different pricing
- Asynchronous callback: Optional; receive task completion notifications and results through
callback_url - Number of images: Optional; specify 1–4 images through
count, with 1 image by default; each image is generated by a separate generation call; ordinary technical failures or provider safety rejections affect only the corresponding call, while other successfully generated images are returned as usual, and billing is based on the number of images successfully returned - Nano Banana 2 per-image billing:
4Kfornano-banana-2costs 0.33 Credits per image, and1Kand2Kcost 0.28 Credits per image. Billing is based on the number of images successfully returned.
¶ Quick Start: Generate Images (action=generate)
Minimum required parameters: action, prompt
When you only want to generate an image directly from a prompt, set action to generate and provide a clear prompt.
¶ Request Example (cURL)
curl -X POST 'https://api.acedata.cloud/nano-banana/images' \
-H 'authorization: Bearer {token}' \
-H 'accept: application/json' \
-H 'content-type: application/json' \
-d '{
"action": "generate",
"model": "nano-banana-pro",
"prompt": "A photorealistic close-up portrait of an elderly Japanese ceramicist with deep, sun-etched wrinkles and a warm, knowing smile. He is carefully inspecting a freshly glazed tea bowl. The setting is his rustic, sun-drenched workshop. The scene is illuminated by soft, golden hour light streaming through a window, highlighting the fine texture of the clay. Captured with an 85mm portrait lens, resulting in a soft, blurred background (bokeh). The overall mood is serene and masterful. Vertical portrait orientation.",
"count": 1
}'
¶ Request Example (Python)
import requests
url = "https://api.acedata.cloud/nano-banana/images"
headers = {
"authorization": "Bearer {token}",
"accept": "application/json",
"content-type": "application/json",
}
payload = {
"action": "generate",
"model": "nano-banana-pro",
"prompt": (
"A photorealistic close-up portrait of an elderly Japanese ceramicist "
"with deep, sun-etched wrinkles and a warm, knowing smile. He is carefully "
"inspecting a freshly glazed tea bowl. The setting is his rustic, sun-drenched "
"workshop. The scene is illuminated by soft, golden hour light streaming through "
"a window, highlighting the fine texture of the clay. Captured with an 85mm "
"portrait lens, resulting in a soft, blurred background (bokeh). The overall mood "
"is serene and masterful. Vertical portrait orientation."
),
"count": 1
}
resp = requests.post(url, json=payload, headers=headers)
print(resp.json())
¶ Successful Response Example
{
"success": true,
"task_id": "70e6931b-6e34-43db-9e36-8765e2809d04",
"trace_id": "60df8d38-f265-4986-aec7-75c9220bced2",
"data": [
{
"prompt": "A photorealistic close-up portrait of an elderly Japanese ceramicist with deep, sun-etched wrinkles and a warm, knowing smile. He is carefully inspecting a freshly glazed tea bowl. The setting is his rustic, sun-drenched workshop. The scene is illuminated by soft, golden hour light streaming through a window, highlighting the fine texture of the clay. Captured with an 85mm portrait lens, resulting in a soft, blurred background (bokeh). The overall mood is serene and masterful. Vertical portrait orientation.",
"image_url": "https://cdn.acedata.cloud/assets/examples/nanobanana/1d0160b4-93f9-4229-8926-ea9ef0bed336-34b3dc2195e8.png"
}
]
}
¶ Field Descriptions
success: Whether the request was successful.task_id: Task ID.trace_id: Trace ID, useful for troubleshooting.count: The number of images requested for generation or editing; supports 1–4, with a default of 1.datacontains only successfully generated images, and billing is based on the number actually returned. The provider's native safety policies are enforced for every generation call; rejection of one call does not affect other successful calls, and a 403 is returned if all calls are rejected.data[]: List of results.prompt: The prompt used for generation (echoed back).image_url: The direct URL of the generated image.
Note:
/nano-banana/imagesonly requiresactionandpromptto generate an image
¶ Edit Images (action=edit)
When you want to edit existing images, set action to edit, pass a list of image URLs to be edited (one or more images) through image_urls, and provide a prompt describing the editing goal.
For example, here we provide a photo of a person and a photo of an item of clothing, and ask the person to wear the clothing. You can pass both image links and specify action as edit. The URLs can be HTTP URLs, publicly accessible links using the https or http protocol, or Base64-encoded images, such as data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA+gAAAVGCAMAAAA6u2FyAAADAFBMVEXq6uwdHCEeHyMdHS....
¶ Request Example (cURL)
curl -X POST 'https://api.acedata.cloud/nano-banana/images' \
-H 'authorization: Bearer {token}' \
-H 'accept: application/json' \
-H 'content-type: application/json' \
-d '{
"action": "edit",
"prompt": "let this man wear on this T-shirt",
"image_urls": [
"https://cdn.acedata.cloud/v8073y.png",
"https://cdn.acedata.cloud/44xlah.png"
],
"count": 1
}'
¶ Request Example (Python)
import requests
url = "https://api.acedata.cloud/nano-banana/images"
headers = {
"authorization": "Bearer {token}",
"accept": "application/json",
"content-type": "application/json",
}
payload = {
"action": "edit",
"prompt": "let this man wear on this T-shirt",
"image_urls": [
"https://cdn.acedata.cloud/v8073y.png",
"https://cdn.acedata.cloud/44xlah.png"
],
"count": 1
}
resp = requests.post(url, json=payload, headers=headers)
print(resp.json())
¶ Successful Response Example
{
"success": true,
"task_id": "93f11baf-347b-4bb4-9520-8653cb46d6a3",
"trace_id": "a9063166-26ed-4451-85b5-54e896817c69",
"data": [
{
"prompt": "let this man wear on this T-shirt",
"image_url": "https://platform.cdn.acedata.cloud/nanobanana/8e9e0253-26f4-45b9-b3f8-ac1aed1c284b.png"
}
]
}
¶ Field Descriptions
image_urls[]: List of URLs for images to be edited (must be publicly accessible). Multiple images can be provided; the service will use these materials together with thepromptto complete the edit.- The remaining fields are the same as those returned by “Generate Images”.
¶ Asynchronous Callback (Optional, Recommended)
Generating or editing images may take some time. To avoid resource usage by long-lived connections, we recommend using a Webhook callback via callback_url:
- Add
callback_urlto the request body, for example, your server’s Webhook address (must be publicly accessible and support POST JSON). - The API will immediately return a response containing a
task_id(or basic results). - When the task is complete, the platform will send the full JSON to
callback_urlusingPOST. You can usetask_idto associate the request with the result.
Callback payload example (the field structure is the same as the synchronous successful response):
{
"success": true,
"task_id": "6a97bf49-df50-4129-9e46-119aa9fca73c",
"trace_id": "9b4b1ff3-90f2-470f-b082-1061ec2948cc",
"data": [
{
"prompt": "a white siamese cat",
"image_url": "https://platform.cdn.acedata.cloud/nanobanana/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.png"
}
]
}
¶ Error Handling
When a call fails, a standard error format and trace ID are returned. Common errors are as follows:
- 400
token_mismatched: Invalid request or parameters. - 400
api_not_implemented: The API is not implemented (please contact support). - 401
invalid_token: Authentication failed or the token is missing. - 403
forbidden: The provider’s native safety policy rejected the request or generated result. This call will not return an image and will not be charged; requests for multiple images may still return and be charged for other successful calls. - 429
too_many_requests: Request rate limit exceeded. - 500
api_error: Server error.
¶ Error Response Example
{
"success": false,
"error": {
"code": "api_error",
"message": "Internal server error."
},
"trace_id": "2cf86e86-22a4-46e1-ac2f-032c0f2a4e89"
}
¶ Parameter Reference and Notes
- Required:
action,prompt - Editing only:
image_urls(array, at least 1 item) - Optional:
model(defaults tonano-banana; options includenano-banana-2-lite,nano-banana-2,nano-banana-2.1, andnano-banana-pro; corresponding:officialofficial-channel versions are also available, except fornano-banana-2.1),aspect_ratio(autoor a specific aspect ratio, such as1:1or16:9),resolution(resolution, such as1K,2K, or4K;nano-banana-2-liteonly supports1K),callback_url(for asynchronous callbacks) - Headers:
authorization: Bearer {token}must be provided; settingaccepttoapplication/jsonis recommended - Image accessibility:
image_urlsmust be publicly accessible direct links (HTTP/HTTPS); HTTPS is recommended - Idempotency and tracing: Retain
task_idandtrace_idfor troubleshooting and associating results
Explicitly passing "aspect_ratio": "auto" selects the closest preset based on the aspect ratio, orientation, or layout in the prompt, and applies to both generation and editing. For example, a prompt containing “YouTube thumbnail” can select 16:9. When the prompt has no size requirements or automatic detection is unavailable, text-to-image generation uses the default aspect ratio, while image editing follows the first reference image and uses the closest supported ratio. When this field is omitted, the default aspect ratio or the reference image’s ratio is used. If there is already a specific aspect ratio requirement, pass the specific ratio directly.
