Model ID
Use with the Workers AI binding, the AI Gateway REST API, or the Unified API.
Calling the provider directly? Use the provider's model name instead, including with provider-native endpoints or the provider's own SDK. For example, Anthropic's name for anthropic/claude-opus-4.8 is claude-opus-4-8.
- Third-party
Google's Nano Banana 2.1 image generation and editing model, optimized for a balance of quality and performance.
| Model Info | |
|---|---|
| Context Window ↗ | 131,072 tokens |
| Terms and License | link ↗ |
| More information | link ↗ |
| Pricing |
|
const response = await env.AI.run(
'google/nano-banana-2.1',
{
prompt:
'A cinematic landscape of a misty mountain valley at sunrise, with warm golden light and dramatic clouds',
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.1",
"input": {
"prompt": "A cinematic landscape of a misty mountain valley at sunrise, with warm golden light and dramatic clouds",
"aspect_ratio": "16:9"
}
}'
{
"state": "Completed",
"result": {
"image": "https://examples.aig.cloudflare.com/google/nano-banana-2.1/cinematic-landscape.png"
}
}Watercolor Edit — Edit an image with a text prompt
const response = await env.AI.run(
'google/nano-banana-2.1',
{
prompt: 'Turn the scene into a watercolor illustration with soft pastel colors',
image_input: ['https://storage.googleapis.com/cloud-samples-data/generative-ai/image/scones.jpg'],
aspect_ratio: 'match_input_image',
output_format: 'png',
},
)
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.1",
"input": {
"prompt": "Turn the scene into a watercolor illustration with soft pastel colors",
"image_input": [
"https://storage.googleapis.com/cloud-samples-data/generative-ai/image/scones.jpg"
],
"aspect_ratio": "match_input_image",
"output_format": "png"
}
}'
{
"state": "Completed",
"result": {
"image": "https://examples.aig.cloudflare.com/google/nano-banana-2.1/watercolor-edit.png"
}
}Grounded Travel Poster — Create a search-grounded travel poster
const response = await env.AI.run(
'google/nano-banana-2.1',
{
prompt:
'A stylish vintage travel poster celebrating the latest landmarks and cultural highlights of Tokyo, with bold Japanese-inspired typography, Mount Fuji in the distance, and a warm limited-color print palette',
aspect_ratio: '2:3',
google_search: true,
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.1",
"input": {
"prompt": "A stylish vintage travel poster celebrating the latest landmarks and cultural highlights of Tokyo, with bold Japanese-inspired typography, Mount Fuji in the distance, and a warm limited-color print palette",
"aspect_ratio": "2:3",
"google_search": true,
"output_format": "jpg"
}
}'
{
"state": "Completed",
"result": {
"image": "https://examples.aig.cloudflare.com/google/nano-banana-2.1/grounded-travel-poster.jpg"
}
}Editorial Product Campaign — Create a polished product campaign image from a reference
const response = await env.AI.run(
'google/nano-banana-2.1',
{
prompt:
'Transform this product photo into a premium editorial campaign image on a sculptural stone pedestal, with soft studio lighting, deep emerald accents, realistic shadows, and a clean luxury magazine aesthetic',
image_input: [
'https://storage.googleapis.com/cloud-samples-data/generative-ai/image/320px-Felis_catus-cat_on_snow.jpg',
],
aspect_ratio: '4:5',
output_format: 'jpg',
resolution: '2K',
},
)
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.1",
"input": {
"prompt": "Transform this product photo into a premium editorial campaign image on a sculptural stone pedestal, with soft studio lighting, deep emerald accents, realistic shadows, and a clean luxury magazine aesthetic",
"image_input": [
"https://storage.googleapis.com/cloud-samples-data/generative-ai/image/320px-Felis_catus-cat_on_snow.jpg"
],
"aspect_ratio": "4:5",
"output_format": "jpg",
"resolution": "2K"
}
}'
{
"state": "Completed",
"result": {
"image": "https://examples.aig.cloudflare.com/google/nano-banana-2.1/editorial-product-campaign.jpg"
}
}prompt
stringrequired▶image_input[]
arraymaxItems: 3aspect_ratio
stringenum: match_input_image, 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9output_format
stringenum: jpg, pngresolution
stringenum: 1K, 2K, 4Kgoogle_search
booleanimage_search
booleanimage
stringformat: uri