Skip to content
Google logo

Nano Banana 2.1

Text-to-Image • Google

View as MarkdownAgent setup

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 Licenselink ↗
More informationlink ↗
Pricing
  • Input text (per 1M tokens)$1.50
  • Input image (per 1M tokens)$1.50
  • Output text (per 1M tokens)$7.50
  • Reasoning (per 1M tokens)$7.50
  • Output image (per 1M tokens)$30.00

Usage

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"
  }
}'
Cinematic Landscape
{
  "state": "Completed",
  "result": {
    "image": "https://examples.aig.cloudflare.com/google/nano-banana-2.1/cinematic-landscape.png"
  }
}

Examples

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"
  }
}'
Watercolor Edit
{
  "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"
  }
}'
Grounded Travel Poster
{
  "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"
  }
}'
Editorial Product Campaign
{
  "state": "Completed",
  "result": {
    "image": "https://examples.aig.cloudflare.com/google/nano-banana-2.1/editorial-product-campaign.jpg"
  }
}

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
image
stringformat: uri

API Schemas (Raw)

Input
Output

Was this helpful?