UniterRouter
API ReferenceGoogle Compatible

Image Generation (Nano Banana)

Gemini Image Generation API - Create and edit images with Imagen 3. Native multimodal image generation through UniterRouter, supports inpainting and outpainting.

Nano Banana Image Generation

Nano Banana is Google's native image generation model family built into Gemini. Generate, edit, and iterate on images through conversational prompts.

Models: gemini-2.5-flash-image (Nano Banana) for speed, gemini-3-pro-image-preview (Nano Banana Pro) for professional quality up to 4K.

Models

ModelDescriptionMax ResolutionMax Input Images
gemini-2.5-flash-imageFast, high-volume tasks1024px3
gemini-3-pro-image-previewProfessional quality with thinking4K14

Text to Image

import google.generativeai as genai

genai.configure(
    api_key="your_uniterouter_api_key",
    transport="rest",
    client_options={"api_endpoint": "api.uniterouter.ai"}
)

model = genai.GenerativeModel("gemini-2.5-flash-image")

response = model.generate_content(
    "Create a picture of a futuristic city at sunset with flying cars",
    generation_config={"response_modalities": ["IMAGE", "TEXT"]}
)

for part in response.parts:
    if part.text:
        print(part.text)
    elif part.inline_data:
        image = part.as_image()
        image.save("generated_image.png")
import { GoogleGenerativeAI } from "@google/generative-ai";
import * as fs from "fs";

const genAI = new GoogleGenerativeAI("your_uniterouter_api_key", {
  baseUrl: "https://api.uniterouter.ai"
});

const model = genAI.getGenerativeModel({
  model: "gemini-2.5-flash-image",
  generationConfig: { responseModalities: ["IMAGE", "TEXT"] }
});

const result = await model.generateContent(
  "Create a picture of a futuristic city at sunset"
);

for (const part of result.response.candidates[0].content.parts) {
  if (part.text) {
    console.log(part.text);
  } else if (part.inlineData) {
    const buffer = Buffer.from(part.inlineData.data, "base64");
    fs.writeFileSync("generated_image.png", buffer);
  }
}
curl -X POST "https://api.uniterouter.ai/v1beta/models/gemini-2.5-flash-image:generateContent" \
  -H "Content-Type: application/json" \
  -H "x-goog-api-key: $UNITEROUTER_API_KEY" \
  -d '{
    "contents": [{"role": "user", "parts": [{"text": "Create a futuristic city"}]}],
    "generationConfig": {"responseModalities": ["IMAGE", "TEXT"]}
  }'

Image Editing

Edit existing images with text prompts:

import base64

with open("input.jpg", "rb") as f:
    image_data = base64.b64encode(f.read()).decode()

response = model.generate_content([
    {"inline_data": {"mime_type": "image/jpeg", "data": image_data}},
    "Change the sky to a beautiful sunset with orange and pink colors"
])

Configuration

Response Modalities

generation_config = {
    "response_modalities": ["IMAGE", "TEXT"]  # or ["IMAGE"] for image only
}

Aspect Ratio

generation_config = {
    "response_modalities": ["IMAGE"],
    "image_config": {
        "aspect_ratio": "16:9"  # 1:1, 4:3, 3:4, 16:9, 9:16
    }
}

Image Size (Nano Banana Pro)

generation_config = {
    "response_modalities": ["IMAGE"],
    "image_config": {
        "image_size": "4K"  # 1K, 2K, 4K
    }
}

Nano Banana Pro Features

Thinking Mode

Nano Banana Pro uses reasoning before generating for better composition:

model = genai.GenerativeModel("gemini-3-pro-image-preview")
response = model.generate_content(
    "Create a detailed architectural rendering of a modern museum"
)

Google Search Grounding

Generate images based on real-world references:

model = genai.GenerativeModel(
    "gemini-3-pro-image-preview",
    tools=["google_search"]
)
response = model.generate_content(
    "Generate an image of the Eiffel Tower at night with current lighting"
)

Multiple Reference Images

Use up to 14 reference images (5 for high fidelity):

response = model.generate_content([
    image1, image2, image3,
    "Combine elements from these images into a cohesive scene"
])

Use Cases

Use CaseExample Prompt
Product Design"Design a sleek modern smartphone"
Art Creation"Paint an impressionist landscape"
Logo Design"Create a minimalist tech company logo"
Photo Editing"Remove the background and add a beach"
Style Transfer"Convert this photo to anime style"
Text in Images"Create a poster with 'Welcome' text"

Best Practices

  1. Be specific - Detailed prompts get better results
  2. Iterative editing - Use multi-turn for refinements
  3. Generate text first - For text in images, generate text content first
  4. Use references - Provide example images for style guidance

Limitations

  • Supported languages: English, Chinese, Japanese, Korean, and more
  • No audio/video input support
  • All images include SynthID watermark
  • Image count may vary from requested

How is this guide?