Skip to main content
POST
/
api
/
v1
/
nanobanana
/
generate
Generate or Edit Image
curl --request POST \
  --url https://api.nanobananaapi.ai/api/v1/nanobanana/generate \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "prompt": "A serene mountain landscape at sunset with a lake reflecting the orange sky",
  "numImages": 1,
  "type": "TEXTTOIAMGE",
  "image_size": "16:9",
  "callBackUrl": "https://your-callback-url.com/callback"
}'
{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "task12345"
  }
}

Usage Modes

  1. Text-to-Image Generation
    • Provide prompt and set type to “TEXTTOIAMGE”
    • Model will generate a new image based on the text description
  2. Image-to-Image Editing
    • Provide prompt, imageUrls and set type to “IMAGETOIAMGE”
    • Model will edit the input images according to the prompt

Important Notes

  • You can generate 1-4 images per request using the numImages parameter
  • Use the image_size parameter to specify the desired aspect ratio for your images
  • Callback URL (callBackUrl) is required for receiving task completion notifications
  • Task completion will be sent to your callback URL via POST request
  • Use the Get Task Details endpoint to poll task status if needed
  • Choose the appropriate generation type based on your needs:
    • TEXTTOIAMGE: Text to Image generation
    • IMAGETOIAMGE: Image editing with input images

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 describing the desired image or edit.

Example:

"A serene mountain landscape at sunset with a lake reflecting the orange sky"

type
enum<string>
required

Generation type:

  • TEXTTOIAMGE: Text to Image
  • IMAGETOIAMGE: Image Editing
Available options:
IMAGETOIAMGE,
TEXTTOIAMGE
Example:

"TEXTTOIAMGE"

callBackUrl
string<uri>
required

Callback URL to receive task completion notifications (required)

Example:

"https://your-callback-url.com/callback"

numImages
integer
default:1

Number of images to generate. Min: 1, Max: 4

Required range: 1 <= x <= 4
Example:

1

imageUrls
string<uri>[]

Array of input image URLs for image editing mode

Example:
["https://example.com/input-image.jpg"]
watermark
string

Watermark text to add to generated images

Example:

"NanoBanana"

image_size
enum<string>

Image aspect ratio. Supported ratios:

  • 1:1: Square
  • 9:16: Portrait (mobile)
  • 16:9: Landscape (widescreen)
  • 3:4: Portrait
  • 4:3: Landscape (traditional)
  • 3:2: Landscape (photo)
  • 2:3: Portrait (photo)
  • 5:4: Portrait (close to square)
  • 4:5: Portrait (close to square)
  • 21:9: Ultra-wide landscape
Available options:
1:1,
9:16,
16:9,
3:4,
4:3,
3:2,
2:3,
5:4,
4:5,
21:9
Example:

"1:1"

Response

Request successful

code
enum<integer>

Response status code

  • 200: Success
  • 400: Parameter error
  • 401: Unauthorized
  • 500: Server internal error
Available options:
200,
400,
401,
500
msg
string

Response message

Example:

"success"

data
object
I