Gemini 3.1 Flash Image Preview (Nano Banana 2)

Overview

Gemini 3.1 Flash Image Preview (also known as Nano Banana 2) provides high-quality image generation and conversational editing at a mainstream price point with low latency. It serves as the high-efficiency counterpart to the Pro tier, optimized for speed and high-volume developer use cases.

Nano Banana 2 supports output resolutions from 512px to 4K, extended aspect ratios including ultra-wide formats, Image Search Grounding, Thinking mode, and improved multilingual text rendering.

Model Variants

ModelResolutionCredits / ImageDescription
gemini-3.1-flash-image-preview-512512px4Fast preview, lower resolution
gemini-3.1-flash-image-preview1K (1024px)4Default balanced quality
gemini-3.1-flash-image-preview-2k2K (2048px)6High resolution
gemini-3.1-flash-image-preview-4k4K (4096px)8Ultra-high resolution

Choose a Nano Banana 2 variant based on your output requirements. The 1K variant works well for social media posts and thumbnails, while the 2K and 4K variants are ideal for print-ready assets and high-DPI displays.

Capabilities

FeatureSupport
Text to Image✅ Supported
Image Editing✅ Supported
Batch Generation✅ Up to 9 images per request
Max Input Images10 (character resemblance up to 4)
Thinking✅ Supported
Search Grounding✅ Supported (text + image search)

Supported Aspect Ratios

Standard:

1:1 · 16:9 · 9:16 · 4:3 · 3:4 · 2:3 · 3:2 · 4:5 · 5:4

Extended (exclusive to this model):

21:9 · 1:4 · 4:1 · 8:1 · 1:8

The extended ratios are particularly useful for website banners (21:9), vertical story backgrounds (1:4), and panoramic scenes (8:1). No other model in our lineup supports these extreme aspect ratios.

Pricing

All pricing is based on per-image cost via the NanoBanana API, which is significantly cheaper than going through the official channels directly.

VariantOur PriceOfficial PriceSavings
512px~$0.04~$0.05~20%
1K (1024px)~$0.04~$0.067~40%
2K (2048px)~$0.06~$0.101~40%
4K (4096px)~$0.08~$0.151~47%

Nano Banana 2 at higher resolutions provides better value savings compared to official pricing. For high-volume workloads, you can achieve even greater cost efficiency by using our credit bundles.

Best Practices

Prompt Engineering Tips

  • Be specific with details: Include colors, lighting, perspective, and mood descriptors in your prompts for better results. For example, "a golden retriever puppy playing in autumn leaves, warm sunset lighting, shallow depth of field" produces more precise output than simply "a dog".
  • Use natural language: Write prompts as complete, descriptive sentences rather than comma-separated keywords. The underlying language model interprets context and meaning, not just individual terms.
  • Leverage reference images: Upload up to 10 reference images to guide style, composition, or character consistency. This is ideal for maintaining visual branding across multiple assets.

Choosing the Right Resolution

  • 512px: Best for rapid iteration, storyboards, or concept exploration where speed matters more than final quality.
  • 1K (1024px): Ideal for web content, social media posts, blog headers, and email newsletters. Offers the best balance of quality and cost.
  • 2K (2048px): Recommended for product photography, marketing materials, and presentations that require sharp detail on retina displays.
  • 4K (4096px): Designed for print-ready assets, large-format displays, and archival-quality imagery. Also suitable for cropping high-detail regions from panoramic compositions.

Performance Optimization

  • Batch requests: Group multiple Nano Banana 2 prompts into a single request (up to 9 images) to reduce round-trip overhead and improve throughput.
  • Cache common parameters: Store your preferred model, resolution, and style settings on the client side to avoid redundant configuration in each API call.
  • Use webhooks for 4K: Higher resolutions may take longer to render. Consider using webhook callbacks instead of synchronous polling for production workloads.

Use Cases

  • Professional content creation — High-resolution images for marketing campaigns and social media channels
  • Product visualization — Detailed product mockups and commercial photography with logo integration
  • Multi-reference generation — Use up to 10 reference images for consistent character and style output
  • Ultra-wide / panoramic — Extended aspect ratios for website headers, banners, and cinematic backgrounds
  • Multilingual text rendering — Improved accuracy for CJK characters, Arabic script, and other non-Latin text systems
  • Iterative design workflows — Edit and refine generated images through conversational prompts
  • Brand asset production — Maintain visual consistency across large content libraries using style references

Quick Start

Replace YOUR_API_KEY with your actual API key. Don't have one yet? Create an API key here.

curl -X POST "https://api.nanobananaapi.dev/v1/images/generate" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A futuristic city skyline at dusk with neon lights reflecting on glass buildings",
    "num": 1,
    "model": "gemini-3.1-flash-image-preview-2k",
    "image_size": "16:9"
  }'
const res = await fetch('https://api.nanobananaapi.dev/v1/images/generate', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    prompt: 'A futuristic city skyline at dusk with neon lights reflecting on glass buildings',
    num: 1,
    model: 'gemini-3.1-flash-image-preview-2k',
    image_size: '16:9',
  }),
});

const result = await res.json();
console.log(result.data.url);
import requests

res = requests.post(
  'https://api.nanobananaapi.dev/v1/images/generate',
  headers={
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  json={
    'prompt': 'A futuristic city skyline at dusk with neon lights reflecting on glass buildings',
    'num': 1,
    'model': 'gemini-3.1-flash-image-preview-2k',
    'image_size': '16:9',
  },
  timeout=60,
)

result = res.json()
print(result['data']['url'])

API Parameters Reference

ParameterTypeRequiredDescription
promptstringYesThe text description of the image to generate
modelstringYesModel identifier (see variants above)
numintegerNoNumber of images to generate (1–9, default 1)
image_sizestringNoAspect ratio (default 1:1)
ref_imagesarrayNoReference images for style or character guidance

Frequently Asked Questions

What is the difference between the Nano Banana 2 1K and 2K variants? The 1K variant outputs images at 1024×1024 pixels, while the 2K variant outputs at 2048×2048 pixels. The 2K variant costs slightly more per image but provides significantly sharper detail, making it better for print and high-DPI screens.

Can I use reference images for character consistency? Yes. You can upload up to 10 reference images per request, with up to 4 specifically for character resemblance. This is useful for creating consistent characters across multiple scenes or maintaining brand mascots.

Does Nano Banana 2 support image editing? Yes. You can pass existing images along with a text prompt describing desired changes. The model supports conversational editing, meaning you can make multiple rounds of refinements to the same base image.

How does Search Grounding work? When enabled, the model can access Google Search results to ground its output in real-world information. This is useful for generating images of real places, current events, or factual subjects that require up-to-date visual references.