Nano Banana 2 API guide
Nano Banana 2 API: Generate images or edit image references with Nano Banana 2. The public request includes resolution and aspect-ratio controls plus optional Google search and image-search settings.
Model overview
Generate images or edit image references with Nano Banana 2. The public request includes resolution and aspect-ratio controls plus optional Google search and image-search settings.
API integration
| Documentation | Value |
|---|---|
| API invocation identifier | nano-banana-2 |
| Integration | Async task API |
Use this invocation identifier in API requests. Check your authorized model catalog for access. Follow the Quickstart for your first complete call.
Request parameters
Select a mode to highlight its required inputs. Mode selection does not change the API field names.
Studio presets describe the form setup, not guaranteed server defaults. Send preset values explicitly to reproduce them.
Describe the image you want to generate.
Required for Image Editing and References.
Additional requirements depend on other values. See model rules.
Reference images as public HTTP(S) URLs or complete image data URIs. Maximum 14 images; at most 10 MB per image. Supports JPEG, PNG, and WebP.
Item count: maximum 14.
Media types: image/jpeg, image/png, image/webp.
Choose the output image resolution.
Allowed values: "0.5K", "1K", "2K", "4K".
Studio preset: "1K".
Choose the output image aspect ratio.
Allowed values (15)
Allowed values: "auto", "1:1", "3:2", "2:3", "4:3", "3:4", "16:9", "9:16", "5:4", "4:5", "21:9", "1:4", "4:1", "1:8", "8:1".
Studio preset: "1:1".
Additional requirements depend on other values. See model rules.
Allow Google Search to gather information for the prompt.
Studio preset: false.
Allow Google Image Search to find reference images. Requires Google Search to be enabled as well.
Studio preset: false.
Standard quantity control field. The allowed range for this item is 1-15.
Repeats MuseSpark execution within one logical task. This is separate from a model-native output count.
Value: minimum 1; maximum 15.
Studio preset: 1.
Safety-check preference. Availability, scope, and timing depend on the selected provider.
Studio preset: false.
No parameters match. Clear the search or reset the filters.
Model rules
Input modes
Select a mode by supplying its required public inputs. The mode identifier describes a documentation/form choice; do not send input_mode as a model parameter.
| Mode | Required inputs |
|---|---|
| Text to Image | No reference media required |
| Image Editing and References | image_urls |
- When
google_image_searchis true, providegoogle_search; usetrueforgoogle_search. - When the input mode is Text to Image, omit
image_urls. - When the input mode is Image Editing and References, provide
image_urls; keepimage_urls, when supplied, at least 1 items.
Parameter meaning
- Select a ratio suited to the destination: portrait for vertical covers, landscape for banners, or an explicitly supported extreme ratio. Automatic composition can follow the reference image.
- Resolution and aspect ratio describe different dimensions. Keep the ratio fixed when comparing output tiers.
batch_size controls repeated MuseSpark executions. Output grouping, sequential image generation, and video shot count are separate concepts.
Request examples
Replace example media URLs and YOUR_... input identifiers with your own valid resources. Examples are checked against the exported item schema; media access and paid execution are separate runtime checks.
Set MUSESPARK_API_KEY and a stable MUSESPARK_REQUEST_ID before submitting. Preserve the request ID for retries of the same request and use a new ID for new work. Python examples use requests; JavaScript examples use Node.js 20 or later. The standalone Quickstart includes task polling and recovery.
Text to Image
curl --fail-with-body 'https://api.musespark.ai/api/v1/openapi/task' \
-H "Authorization: Bearer $MUSESPARK_API_KEY" \
-H "X-Idempotency-Key: $MUSESPARK_REQUEST_ID" \
-H 'Content-Type: application/json' \
-d '{
"item_key": "nano-banana-2",
"parameters": {
"batch_size": 1,
"nsfw_check": false,
"resolution": "1K",
"aspect_ratio": "1:1",
"google_search": false,
"google_image_search": false,
"prompt": "A paper city under soft morning light"
}
}'Parameters used: batch_size · nsfw_check · resolution · aspect_ratio · google_search · google_image_search · prompt.
Image Editing and References
curl --fail-with-body 'https://api.musespark.ai/api/v1/openapi/task' \
-H "Authorization: Bearer $MUSESPARK_API_KEY" \
-H "X-Idempotency-Key: $MUSESPARK_REQUEST_ID" \
-H 'Content-Type: application/json' \
-d '{
"item_key": "nano-banana-2",
"parameters": {
"batch_size": 1,
"nsfw_check": false,
"resolution": "1K",
"aspect_ratio": "1:1",
"google_search": false,
"google_image_search": false,
"prompt": "A paper city under soft morning light",
"image_urls": [
"https://example.com/input-1.png"
]
}
}'Parameters used: batch_size · nsfw_check · resolution · aspect_ratio · google_search · google_image_search · prompt · image_urls.
Output
Creation returns a task ID inside data. Poll that task until completion, then save data.result.output_urls and any data.result.batch_results. See the task lifecycle for terminal states, result retention, and errors.
Troubleshooting
For rejected inputs, check the field type, accepted values, and conditional requirements in Request parameters and Model rules. Correct the affected fields before submitting again.
If creation times out, preserve the request identity and any known task ID. Follow Errors, timeouts and retries before submitting again.
Related docs
The public input snapshot was exported on 2026-11-09. Current prices and availability are listed in the model center.