Generate and edit images using Google's Nano Banana 2 (Imagen) model via two provider options.
> Privacy & data note: This skill sends text prompts and image data to third-party APIs (Atlas Cloud at api.atlascloud.ai or Google AI Studio at generativelanguage.googleapis.com) for image generation. For image editing via Atlas Cloud, local files are uploaded to Atlas Cloud's temporary storage to obtain a URL — the agent MUST ask the user for explicit confirmation before uploading any local file. Uploaded files are temporary and may be cleaned up periodically. No data is stored locally beyond the downloaded output files.
| Variable | Required | Description |
|---|---|---|
| ---------- | :--------: | ------------- |
ATLASCLOUD_API_KEY | If using Atlas Cloud | Atlas Cloud API key for image generation |
GEMINI_API_KEY | If using Google AI Studio | Google AI Studio API key |
At least one of the above must be set. If both are set, ask the user which provider to use.
ATLASCLOUD_API_KEY is set → use Atlas CloudGEMINI_API_KEY is set → use Google AI Studioexport ATLASCLOUD_API_KEY="your-key"export GEMINI_API_KEY="your-key"Atlas Cloud
Google AI Studio
| Resolution | Google AI Studio | Atlas Cloud | Savings |
|---|---|---|---|
| :----------: | :----------------: | :-----------: | :-------: |
| 1K (default) | $0.080/image | $0.072/image | 10% off |
| 2K | $0.080/image | $0.072/image | 10% off |
| 4K | $0.080/image | $0.072/image | 10% off |
Atlas Cloud is 10% cheaper than Google AI Studio across all resolutions, with flat-rate pricing regardless of resolution.
| Model ID (Atlas Cloud) | Price | Description |
|---|---|---|
| ------------------------ | ------- | ------------- |
google/nano-banana-2/text-to-image | $0.072/image | Stable, production-ready |
| Model ID (Atlas Cloud) | Price | Description |
|---|---|---|
| ------------------------ | ------- | ------------- |
google/nano-banana-2/edit | $0.072/image | Stable image editing |
Google AI Studio model: gemini-3.1-flash-image-preview (handles both generation and editing)
The user needs an Atlas Cloud API key. Guide them to:
export ATLASCLOUD_API_KEY="your-key"This skill includes a Python script for image generation. Zero external dependencies required.
python scripts/generate_image.py list-models
python scripts/generate_image.py generate \
--model "MODEL_ID" \
--prompt "Your prompt here" \
--output ./output
python scripts/generate_image.py upload ./local-image.jpg
python scripts/generate_image.py generate \
--model "MODEL_ID" \
--prompt "Edit instruction" \
--image "https://...uploaded-url..."
Run python scripts/generate_image.py generate --help for all options. Extra model params can be passed as key=value (e.g. aspect_ratio=16:9 resolution=2k).
Parameters:
| Parameter | Type | Required | Default | Options |
|---|---|---|---|---|
| ----------- | ------ | ---------- | --------- | --------- |
prompt | string | Yes | - | Text description of the image |
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 |
Workflow — submit, poll, download:
# Step 1: Submit generation request
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"
}'
# Response: { "code": 0, "data": { "id": "prediction-id" } }
# Step 2: Poll for result (repeat until status is "completed" or "succeeded")
curl -s "https://api.atlascloud.ai/api/v1/model/prediction/{prediction-id}" \
-H "Authorization: Bearer $ATLASCLOUD_API_KEY"
# Response when done: { "code": 0, "data": { "status": "completed", "outputs": ["https://...image-url..."] } }
# Step 3: Download the image
curl -o output.png "IMAGE_URL_FROM_OUTPUTS"
When implementing this workflow programmatically:
error fielddata.outputs[] arrayTo use local images for editing, first upload them to get a URL. The agent MUST confirm with the user before uploading any local file (e.g., "I'll upload /path/to/image.jpg to Atlas Cloud for editing. Proceed?").
curl -s -X POST "https://api.atlascloud.ai/api/v1/model/uploadMedia" \
-H "Authorization: Bearer $ATLASCLOUD_API_KEY" \
-F "file=@/path/to/local/image.jpg"
# Returns: { "code": 200, "data": { "download_url": "https://...url...", "filename": "image.jpg", "size": 123456 } }
Use the returned download_url as the image URL in the images array for editing requests.
> Note: Uploaded files are for temporary use with Atlas Cloud generation tasks only. URLs may expire after a period of time.
Same workflow as text-to-image, but with additional images parameter:
| Parameter | Type | Required | Default | Options |
|---|---|---|---|---|
| ----------- | ------ | ---------- | --------- | --------- |
prompt | string | Yes | - | Editing instruction |
images | array of strings | Yes | - | 1-14 image URLs to edit |
aspect_ratio | string | No | - | Same options as above |
resolution | string | No | 1k | 1k, 2k, 4k |
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"
}'
If the user has the Atlas Cloud MCP server configured, use the built-in tools directly:
# Quick generate
atlas_quick_generate(model_keyword="nano banana 2", type="Image", prompt="...")
# Or with specific model
atlas_generate_image(model="google/nano-banana-2/text-to-image", params={...})
# Check result
atlas_get_prediction(prediction_id="...")
export GEMINI_API_KEY="your-key"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"
}
}
}'
Parameters for Google AI Studio:
| 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 |
Response handling:
The response contains base64-encoded image data in candidates[0].content.parts[]. Loop through parts — text parts have .text, image parts have .inline_data.mime_type and .inline_data.data (base64).
Include the source image as base64 inline_data alongside the text prompt:
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"]
}
}'
from google import genai
from google.genai import types
import base64
client = genai.Client()
# Text-to-Image
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")
When the user asks to generate an image, follow this workflow:
google/nano-banana-2/text-to-image for generationgoogle/nano-banana-2/edit for editing tasksShare these with users to get better results:
共 3 个版本