Skip to main content
POST
/
api
/
v1
/
nanobanana
/
generate-2
Generate Image (Generate-2)
curl --request POST \
  --url https://api.nanobananaapi.ai/api/v1/nanobanana/generate-2 \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "prompt": "a happy dog running in the park",
  "imageUrls": [],
  "aspectRatio": "auto",
  "resolution": "1K",
  "googleSearch": false,
  "outputFormat": "jpg",
  "callBackUrl": "https://example-callback.com"
}
'
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678"
  }
}

Important Notes

  • Task ID returned in the response is used to query task status via the Get Task Details endpoint
  • If callBackUrl is provided, task completion notifications will be sent to that URL via POST request
  • The prompt field supports up to 20,000 characters; more detailed prompts generally produce better results
  • When imageUrls is an empty array, the request runs in pure text-to-image mode; when URLs are provided, it runs in image-to-image / reference mode
  • You can control the aspect ratio, resolution, and output format using aspectRatio, resolution, and outputFormat

Parameter Overview

  • prompt: Text prompt (required), up to 20,000 characters
  • imageUrls: Array of reference image URLs; use an empty array for text-to-image mode, up to 14 images
  • aspectRatio: Aspect ratio of the generated image. Supported: 1:1, 1:4, 1:8, 2:3, 3:2, 3:4, 4:1, 4:3, 4:5, 5:4, 8:1, 9:16, 16:9, 21:9, auto
  • resolution: Output quality level, one of 1K / 2K / 4K
  • googleSearch: Whether to enable Google Web Search grounding (default: false)
  • outputFormat: Output format, either png or jpg (default: jpg)
  • callBackUrl: Optional callback URL to receive async task completion notifications

Authorizations

Authorization
string
header
required

All APIs require authentication via Bearer Token.

Get API Key:

  1. Visit API Key Management Page to get your API Key

Usage: Add to request header: Authorization: Bearer YOUR_API_KEY

Note:

  • Keep your API Key secure and do not share it with others
  • If you suspect your API Key has been compromised, reset it immediately in the management page

Body

application/json
prompt
string
required

Text prompt for image generation (required). Controls the content and style of the generated image. Maximum length: 20,000 characters.

Maximum string length: 20000
Example:
["a happy dog running in the park"]
imageUrls
string<uri>[]

Image URLs for image-to-image mode. Use an empty array for pure text-to-image generation. Supports up to 14 reference images.

Maximum array length: 14
aspectRatio
enum<string>
default:auto

Aspect ratio of the generated image.

Available options:
1:1,
1:4,
1:8,
2:3,
3:2,
3:4,
4:1,
4:3,
4:5,
5:4,
8:1,
9:16,
16:9,
21:9,
auto
resolution
enum<string>
default:1K

Output resolution quality. Higher values produce larger and sharper images at higher cost.

Available options:
1K,
2K,
4K

Use Google Web Search grounding to generate images based on real-time information.

outputFormat
enum<string>
default:jpg

Output image format.

Available options:
png,
jpg
callBackUrl
string<uri>

Optional callback URL for async notifications when the task is completed.

Response

200 - application/json

Request successful

code
integer

Response status code

Example:

200

message
string

Response message

Example:

"success"

data
object