当前位置: 首页 > Skill >

Nano Banana 2 Image Generation&Editing

Nano Banana 2 Image Generation&Editing

Nano Banana 2 Image Generation&Editing

{"answer":"使用 Google Nano Banana 2 (Imagen) 模型生成与编辑图像——最新高质量图像生成AI。支持文生图及图..."}

1.0.9 2026.11.22 563
获取Skill文件查看使用说明
作 者:叶禾 许可证: 更新时间:2026.11.22
本文目录展开

Nano Banana 2 Image Generation

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.

Required Environment Variables

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.

Provider Selection

  1. If ATLASCLOUD_API_KEY is set → use Atlas Cloud
  2. If GEMINI_API_KEY is set → use Google AI Studio
  3. If both are set → ask the user which provider to use
  4. 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"

Atlas Cloud

  • Async API with polling workflow
  • Flat-rate pricing regardless of resolution
  • Supports 300+ models through one API key

Google AI Studio

  • Direct access via Google's Gemini API
  • Synchronous response with base64 image output

Pricing Comparison

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.

Available Models

Text-to-Image Models

Model ID (Atlas Cloud) Price Description
google/nano-banana-2/text-to-image $0.072/image Stable, production-ready

Image Editing Models

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)

Mode 1: Atlas Cloud API

Setup

The user needs an Atlas Cloud API key. Guide them to:

  1. Sign up at https://www.atlascloud.ai
  2. Go to Console → API Keys → Create new key
  3. Set environment variable: export ATLASCLOUD_API_KEY="your-key"

Script Usage

This skill includes a Python script for image generation. Zero external dependencies required.

List available image models

python scripts/generate_image.py list-models

Generate an image

python scripts/generate_image.py generate 
  --model "MODEL_ID" 
  --prompt "Your prompt here" 
  --output ./output

Upload a local image (for editing)

python scripts/generate_image.py upload ./local-image.jpg

Edit an image

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).

Text-to-Image Generation

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:

  • Poll every 2-3 seconds
  • Check for status: "completed" or "succeeded" means done
  • Check for status: "failed" means error — read the error field
  • Image URLs are in data.outputs[] array

Uploading Local Images

To 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.

Image Editing

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"
  }'

Using Atlas Cloud MCP Tools (if available)

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="...")

Mode 2: Google AI Studio (Official)

Setup

  1. Get API key from https://aistudio.google.com/apikey
  2. Set environment variable: export GEMINI_API_KEY="your-key"

Text-to-Image Generation

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).

Image Editing (Google AI Studio)

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"]
    }
  }'

Python Example (Google AI Studio)

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")

Implementation Guide

When the user asks to generate an image, follow this workflow:

  1. Determine provider: Check which API key is available (see Provider Selection above).

  2. Extract parameters from user request:

    • Prompt: the image description
    • Aspect ratio: infer from context (banner→16:9, portrait→9:16, square→1:1, phone wallpaper→9:16, desktop wallpaper→16:9)
    • Resolution: default 1k unless user wants high quality (then 2k or 4k)
    • For editing: identify source image(s)
  3. Choose model (Atlas Cloud only):

    • Use google/nano-banana-2/text-to-image for generation
    • Use google/nano-banana-2/edit for editing tasks
  4. Execute the API call using bash with curl

  5. For Atlas Cloud: Poll the prediction endpoint every 3 seconds until complete, then download the image

  6. For Google AI Studio: Parse the response, extract base64 image data, save to file

  7. Present the result: Show the saved file path and offer to open it

Prompt Engineering Tips

Share these with users to get better results:

  • Be specific about style: "oil painting", "photorealistic", "anime style", "watercolor"
  • Describe lighting: "golden hour", "studio lighting", "neon glow"
  • Mention composition: "close-up", "wide angle", "bird's eye view"
  • Include mood: "serene", "dramatic", "whimsical"
  • For text in images: Nano Banana 2 handles text rendering well — just include the text in quotes in your prompt

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,034
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,031
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,018
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,017
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,014
OpenAI的Jalapeno芯片未落地,教你分辨300兆瓦算力消息

OpenAI计划在SB Energy租赁的数据中心部署约300兆瓦自研Jalapeno推理芯片,但目前双方仍处于洽谈阶段,交易细节与上线时间表均未公布。本文带你按报道原文核实项目所处阶段,厘清芯片发布、电力功率与实际推理算力的边界,并将融资意向与签约、开工、投运节点分开追踪,避免误将规划容量计入现有算力。

2026.12.02 1,013
Skill 文件
  • SKILL.md
    • Nano Banana 2 Image Generation
    • Required Environment Variables
    • Provider Selection
    • Pricing Comparison
    • Available Models
      • Text-to-Image Models
      • Image Editing Models
    • Mode 1: Atlas Cloud API
      • Setup
      • Script Usage
        • List available image models
        • Generate an image
        • Upload a local image (for editing)
        • Edit an image
      • Text-to-Image Generation
      • Uploading Local Images
      • Image Editing
      • Using Atlas Cloud MCP Tools (if available)
    • Mode 2: Google AI Studio (Official)
      • Setup
      • Text-to-Image Generation
      • Image Editing (Google AI Studio)
      • Python Example (Google AI Studio)
    • Implementation Guide
    • Prompt Engineering Tips
  • 项目或源文件

相关 Skill

更多
Nano Banana 2 — Gemini Image Generation Nano Banana 2 — Gemini Image Generation Gemini image generation, editing, and search-grounded image creation via gemini-3.1-flash-image-preview (Nano Banana 2). USE FOR: - Generating images from te...
WaveSpeedAI Nano Banana 2 Image Generation/Editing WaveSpeedAI Nano Banana 2 Image Generation/Editing 使用谷歌Nano Banana 2模型通过WaveSpeed AI生成和编辑图像,支持文生图及自然语言提示的图像编辑。
Agnes AI 免费图片视频生成 Agnes AI 免费图片视频生成 Generate images and videos using Agnes AI models (agnes-image-2.0-flash, agnes-image-2.1-flash, agnes-video-v2.0). Trigger when user wants to generate images from text, edit images, create videos from text or images, or mentions '生图', '生视频', 'image generation', 'video generation', 'Agnes AI', 'agnes-ai.com'.
Nanobanana Nanobanana Nano Banana 2 Pro AI 图像生成工具。触发条件:用户提到“生图”“生成图片”“AI画图”“nano banana”“nanobanana”,或需调用 Nano Banana API 生成/编辑图片。支持文本生成图片、以图生图的图片编辑及多模态对话。
Nano Banana Image Skills Nano Banana Image Skills 使用 Google Gemini 模型(Nano Banana 2 / gemini-3-pro-image-preview)生成图像。适用于用户要求创建、生成或制作图片时。