Nano Banana 2
Generate or edit images through the NanoPhoto.AI Nano Banana 2 API.
Prerequisites
- Obtain an API key at: https://nanophoto.ai/settings/apikeys
- Configure
NANOPHOTO_API_KEYbefore using the skill. - 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.jsonatskills.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_KEYenvironment variable →~/.openclaw/openclaw.jsonskill env - No unrelated credentials are required
Recommended workflow
- Collect the user's prompt.
- Decide whether the request is
generate(text-to-image) oredit(image-to-image). - Choose
aspectRatio,imageQuality, and whethergoogleSearchshould be enabled. - For edit mode, require one to fourteen public image URLs.
- Submit the generation request.
- If the user wants synchronous progress output in the same process, use
submit --follow. - Poll every 3-5 seconds until
completedorfailed. - Return the final
imageUrl,generationId, and progress details when available.
Parameter guidance
modegenerate: text-to-imageedit: image-to-image; requiresinputImageUrls
aspectRatio16:99:164:33:4
imageQuality1K: default, lowest cost2K: higher detail4K: 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 tasksubmit --follow: submit and keep polling in the same processstatus: check an existinggenerationId
Cross-platform note:
- Use
python3on macOS/Linux. - Use
pythonon Windows unlesspython3is available. - The script uses Python's standard HTTP client and does not require
curl. - Use
--json-onlywhen another script/tool needs raw JSON output. - Use
--poll-intervalto 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 pollingreferences/api.md: condensed API reference, parameters, and error behavior
