/api/v1/images/generateText 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"
promptstringrequiredText 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
nintegeroptionalNumber of images to generate. Currently only 1 is supported.
Response fields
idstringUnique generation ID with prefix gen_
modelstringThe model used for this generation
image_urlstringPublicly hosted URL of the generated image (valid for 7 days)
image_base64stringBase64-encoded PNG data
credits_usedintegerCredits deducted for this request
credits_remainingintegerYour credit balance after this request
Error codes
bad_requestMissing or invalid parameters
unauthorizedInvalid or missing API key
insufficient_creditsNot enough credits
rate_limitedToo many requests — slow down