How to Use Google's Nano Banana 2 Lite (Gemini 3.1 Flash-Lite Image) API: Code, Pricing, & Troubleshooting (2026)
Learn how to integrate Google's Nano Banana 2 Lite (Gemini 3.1 Flash-Lite Image) API. Get SDK code, pricing, and fixes for the 400 error.
On this page 13 sections

Key takeaways
Google's Nano Banana 2 Lite (model ID: gemini-3.1-flash-lite-image) is a proprietary, API-only image model. It generates 1K images in 4 seconds at $0.034 per 1,000 generations. It is not open-source and cannot be run locally via Hugging Face. To fix the common 400 HTTP error, run pip install --upgrade google-genai to update your local SDK registry.
Google has officially released Nano Banana 2 Lite (Gemini 3.1 Flash-Lite Image). This complete developer guide covers the Python SDK integration code, the pricing structure, and how to fix the common
On June 30, 2026, Google DeepMind officially released Gemini 3.1 Flash-Lite Image, codenamed Nano Banana 2 Lite.
This model is a significant release for developers building high-volume image pipelines. While premium models like Midjourney v8.1 focus on creative visual styling and FLUX.2 dominates high-fidelity photorealism, Nano Banana 2 Lite is built for speed and low cost, generating a standard 1K resolution image in approximately 4 seconds.
However, because the model is new, developers are encountering common integration errors — most notably the HTTP 400 error: Unsupported Model.
This developer guide covers the pricing structure, Python SDK integration code, and step-by-step troubleshooting to get the Nano Banana 2 Lite API working in your application.
1. What is Nano Banana 2 Lite?
Nano Banana 2 Lite is the entry-tier image generation model in Google's 3.1 image generation suite. It is designed to sit alongside the generalist workhorse model Nano Banana 2 (gemini-3.1-flash-image) and the premium model Nano Banana Pro (gemini-3-pro-image).
For a complete performance comparison of how Google's image models stack up against the competition, review our GPT Image 2 vs Midjourney vs FLUX vs Krea 2 Comparison.
Key Features
- Ultra-Low Latency: Renders 1024x1024px images in 4 seconds.
- SynthID Watermarking: Automatically embeds Google's invisible, crop-resistant digital watermarks into every image.
- Aspect Ratio Support: Natively supports 14 distinct aspect ratios (including 1:1, 16:9, 9:16, 4:3, 3:2, and 2:3).
- Multimodal Input: A 65,536-token context window allows you to feed both text descriptions and reference images directly to the API for style transfer and editing.
2. Is Nano Banana 2 Lite on Hugging Face?
Many developers are searching GitHub and Hugging Face looking for weights to run Nano Banana 2 Lite locally on consumer GPUs.
The Answer: No. Nano Banana 2 Lite is a proprietary, closed-source API-only model hosted on Google’s infrastructure. It is accessed exclusively via the Google GenAI API or cloud gateways (such as Fal.ai or OpenRouter). You cannot run it locally.
For developers seeking open-weight models that can be run locally, we recommend checking out FLUX.2 Dev or Stable Diffusion. See our Stable Diffusion Anime Checkpoints Guide for details on configuring local open-source setups.
3. API Pricing Structure
Google has priced Nano Banana 2 Lite for developers running high-volume pipelines (e.g. real-time user image generators in chat apps).
- Priced per image: Approximately $0.034 per 1,000 images generated at standard quality.
- Token-based billing: Alternately billed at $0.25 per million input tokens and $1.50 per million output tokens.
This is approximately 5–10× cheaper than running standard API pipelines for Midjourney or FLUX.2 Pro, making it the most cost-efficient image API available in 2026.
4. API Integration Code (Python SDK)
To interact with the Nano Banana 2 Lite API, you must use the official google-genai SDK.
Step 1: Install or Upgrade the SDK
pip install --upgrade google-genai
Step 2: Set Your API Key
Set your Gemini API key in your environment variables:
export GEMINI_API_KEY="your-api-key-here"
Step 3: Python Implementation Script
from google import genai
from google.genai import types
def generate_nano_banana_image(prompt_text: str, aspect_ratio: str = "16:9"):
# Initialize the client (automatically reads GEMINI_API_KEY from environment)
client = genai.Client()
print(f"Sending prompt to Nano Banana 2 Lite: '{prompt_text}'...")
try:
response = client.models.generate_images(
model='gemini-3.1-flash-lite-image',
prompt=prompt_text,
config=types.GenerateImagesConfig(
number_of_images=1,
aspect_ratio=aspect_ratio,
output_mime_type="image/jpeg",
person_generation="ALLOW_ADULT" # Options: DONT_ALLOW, ALLOW_ADULT
)
)
# Save the generated image
for i, generated_image in enumerate(response.generated_images):
output_file = f"output_nano_banana_{i}.jpg"
with open(output_file, "wb") as f:
f.write(generated_image.image.image_bytes)
print(f"Successfully generated and saved: {output_file}")
except Exception as e:
print(f"API Generation Failed: {e}")
# Example invocation
generate_nano_banana_image(
prompt_text="A sleek cyberpunk office desk at night, neon reflections on a clean glass tabletop, glowing keyboard, cinematic side-lighting --ar 16:9"
)
5. Troubleshooting: How to Fix the 400 Error
The most common issue developers are reporting is the following exception:
google.genai.errors.APIError: [400] Unsupported Model: gemini-3.1-flash-lite-image
Why it happens:
Your local google-genai SDK library uses a local registry file of supported models. If your library was installed before the June 30, 2026 release date, the SDK will block your code from executing the request because it doesn't recognize the new model ID gemini-3.1-flash-lite-image.
The Fix:
You must force the SDK to update its model registry by upgrading to the latest version:
# Upgrade the core SDK
pip install --upgrade google-genai
# If you are using Node.js, upgrade the npm package:
npm install @google/genai@latest
If you are using a managed container (like Docker), ensure you trigger a rebuild with --no-cache to force the package manager to fetch the July 1, 2026 release of the library.
Ready to find the best prompts to feed into your new Nano Banana 2 Lite API? Browse our Explore Prompt Library to copy verified styles and layouts.
Frequently asked questions
What is Nano Banana 2 Lite (Gemini 3.1 Flash-Lite Image)?
How do I fix the 400 Unsupported Model error for gemini-3.1-flash-lite-image?
Can I run Nano Banana 2 Lite locally via Hugging Face?
Sources and further reading
- Google DeepMind: Gemini 3.1 Flash-Lite Image (Nano Banana 2 Lite) Model Release and Pricing Documentation (June 30, 2026)
- Google GenAI SDK GitHub Repository: Release Tags and Model Registry Updates (June 2026)








