Generate Image (Nanobanana 2)
Submit NanoBanana Generate-2 image generation task using the latest NanoBanana model.
Documentation Index
Fetch the complete documentation index at: https://docs.nanobananaapi.ai/llms.txt
Use this file to discover all available pages before exploring further.
Important Notes
- Task ID returned in the response is used to query task status via the Get Task Details endpoint
- If
callBackUrlis provided, task completion notifications will be sent to that URL via POST request - The
promptfield supports up to 20,000 characters; more detailed prompts generally produce better results - When
imageUrlsis 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, andoutputFormat
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
All APIs require authentication via Bearer Token.
Get API Key:
- 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
Text prompt for image generation (required). Controls the content and style of the generated image. Maximum length: 20,000 characters.
20000["a happy dog running in the park"]Image URLs for image-to-image mode. Use an empty array for pure text-to-image generation. Supports up to 14 reference images.
14Aspect ratio of the generated image.
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 Output resolution quality. Higher values produce larger and sharper images at higher cost.
1K, 2K, 4K Use Google Web Search grounding to generate images based on real-time information.
Output image format.
png, jpg Optional callback URL for async notifications when the task is completed.