Skip to main content
🆕 Nano Banana2 (Gemini 3.1 Flash) Now Available! The new benchmark for value. Usage is identical to Nano Banana Pro.
  • Great Value: Only $0.03/image, cheaper than Pro
  • 4K Quality: Supports 1K, 2K, 4K resolutions
  • Full Features: Text-to-image + image editing, compatible with OpenAI SDK and Google native format

Prerequisites

1

Get API Key

Login to laozhang.ai console to get your API key
2

Configure Billing Mode

Edit token settings and select one of these billing modes (same price):
  • Pay-per-use Priority (Recommended): Use balance first, auto-switch when insufficient
  • Pay-per-use: Direct charge per request, best for strict budget control
Both modes have identical pricing at $0.03/image, only the billing method differs.
Token Settings
API calls will fail without proper billing configuration. Complete this setup first!

Model Overview

Nano Banana2 is LaoZhang API’s custom name for Google’s Gemini 3.1 Flash Image Preview (gemini-3.1-flash-image-preview) model. Built on the latest Gemini 3.1 Flash architecture, it delivers high-quality output with better value. Nano Banana2 usage is identical to Nano Banana Pro - just replace the model name with gemini-3.1-flash-image-preview.

📋 Nano Banana Model Comparison

ModelModel IDBillingLaoZhang API PriceResolutionSpeedHighlight
Nano Banana Progemini-3-pro-image-previewPer-use$0.05/image1K/2K/4K~10sMost intelligent, complex instructions
Nano Banana2gemini-3.1-flash-image-previewPer-use$0.03/image1K/2K/4K~10sBest value, high quality
Nano Bananagemini-2.5-flash-imagePer-use$0.025/image1K (fixed)~10sBasic, stable & reliable
💡 How to Choose?
  • Ultimate quality & complex instructions: Choose Nano Banana Pro ($0.05/image)
  • Best value for advanced use: Choose Nano Banana2 ($0.03/image)
  • Budget-conscious, basic needs: Choose Nano Banana Standard ($0.025/image)

🚀 Quick Start: OpenAI Compatible Mode

Curl Example

curl -X POST "https://api.laozhang.ai/v1/chat/completions" \
     -H "Authorization: Bearer $API_KEY" \
     -H "Content-Type: application/json" \
     -d '{
    "model": "gemini-3.1-flash-image-preview",
    "stream": false,
    "messages": [
        {
            "role": "user",
            "content": "a beautiful sunset over mountains"
        }
    ]
}'

Python SDK Example

from openai import OpenAI
import base64
import re

client = OpenAI(
    api_key="sk-YOUR_API_KEY",
    base_url="https://api.laozhang.ai/v1"
)

response = client.chat.completions.create(
    model="gemini-3.1-flash-image-preview",
    messages=[
        {
            "role": "user",
            "content": "a beautiful sunset over mountains"
        }
    ]
)

# Extract base64 image data
content = response.choices[0].message.content
match = re.search(r'!\[.*?\]\((data:image/png;base64,.*?)\)', content)

if match:
    base64_data = match.group(1).split(',')[1]
    image_data = base64.b64decode(base64_data)

    with open('output.png', 'wb') as f:
        f.write(image_data)
    print("✅ Image saved: output.png")

🎨 Image Editing

Nano Banana2 also supports image editing, with usage identical to Pro. Simply include reference images and editing instructions in your request, using model name gemini-3.1-flash-image-preview.
# Image editing example (OpenAI compatible mode)
response = client.chat.completions.create(
    model="gemini-3.1-flash-image-preview",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "Transform this image into Van Gogh Starry Night style"},
            {"type": "image_url", "image_url": {"url": "https://example.com/your-image.jpg"}}
        ]
    }]
)
For more image editing features (multi-image fusion, 4K output, Google native format, etc.), see the Nano Banana Pro Image Editing docs and replace the model name with gemini-3.1-flash-image-preview.

📖 Complete Usage Guide

Nano Banana2 API calls are identical to Nano Banana Pro, including OpenAI compatible mode and Google native format. Simply replace the model name from gemini-3-pro-image-preview to gemini-3.1-flash-image-preview - no other code changes needed.

❓ FAQ

FeatureNano Banana ProNano Banana2
Modelgemini-3-pro-image-previewgemini-3.1-flash-image-preview
TechnologyGemini 3 ProGemini 3.1 Flash
Resolution1K/2K/4K1K/2K/4K
Price$0.05/image$0.03/image
API UsageIdenticalIdentical
Both share the same API interface. Banana2 is based on Gemini 3.1 Flash architecture with a more affordable price point.
Just change one line of code: replace the model name from gemini-3-pro-image-preview to gemini-3.1-flash-image-preview. Everything else stays the same.
Yes, fully supported! Use this endpoint:
https://api.laozhang.ai/v1beta/models/gemini-3.1-flash-image-preview:generateContent
Supports custom aspect ratios (10 options) and resolutions (1K/2K/4K), same usage as Pro.
Yes! Full text-to-image and image editing features. See the Pro Image Editing docs for details.

📝 Changelog

🆕 Nano Banana2 Released
  • Based on Gemini 3.1 Flash architecture
  • Priced at $0.03/image for better value
  • Usage identical to Nano Banana Pro
  • Supports text-to-image, image editing, 4K resolution