Skip to content

NanoBanana NanoBanana Image Generation Deployment Guide ​

Call Gemini's native image generation API through IKunCode

ResourceURL
IKunCode platformapi.ikuncode.cc

📋 Overview

NanoBanana is the Gemini image generation model family offered by IKunCode. You can call it directly with an IKunCode API Key — no VPN, no Google account required.

🎯 Model Overview ​

IKunCode offers two NanoBanana models:

ModelModel IDFeaturesUse Cases
NanoBananaProgemini-3-pro-image-previewBest quality, supports high-resolution outputHigh-quality posters, commercial assets, detailed creative work
NanoBanana2gemini-3.1-flash-image-previewFast and affordableQuick previews, batch generation, everyday use

💡 How to choose

  • For the best image quality: choose NanoBananaPro (Pro version)
  • For speed and cost-effectiveness: choose NanoBanana2 (Flash version)

📐 Supported Aspect Ratios ​

Both models support the following 10 aspect ratios:

Aspect RatioDescriptionAspect RatioDescription
1:1Square image3:2Common camera ratio (landscape)
16:9Standard landscape2:3Common camera ratio (portrait)
9:16Standard portrait21:9Ultrawide
4:3Classic landscape5:4Monitor ratio (landscape)
3:4Classic portrait4:5Monitor ratio (portrait)

📏 Supported Resolutions ​

Each aspect ratio supports three resolution tiers:

1K Resolution (Quick Preview) ​

Aspect RatioResolutionAspect RatioResolution
1:11024×10243:21232×816
16:91376×7682:3816×1232
9:16768×137621:91584×672
4:31200×8965:41136×896
3:4896×12004:5896×1136
Aspect RatioResolutionAspect RatioResolution
1:12048×20483:22464×1632
16:92752×15362:31632×2464
9:161536×275221:93168×1344
4:32400×17925:42272×1792
3:41792×24004:51792×2272

4K Resolution (Ultra HD) ​

Aspect RatioResolutionAspect RatioResolution
1:14096×40963:24928×3264
16:95504×30722:33264×4928
9:163072×550421:96336×2688
4:34800×35845:44544×3584
3:43584×48004:53584×4544

🔧 API Request Format ​

NanoBanana uses the Google native format API, which differs from the OpenAI format.

Basic Request Structure ​

json
{
  "contents": [{
    "parts": [
      { "text": "Your image description" }
    ]
  }],
  "generationConfig": {
    "responseModalities": ["IMAGE"],
    "imageConfig": {
      "aspectRatio": "16:9",
      "image_size": "2K"
    }
  }
}

Parameters ​

ParameterDescriptionAllowed Values
responseModalitiesResponse type, must be image["IMAGE"]
aspectRatioAspect ratio1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3, 21:9, 5:4, 4:5
image_sizeResolution tier1K, 2K, 4K

API Endpoint ​

POST https://api.ikuncode.cc/v1beta/models/{ModelID}:generateContent
  • NanoBananaPro: gemini-3-pro-image-preview
  • NanoBanana2: gemini-3.1-flash-image-preview

📝 Sample Code ​

cURL Example ​

bash
curl -X POST "https://api.ikuncode.cc/v1beta/models/gemini-3-pro-image-preview:generateContent" \
  -H "Authorization: Bearer sk-your-IKunCode-key" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [{
      "parts": [
        {"text": "A cute kitten sitting in a garden, oil painting style, HD, rich detail"}
      ]
    }],
    "generationConfig": {
      "responseModalities": ["IMAGE"],
      "imageConfig": {
        "aspectRatio": "16:9",
        "image_size": "2K"
      }
    }
  }'

Python Example ​

python
import requests
import base64

API_KEY = "sk-your-IKunCode-key"
API_URL = "https://api.ikuncode.cc/v1beta/models/gemini-3-pro-image-preview:generateContent"

payload = {
    "contents": [{
        "parts": [
            {"text": "A cute kitten sitting in a garden, oil painting style, HD, rich detail"}
        ]
    }],
    "generationConfig": {
        "responseModalities": ["IMAGE"],
        "imageConfig": {
            "aspectRatio": "16:9",
            "image_size": "2K"
        }
    }
}

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

response = requests.post(API_URL, headers=headers, json=payload, timeout=600)

if response.status_code == 200:
    data = response.json()
    image_base64 = data["candidates"][0]["content"]["parts"][0]["inlineData"]["data"]

    # Save the image
    with open("output.png", "wb") as f:
        f.write(base64.b64decode(image_base64))
    print("Image saved to output.png")
else:
    print(f"Request failed: {response.status_code}")
    print(response.text)

Node.js Example ​

javascript
const fs = require('fs');

const API_KEY = 'sk-your-IKunCode-key';
const API_URL = 'https://api.ikuncode.cc/v1beta/models/gemini-3-pro-image-preview:generateContent';

async function generateImage() {
  const response = await fetch(API_URL, {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      contents: [{
        parts: [
          { text: 'A cute kitten sitting in a garden, oil painting style, HD, rich detail' }
        ]
      }],
      generationConfig: {
        responseModalities: ['IMAGE'],
        imageConfig: {
          aspectRatio: '16:9',
          image_size: '2K'
        }
      }
    })
  });

  const data = await response.json();
  const imageBase64 = data.candidates[0].content.parts[0].inlineData.data;

  fs.writeFileSync('output.png', Buffer.from(imageBase64, 'base64'));
  console.log('Image saved to output.png');
}

generateImage().catch(console.error);

🖼️ Image-to-Image Editing ​

NanoBananaPro also supports image-to-image editing. Upload an image along with an editing instruction to modify it.

json
{
  "contents": [{
    "parts": [
      {
        "inlineData": {
          "mimeType": "image/png",
          "data": "Base64-encoded string of the image"
        }
      },
      { "text": "Change the background to a starry sky, keep the person unchanged" }
    ]
  }],
  "generationConfig": {
    "responseModalities": ["IMAGE"],
    "imageConfig": {
      "aspectRatio": "16:9",
      "image_size": "2K"
    }
  }
}

💡 Tips for image-to-image editing

  • Make editing instructions specific and clear — spell out what to keep and what to change
  • Supports background swaps, style changes, adding elements, watermark removal, and more
  • Encode the image as Base64 and place it in the inlineData.data field

🤖 Using It Inside Claude Code ​

If you have installed the ikunimage Skill, you can generate images with natural language directly in a Claude Code conversation — no manual API calls needed.

> Use ikun to draw a cyberpunk city nightscape, 16:9 ratio, 2K resolution

> ikun generate an ink-wash landscape painting, portrait 9:16

> Use ikun to edit this image /path/to/image.png and change the background to a sunset by the sea

For detailed installation and usage instructions, see: ikunimage AI Image Generation

⏱️ Performance Tips ​

Processing time varies significantly across resolutions — set a reasonable timeout:

ResolutionRecommended TimeoutUse Case
1K360 seconds (6 minutes)Quick previews, testing
2K600 seconds (10 minutes)Everyday use (recommended)
4K1200 seconds (20 minutes)Ultra HD output, commercial use

Bandwidth Considerations ​

Image data is transmitted as Base64, which results in large payloads:

  • Use a stable, high-speed network connection
  • The Base64 payload of a 4K image can exceed 10MB
  • Avoid generating 4K images during peak network hours

⚠️ Notes ​

  1. API Key: create an API Key with image model support on the IKunCode platform
  2. API format: NanoBanana uses the Google native format, not OpenAI-compatible — keep this in mind
  3. Resolution vs. time: higher resolutions take longer to generate; choose based on your real needs
  4. Text rendering: rendering Chinese text inside images is supported (e.g. signs, poster copy) — just include it in your prompt
  5. Pricing: prices vary by model and resolution; see the IKunCode pricing page for details

Friendly, helpful, and made with care