360 Secure SkillHub
360 安全技能中心

Nano Banana 2

核心功能:通过NanoPhoto.AI的Nano Banana 2 API实现文本生成图片、图片转图片编辑,支持调整画幅比例、图像画质,可选谷歌搜索增强提示,可查询生成任务状态、同步轮询进度。典型场景:用户有AI生成/编辑图片需求,或提及Nano Banana 2时使用。输入为文本提示、公开图片URL等参数,输出含生成的图片链接、任务ID等。需先在平台安全环境配置NANOPHOTO_API_KEY,不可直接粘贴密钥到聊天。

nanophotohq
nanophotohq
热度 50.32
最近更新 2026-05-11 17:35:38
分类:创作依赖:代码执行 / 第三方 API应用场景:图像生成 / image-editing

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add nanophoto-nano-banana-2
Metadata
name
nano-banana-2
description
Generate or edit images with the NanoPhoto.AI Nano Banana 2 API. Use when: (1) User wants text-to-image generation, (2) User wants image-to-image editing with public image URLs, (3) User mentions Nano Banana 2, AI image generation, image editing, Google Search enhanced prompts, or checking Nano Banana generation status. Supports aspect ratio, quality, optional Google Search prompt enhancement, status checks, and optional in-process polling from a single bundled script. Prerequisite: Obtain an API key at https://nanophoto.ai/settings/apikeys and configure env.NANOPHOTO_API_KEY.
metadata
{"openclaw":{"homepage":"https://nanophoto.ai","requires":{"env":["NANOPHOTO_API_KEY"]},"primaryEnv":"NANOPHOTO_API_KEY"}}

Nano Banana 2

Generate or edit images through the NanoPhoto.AI Nano Banana 2 API.

Prerequisites

  1. Obtain an API key at: https://nanophoto.ai/settings/apikeys
  2. Configure NANOPHOTO_API_KEY before using the skill.
  3. Do not paste the API key into chat; store it in the platform's secure env setting for this skill.

Preferred OpenClaw setup:

  • Open the skill settings for this skill
  • Add an environment variable named NANOPHOTO_API_KEY
  • Paste the API key as its value

Equivalent config shape:

{
  "skills": {
    "entries": {
      "nano-banana-2": {
        "enabled": true,
        "env": {
          "NANOPHOTO_API_KEY": "your_api_key_here"
        }
      }
    }
  }
}

Other valid ways to provide the key:

  • Shell: export NANOPHOTO_API_KEY="your_api_key_here"
  • Tool-specific env config: any runtime that injects NANOPHOTO_API_KEY
  • OpenClaw config fallback: the bundled script also falls back to ~/.openclaw/openclaw.json at skills.entries.nano-banana-2.env.NANOPHOTO_API_KEY

Credential declaration summary:

  • Primary credential: NANOPHOTO_API_KEY
  • Resolution order in the bundled script: --api-key → NANOPHOTO_API_KEY environment variable → ~/.openclaw/openclaw.json skill env
  • No unrelated credentials are required

Recommended workflow

  1. Collect the user's prompt.
  2. Decide whether the request is generate (text-to-image) or edit (image-to-image).
  3. Choose aspectRatio, imageQuality, and whether googleSearch should be enabled.
  4. For edit mode, require one to fourteen public image URLs.
  5. Submit the generation request.
  6. If the user wants synchronous progress output in the same process, use submit --follow.
  7. Poll every 3-5 seconds until completed or failed.
  8. Return the final imageUrl, generationId, and progress details when available.

Parameter guidance

  • mode
    • generate: text-to-image
    • edit: image-to-image; requires inputImageUrls
  • aspectRatio
    • 16:9
    • 9:16
    • 4:3
    • 3:4
  • imageQuality
    • 1K: default, lowest cost
    • 2K: higher detail
    • 4K: highest detail and highest cost
  • googleSearch
    • Disabled by default
    • Enable only when web context is likely to improve specificity

Preferred commands

Use the single bundled script with subcommands.

Submit text-to-image generation

python3 scripts/nano_banana_2.py submit \
  --prompt "A futuristic cityscape at sunset with flying cars and neon lights" \
  --mode generate \
  --aspect-ratio 16:9 \
  --image-quality 2K

Submit with Google Search enhancement and in-process polling

python3 scripts/nano_banana_2.py submit \
  --prompt "The latest Tesla Cybertruck in a desert landscape" \
  --mode generate \
  --aspect-ratio 16:9 \
  --image-quality 2K \
  --google-search \
  --follow

Submit image-to-image editing

python3 scripts/nano_banana_2.py submit \
  --prompt "Transform this photo into a watercolor painting style" \
  --mode edit \
  --aspect-ratio 16:9 \
  --image-quality 1K \
  --input-image-url https://static.nanophoto.ai/demo/nano-banana-pro.webp

Check status of an existing generation

python3 scripts/nano_banana_2.py status --generation-id abc123xyz

Script behavior

The bundled script resolves credentials in this order: --api-key, then NANOPHOTO_API_KEY from the environment, then ~/.openclaw/openclaw.json at skills.entries.nano-banana-2.env.NANOPHOTO_API_KEY.

Subcommands:

  • submit: submit a generation task
  • submit --follow: submit and keep polling in the same process
  • status: check an existing generationId

Cross-platform note:

  • Use python3 on macOS/Linux.
  • Use python on Windows unless python3 is available.
  • The script uses Python's standard HTTP client and does not require curl.
  • Use --json-only when another script/tool needs raw JSON output.
  • Use --poll-interval to override the default 4-second polling interval.
  • Default max wait is 180 seconds.

Manual API calls

Submit generation

curl -X POST "https://nanophoto.ai/api/nano-banana-2/generate" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $NANOPHOTO_API_KEY" \
  --data-raw '{
    "prompt": "A futuristic cityscape at sunset with flying cars and neon lights",
    "mode": "generate",
    "aspectRatio": "16:9",
    "imageQuality": "2K"
  }'

Check status

curl -X POST "https://nanophoto.ai/api/nano-banana-2/check-status" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $NANOPHOTO_API_KEY" \
  --data-raw '{"generationId": "abc123xyz"}'

Error handling

errorCode Cause Action
LOGIN_REQUIRED Invalid or missing API key Verify key at https://nanophoto.ai/settings/apikeys
API_KEY_RATE_LIMIT_EXCEEDED Rate limit exceeded Wait and retry
INSUFFICIENT_CREDITS Not enough credits Top up credits
INVALID_PROMPT Missing or invalid prompt Ask for a valid prompt
MISSING_INPUT_IMAGE Edit mode missing images Ask for public image URLs
TOO_MANY_IMAGES Too many images provided Limit to 14 public image URLs
IMAGE_URLS_REQUIRED API needs inputImageUrls Do not send local files or base64
GENERATION_FAILED Server-side generation error Retry or simplify the prompt
NOT_FOUND Unknown generation ID Re-submit or verify the ID
FORBIDDEN Generation not owned by caller Verify the account

Bundled files

  • scripts/nano_banana_2.py: single entry point for submit, status, and optional in-process polling
  • references/api.md: condensed API reference, parameters, and error behavior