Nano Banana 2
Text-to-Image • Google • ProxiedGoogle's second-generation image generation model with improved quality and speed.
| Model Info | |
|---|---|
| Terms and License | link ↗ |
| More information | link ↗ |
| Pricing | View pricing in the Cloudflare dashboard ↗ |
Usage
const response = await env.AI.run( 'google/nano-banana-2', { aspect_ratio: '16:9', prompt: 'A futuristic cyberpunk city at night with towering skyscrapers, neon signs in Japanese and English, flying cars, and rain-slicked streets reflecting colorful lights', },)console.log(response)curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \ --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ --header "Content-Type: application/json" \ --data '{ "model": "google/nano-banana-2", "input": { "aspect_ratio": "16:9", "prompt": "A futuristic cyberpunk city at night with towering skyscrapers, neon signs in Japanese and English, flying cars, and rain-slicked streets reflecting colorful lights" }}'
{ "gatewayMetadata": { "keySource": "Unified" }, "result": { "image": "https://pub-04a6d208d361438ea01b797e6973bd19.r2.dev/catalog/google__nano-banana-2/futuristic-city.png" }, "state": "Completed"}Examples
Abstract Art — Modern abstract expressionist painting
const response = await env.AI.run( 'google/nano-banana-2', { aspect_ratio: '1:1', output_format: 'png', prompt: 'An abstract expressionist painting with bold splashes of cobalt blue, crimson red, and gold leaf accents on a large canvas', },)console.log(response)curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \ --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ --header "Content-Type: application/json" \ --data '{ "model": "google/nano-banana-2", "input": { "aspect_ratio": "1:1", "output_format": "png", "prompt": "An abstract expressionist painting with bold splashes of cobalt blue, crimson red, and gold leaf accents on a large canvas" }}'
{ "gatewayMetadata": { "keySource": "Unified" }, "result": { "image": "https://pub-04a6d208d361438ea01b797e6973bd19.r2.dev/catalog/google__nano-banana-2/abstract-art.png" }, "state": "Completed"}With Google Search — Use web search grounding for current events
const response = await env.AI.run( 'google/nano-banana-2', { aspect_ratio: '16:9', google_search: true, prompt: 'An illustration of the latest Mars rover exploring the Martian surface', },)console.log(response)curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \ --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ --header "Content-Type: application/json" \ --data '{ "model": "google/nano-banana-2", "input": { "aspect_ratio": "16:9", "google_search": true, "prompt": "An illustration of the latest Mars rover exploring the Martian surface" }}'
{ "gatewayMetadata": { "keySource": "Unified" }, "result": { "image": "https://pub-04a6d208d361438ea01b797e6973bd19.r2.dev/catalog/google__nano-banana-2/with-google-search.png" }, "state": "Completed"}High Resolution Portrait — 4K portrait with specific aspect ratio
const response = await env.AI.run( 'google/nano-banana-2', { aspect_ratio: '3:4', output_format: 'jpg', prompt: 'A professional studio portrait of a woman with dramatic side lighting, wearing elegant jewelry', resolution: '4K', },)console.log(response)curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \ --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ --header "Content-Type: application/json" \ --data '{ "model": "google/nano-banana-2", "input": { "aspect_ratio": "3:4", "output_format": "jpg", "prompt": "A professional studio portrait of a woman with dramatic side lighting, wearing elegant jewelry", "resolution": "4K" }}'
{ "gatewayMetadata": { "keySource": "Unified" }, "result": { "image": "https://pub-04a6d208d361438ea01b797e6973bd19.r2.dev/catalog/google__nano-banana-2/high-resolution-portrait.jpg" }, "state": "Completed"}Parameters
aspect_ratio
stringenum: match_input_image, 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9google_search
boolean▶image_input[]
arraymaxItems: 3image_search
booleanoutput_format
stringenum: jpg, pngprompt
stringrequiredresolution
stringenum: 1K, 2K, 4Kimage
stringformat: uri