用途
Nano Banana Pro 是一个用于调用 Google Gemini 3 Pro Image(Nano Banana Pro)模型的技能,主要面向 AI 图像生成与编辑场景。它通过一组 Python 脚本封装 API 调用,让使用者可以用命令行或代码方式生成、修改图片。
主要能力
- 文生图:根据文本提示词从零生成图像。
- 图像编辑:用自然语言指令修改已有图片,支持添加、删除、替换、改变风格等操作,并可多轮迭代精修。
- 批量生成:通过 shell 脚本或 Python 封装按顺序生成多张图片。
- 参考图生成:使用最多 14 张参考图维持风格或角色一致性,支持 1K/2K/4K 分辨率。
- 连接测试:提供 test_connection.py 验证 API 凭据。
使用方式
- 配置 API Key:
export GEMINI_API_KEY="your-api-key-here"
API Key 获取地址:https://aistudio.google.com/apikey
- 测试连接:
python scripts/test_connection.py --api-key YOUR_KEY
- 文生图:
python scripts/generate_image.py "A futuristic cityscape at sunset, neon lights, cyberpunk style"
支持参数:--aspect-ratio(1:1 | 3:4 | 4:3 | 9:16 | 16:9,默认 16:9)、--temperature(0.0-1.0,默认 0.7)、--output、--filename、--verbose。
- 图像编辑:
python scripts/edit_image.py "Make the sky more dramatic with storm clouds" input.jpg
支持参数:--aspect-ratio、--temperature、--output、--filename、--verbose。
- 参考图生成:
python scripts/generate_with_references.py "Portrait of elderly craftsman in same artistic style as references" ref1.png ref2.jpg ref3.png --output ./output --filename craftsman
支持参数:--aspect-ratio(含 2:3、3:2、4:5、5:4、21:9 等)、--resolution(1K | 2K | 4K,默认 2K)、--output、--filename、--verbose。
- Python 集成:
from scripts.generate_image import NanoBananaProClient client = NanoBananaProClient(api_key="YOUR_KEY") response = client.generate_image(prompt="Professional product photo", aspect_ratio="1:1", temperature=0.6)
提示词建议
推荐结构:[主体] + [风格/媒介] + [光照细节] + [相机/构图] + [质量修饰词]。
- 具体化描述,避免模糊提示词。
- 使用摄影术语(镜头、光照、机位)。
- 分层描述氛围、材质与情绪。
- 多轮迭代逐步精修。
温度策略:0.3-0.5 适合产品摄影与需要一致性的场景;0.7 为默认平衡值;0.8-0.9 适合创意探索与艺术风格。
宽高比选择:1:1 用于社交媒体与头像;16:9 用于演示与视频缩略图;9:16 用于移动端竖屏;4:3 / 3:4 用于传统摄影;4:5 用于 Instagram(可用 4:3 近似)。
适用场景
- 营销活动主图与社交媒体变体。
- 博客头图与视频缩略图。
- 产品效果图与生活场景图。
- 需要风格或角色一致性的系列图像。
限制与注意事项
- 需要有效的 Gemini API Key。
- 免费层约 100 请求/天,2-5 请求/分钟,1 个并发请求;付费层 60 请求/分钟,10 个并发请求。
- 定价:1K/2K 图像 $0.134/张,4K 图像 $0.24/张,编辑输入图像 $0.0011/张。
- 输入格式(编辑):JPEG、PNG、WebP;输出:JPEG、PNG。
- 模型名称:gemini-3-pro-image-preview;部分地区(欧洲/中东及北非)可能受地理限制。
- 内容政策限制:避免暴力、露骨内容、受版权保护角色及未经许可的真实公众人物。
- 参考图最多 14 张(6 张用于对象,5 张用于角色一致性)。
文档资源
- 提示词指南:references/prompting-guide.md
- API 参考:references/api-reference.md
- 故障排查:references/troubleshooting.md
- 示例提示词:assets/example-prompts.md
- 电影感数字绘画风格:cinematic-style.md
外部链接:
- Google AI Studio:https://aistudio.google.com
- 官方文档:https://ai.google.dev/gemini-api/docs
- 定价页:https://ai.google.dev/gemini-api/docs/pricing
- 模型信息:https://deepmind.google/models/gemini-image/pro/
- Vertex AI 控制台:https://console.cloud.google.com/vertex-ai