Nano Banana 2 Image Generation & Editing
Generate and edit images using Google's Nano Banana 2 (Imagen) — the latest AI image generation model with industry-leading text rendering, multi-object composition, and photorealistic output.
This skill supports two providers. Choose based on which API key is available.
Provider Selection
- If
ATLASCLOUD_API_KEYis set → use Atlas Cloud - If
GEMINI_API_KEYis set → use Google AI Studio - If both are set → prefer Atlas Cloud (flat-rate pricing)
- If neither is set → ask the user to configure one:
- Atlas Cloud: Sign up at https://www.atlascloud.ai, Console → API Keys → Create key, then export ATLASCLOUD_API_KEY="your-key" - Google AI Studio: Get key from https://aistudio.google.com/apikey, then export GEMINI_API_KEY="your-key"
Pricing Comparison
| Resolution | Google AI Studio | fal.ai | Atlas Cloud Standard | Atlas Cloud Developer |
|---|---|---|---|---|
| 1K (default) | $0.067 | $0.08 | $0.072 | $0.056 |
| 2K | $0.101 | $0.12 | $0.072 | $0.056 |
| 4K | $0.151 | $0.16 | $0.072 | $0.056 |
Atlas Cloud uses flat-rate pricing — same price regardless of resolution. Google AI Studio uses token-based pricing that scales with resolution. At 4K, Atlas Cloud Developer tier is up to 63% cheaper than Google AI Studio.
Available Models
Atlas Cloud Models
| Model ID | Tier | Price | Best For |
|---|---|---|---|
google/nano-banana-2/text-to-image | Standard | $0.072/image | Production, stable output |
google/nano-banana-2/text-to-image-developer | Developer | $0.056/image | Prototyping, experiments |
google/nano-banana-2/edit | Standard | $0.072/image | Production editing |
google/nano-banana-2/edit-developer | Developer | $0.056/image | Budget editing, experiments |
Google AI Studio Model
| Model ID | Price | Notes |
|---|---|---|
gemini-3.1-flash-image-preview | Token-based (~$0.067-$0.151/image) | Handles both generation and editing |
Mode 1: Atlas Cloud API
Setup
- Sign up at https://www.atlascloud.ai
- Console → API Keys → Create new key
- Set env:
export ATLASCLOUD_API_KEY="your-key"
Parameters
Text-to-Image:
| Parameter | Type | Required | Default | Options |
|---|---|---|---|---|
prompt | string | Yes | - | Image description |
aspect_ratio | string | No | 1:1 | 1:1, 3:2, 2:3, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9 |
resolution | string | No | 1k | 1k, 2k, 4k |
output_format | string | No | png | png, jpeg |
seed | integer | No | random | For reproducible results |
Image Editing — same as above plus:
| Parameter | Type | Required | Description |
|---|---|---|---|
images | array of strings | Yes | 1-14 image URLs to edit |
Workflow: Submit → Poll → Download
# Step 1: Submit
curl -s -X POST "https://api.atlascloud.ai/api/v1/model/generateImage" \
-H "Authorization: Bearer $ATLASCLOUD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "google/nano-banana-2/text-to-image",
"prompt": "A serene Japanese garden with cherry blossoms",
"aspect_ratio": "16:9",
"resolution": "2k"
}'
# Returns: { "code": 200, "data": { "id": "prediction-id" } }
# Step 2: Poll (every 3 seconds until "completed" or "succeeded")
curl -s "https://api.atlascloud.ai/api/v1/model/prediction/{prediction-id}" \
-H "Authorization: Bearer $ATLASCLOUD_API_KEY"
# Returns: { "code": 200, "data": { "status": "completed", "outputs": ["https://...url..."] } }
# Step 3: Download
curl -o output.png "IMAGE_URL_FROM_OUTPUTS"Image editing example:
curl -s -X POST "https://api.atlascloud.ai/api/v1/model/generateImage" \
-H "Authorization: Bearer $ATLASCLOUD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "google/nano-banana-2/edit",
"prompt": "Change the sky to a dramatic sunset",
"images": ["https://example.com/photo.jpg"],
"resolution": "2k"
}'Polling logic:
processing/starting/running→ wait 3s, retrycompleted/succeeded→ done, get URL fromdata.outputs[]failed→ error, readdata.error
Atlas Cloud MCP Tools (if available)
If the Atlas Cloud MCP server is configured, use built-in tools:
atlas_quick_generate(model_keyword="nano banana 2", type="Image", prompt="...")
atlas_generate_image(model="google/nano-banana-2/text-to-image", params={...})
atlas_get_prediction(prediction_id="...")Mode 2: Google AI Studio API
Setup
- Get API key from https://aistudio.google.com/apikey
- Set env:
export GEMINI_API_KEY="your-key"
Parameters
| Parameter | Location | Options |
|---|---|---|
aspectRatio | generationConfig.imageConfig | 1:1, 1:4, 1:8, 2:3, 3:2, 3:4, 4:1, 4:3, 4:5, 5:4, 8:1, 9:16, 16:9, 21:9 |
imageSize | generationConfig.imageConfig | 512px, 1K, 2K, 4K (uppercase K required) |
responseModalities | generationConfig | ["TEXT", "IMAGE"] for image output |
Text-to-Image
curl -s -X POST \
"https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [{"parts": [{"text": "A serene Japanese garden with cherry blossoms"}]}],
"generationConfig": {
"responseModalities": ["TEXT", "IMAGE"],
"imageConfig": {"aspectRatio": "16:9", "imageSize": "2K"}
}
}'Response: base64 image in candidates[0].content.parts[]. Text parts have .text, image parts have .inline_data.mime_type and .inline_data.data.
Save the image:
# Extract base64 data from response and decode
echo "$BASE64_DATA" | base64 -d > output.pngImage Editing (Google AI Studio)
curl -s -X POST \
"https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [{"parts": [
{"text": "Change the sky to a dramatic sunset"},
{"inline_data": {"mime_type": "image/png", "data": "BASE64_ENCODED_IMAGE"}}
]}],
"generationConfig": {"responseModalities": ["TEXT", "IMAGE"]}
}'To encode a local image for editing:
BASE64_IMAGE=$(base64 -i input.png)Python Example
from google import genai
from google.genai import types
client = genai.Client()
response = client.models.generate_content(
model="gemini-3.1-flash-image-preview",
contents="A serene Japanese garden with cherry blossoms",
config=types.GenerateContentConfig(
response_modalities=['TEXT', 'IMAGE'],
image_config=types.ImageConfig(aspect_ratio="16:9", image_size="2K"),
)
)
for part in response.parts:
if part.text:
print(part.text)
elif image := part.as_image():
image.save("output.png")Implementation Guide
- Determine provider: Check which API key is available (see Provider Selection above).
- Extract parameters:
- Prompt: the image description - Aspect ratio: infer from context (banner→16:9, portrait→9:16, square→1:1, phone wallpaper→9:16, desktop→16:9) - Resolution: default 1k, use 2k/4k for high quality - For editing: identify source image URL(s) or local file path
- Choose model tier (Atlas Cloud only):
- Standard for production use - Developer if user wants to save costs or is experimenting
- Execute:
- Atlas Cloud: POST to generateImage API → poll prediction → download result - Google AI Studio: POST to generateContent API → parse base64 from response → save to file
- Present result: show file path, offer to open
Prompt Tips
- Style: "oil painting", "photorealistic", "anime style", "watercolor"
- Lighting: "golden hour", "studio lighting", "neon glow"
- Composition: "close-up", "wide angle", "bird's eye view"
- Mood: "serene", "dramatic", "whimsical"
- Text in images: Nano Banana 2 renders text well — include it in quotes in your prompt