Nano Banana 2
Text-to-Image • Google
google/nano-banana-2
- Third-party
- Zero data retention
Google's second-generation image generation model with improved quality and speed.
| Model Info | |
|---|---|
| Terms and License | link ↗ |
| More information | link ↗ |
| Zero data retention | Yes |
| Pricing | <ul><li>Input (per 1M tokens)$0.50</li><li>Output (per 1M tokens)$60.00</li></ul> |
Usage
const response = await env.AI.run(
'google/nano-banana-2',
{
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',
aspect_ratio: '16:9',
},
)
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": {
"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",
"aspect_ratio": "16:9"
}
}'

{
"state": "Completed",
"result": {
"image": "https://examples.aig.cloudflare.com/google/nano-banana-2/futuristic-city.png"
},
"gatewayMetadata": {
"keySource": "Unified"
}
}
Examples
<details>
<summary>Abstract Art — Modern abstract expressionist painting</summary>
const response = await env.AI.run(
'google/nano-banana-2',
{
prompt:
'An abstract expressionist painting with bold splashes of cobalt blue, crimson red, and gold leaf accents on a large canvas',
aspect_ratio: '1:1',
output_format: 'jpg',
},
)
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": {
"prompt": "An abstract expressionist painting with bold splashes of cobalt blue, crimson red, and gold leaf accents on a large canvas",
"aspect_ratio": "1:1",
"output_format": "jpg"
}
}'

{
"state": "Completed",
"result": {
"image": "https://examples.aig.cloudflare.com/google/nano-banana-2/abstract-art.jpg"
},
"gatewayMetadata": {
"keySource": "Unified"
}
}
</details>
<details>
<summary>With Google Search — Use web search grounding for current events</summary>
const response = await env.AI.run(
'google/nano-banana-2',
{
prompt: 'An illustration of the latest Mars rover exploring the Martian surface',
aspect_ratio: '16:9',
google_search: true,
},
)
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": {
"prompt": "An illustration of the latest Mars rover exploring the Martian surface",
"aspect_ratio": "16:9",
"google_search": true
}
}'

{
"state": "Completed",
"result": {
"image": "https://examples.aig.cloudflare.com/google/nano-banana-2/with-google-search.jpg"
},
"gatewayMetadata": {
"keySource": "Unified"
}
}
</details>
<details>
<summary>High Resolution Portrait — 4K portrait with specific aspect ratio</summary>
const response = await env.AI.run(
'google/nano-banana-2',
{
prompt:
'A professional studio portrait of a woman with dramatic side lighting, wearing elegant jewelry',
aspect_ratio: '3:4',
output_format: 'jpg',
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": {
"prompt": "A professional studio portrait of a woman with dramatic side lighting, wearing elegant jewelry",
"aspect_ratio": "3:4",
"output_format": "jpg",
"resolution": "4K"
}
}'

{
"state": "Completed",
"result": {
"image": "https://examples.aig.cloudflare.com/google/nano-banana-2/high-resolution-portrait.jpg"
},
"gatewayMetadata": {
"keySource": "Unified"
}
}
</details>
Parameters
prompt
stringrequired
▶image_input[]
arraymaxItems: 3
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:9
output_format
stringenum: jpg, png
resolution
stringenum: 1K, 2K, 4K
google_search
boolean
image_search
boolean
image
stringformat: uri
API Schemas (Raw)
Was this helpful?
YesNo
On this page
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/ai/models/google/nano-banana-2/#page","headline":"Nano Banana 2","description":"Google's second-generation image generation model with improved quality and speed.","url":"https://developers.cloudflare.com/ai/models/google/nano-banana-2/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
description: Google's fastest Gemini image generation model for rapid image creation and iteration. title: Nano Banana 2 Lite image: https://developers.cloudflare.com/og-docs.png
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt
Use this file to discover all available pages before exploring further.

