·Text to Image
POST/api/v1/images/generate

Text to Image

Generate an image from a text prompt using any of the NanoBanana models. Returns synchronously with the image in image_base64 or a hosted image_url.

Body parameters

modelstringrequired

"nano-banana" | "nano-banana-2" | "nano-banana-pro"

promptstringrequired

Text description of the image (max 2000 chars). More detailed prompts produce better results.

aspect_ratiostringoptional

"1:1" | "16:9" | "9:16" | "4:3" | "3:4" — defaults to "1:1"

resolutionstringoptional

"1K" | "2K" | "4K" — only available for nano-banana-2 and nano-banana-pro

nintegeroptional

Number of images to generate. Currently only 1 is supported.

Response fields

idstring

Unique generation ID with prefix gen_

modelstring

The model used for this generation

image_urlstring

Publicly hosted URL of the generated image (valid for 7 days)

image_base64string

Base64-encoded PNG data

credits_usedinteger

Credits deducted for this request

credits_remaininginteger

Your credit balance after this request

Error codes

400
bad_request

Missing or invalid parameters

401
unauthorized

Invalid or missing API key

402
insufficient_credits

Not enough credits

429
rate_limited

Too many requests — slow down