Skip to content
Google logo

Nano Banana 2

Text-to-ImageGoogleProxied

Google's second-generation image generation model with improved quality and speed.

Model Info
Terms and Licenselink
More informationlink

Usage

TypeScript
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',
},
{
gateway: { id: 'default' },
}
)
console.log(response)
Response 200 Futuristic City

Examples

Abstract Art — Modern abstract expressionist painting
TypeScript
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: 'png',
},
{
gateway: { id: 'default' },
}
)
console.log(response)
Response 200 Abstract Art
With Google Search — Use web search grounding for current events
TypeScript
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,
},
{
gateway: { id: 'default' },
}
)
console.log(response)
Response 200 With Google Search
High Resolution Portrait — 4K portrait with specific aspect ratio
TypeScript
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',
resolution: '4K',
output_format: 'jpg',
},
{
gateway: { id: 'default' },
}
)
console.log(response)
Response 200 High Resolution Portrait

Parameters

prompt
stringrequired
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

API Schemas

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"prompt": {
"type": "string"
},
"image_input": {
"maxItems": 3,
"type": "array",
"items": {
"type": "string"
}
},
"aspect_ratio": {
"type": "string",
"enum": [
"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": {
"type": "string",
"enum": [
"jpg",
"png"
]
},
"resolution": {
"type": "string",
"enum": [
"1K",
"2K",
"4K"
]
},
"google_search": {
"type": "boolean"
},
"image_search": {
"type": "boolean"
}
},
"required": [
"prompt"
],
"additionalProperties": false
}