nano-banana-pro-grsai
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseNano Banana Pro Image Generation & Editing
Nano Banana Pro 图片生成与编辑
Generate new images or edit existing ones using the grsai.com Nano Banana Pro API.
通过grsai.com的Nano Banana Pro API生成新图片或编辑现有图片。
Usage
使用方法
Run the script using absolute path (do NOT cd to skill directory first):
Generate new image:
bash
uv run scripts/generate_image.py --prompt "your image description" --filename "output-name.png" [--resolution 1K|2K|4K] [--api-key KEY]Edit existing image:
bash
uv run scripts/generate_image.py --prompt "editing instructions" --filename "output-name.png" --input-image "path/to/input.png" [--resolution 1K|2K|4K] [--api-key KEY]Important: Always run from the user's current working directory so images are saved where the user is working, not in the skill directory.
使用绝对路径运行脚本(请勿先切换到skill目录):
生成新图片:
bash
uv run scripts/generate_image.py --prompt "your image description" --filename "output-name.png" [--resolution 1K|2K|4K] [--api-key KEY]编辑现有图片:
bash
uv run scripts/generate_image.py --prompt "editing instructions" --filename "output-name.png" --input-image "path/to/input.png" [--resolution 1K|2K|4K] [--api-key KEY]重要提示: 始终从用户当前工作目录运行脚本,这样图片会保存到用户的工作目录,而非skill目录。
Default Workflow (draft → iterate → final)
默认工作流(草稿 → 迭代 → 最终版)
Goal: fast iteration without burning time on 4K until the prompt is correct.
- Draft (1K): quick feedback loop
uv run scripts/generate_image.py --prompt "<draft prompt>" --filename "yyyy-mm-dd-hh-mm-ss-draft.png" --resolution 1K
- Iterate: adjust prompt in small diffs; keep filename new per run
- If editing: keep the same for every iteration until you're happy.
--input-image
- If editing: keep the same
- Final (4K): only when prompt is locked
uv run scripts/generate_image.py --prompt "<final prompt>" --filename "yyyy-mm-dd-hh-mm-ss-final.png" --resolution 4K
目标:快速迭代,在确定prompt准确前无需花费时间生成4K图片。
- 草稿(1K):快速反馈循环
uv run scripts/generate_image.py --prompt "<draft prompt>" --filename "yyyy-mm-dd-hh-mm-ss-draft.png" --resolution 1K
- 迭代:小幅调整prompt;每次运行使用新文件名
- 若为编辑操作:在满意前,每次迭代使用相同的
--input-image
- 若为编辑操作:在满意前,每次迭代使用相同的
- 最终版(4K):仅在prompt确定后使用
uv run scripts/generate_image.py --prompt "<final prompt>" --filename "yyyy-mm-dd-hh-mm-ss-final.png" --resolution 4K
Resolution Options
分辨率选项
- 1K (default) - ~1024px resolution
- 2K - ~2048px resolution
- 4K - ~4096px resolution
Map user requests to API parameters:
- No mention of resolution →
1K - "low resolution", "1080", "1080p", "1K" →
1K - "2K", "2048", "normal", "medium resolution" →
2K - "high resolution", "high-res", "hi-res", "4K", "ultra" →
4K
- 1K(默认)- 约1024px分辨率
- 2K - 约2048px分辨率
- 4K - 约4096px分辨率
用户请求与API参数映射:
- 未提及分辨率 →
1K - “低分辨率”、“1080”、“1080p”、“1K” →
1K - “2K”、“2048”、“普通”、“中等分辨率” →
2K - “高分辨率”、“high-res”、“hi-res”、“4K”、“超清” →
4K
Aspect Ratio Options
宽高比选项
Pass via . Supported values: (default), , , , , , , , , ,
--aspect-ratioauto1:116:99:164:33:43:22:35:44:521:9通过参数传递。支持的值:(默认)、、、、、、、、、、
--aspect-ratioauto1:116:99:164:33:43:22:35:44:521:9API Key
API密钥
The script checks for API key in this order:
- argument (use if user provided key in chat)
--api-key - environment variable
GRSAI_API_KEY
If neither is available, the script exits with an error message.
脚本按以下顺序检查API密钥:
- 参数(若用户在对话中提供了密钥则使用)
--api-key - 环境变量
GRSAI_API_KEY
若两者均不可用,脚本将退出并显示错误信息。
Troubleshooting
故障排除
| Symptom | Resolution |
|---|---|
| Set |
| Wrong path or unreadable file; verify with |
| HTTP 401 | Wrong or expired API key |
| Content moderation or invalid input; rephrase prompt |
| Install: |
For transient errors (network timeouts, server errors), the script retries automatically with exponential backoff. If all retries fail, surface the error to the user.
| 症状 | 解决方法 |
|---|---|
| 设置 |
| 路径错误或文件不可读;使用 |
| HTTP 401 | API密钥错误或已过期 |
| 内容审核不通过或输入无效;重新调整prompt |
| 安装: |
对于临时错误(网络超时、服务器错误),脚本会自动使用指数退避策略重试。若所有重试均失败,将向用户显示错误信息。
Filename Generation
文件名生成
Generate filenames with the pattern:
yyyy-mm-dd-hh-mm-ss-name.pngFormat:
{timestamp}-{descriptive-name}.png- Timestamp: Current date/time in format (24-hour format)
yyyy-mm-dd-hh-mm-ss - Name: Descriptive lowercase text with hyphens
- Keep the descriptive part concise (1-5 words typically)
- Use context from user's prompt or conversation
- If unclear, use random identifier (e.g., ,
x9k2)a7b3
Examples:
- Prompt "A serene Japanese garden" →
2025-11-23-14-23-05-japanese-garden.png - Prompt "sunset over mountains" →
2025-11-23-15-30-12-sunset-mountains.png - Prompt "create an image of a robot" →
2025-11-23-16-45-33-robot.png - Unclear context →
2025-11-23-17-12-48-x9k2.png
按照以下格式生成文件名:
yyyy-mm-dd-hh-mm-ss-name.png格式:
{时间戳}-{描述性名称}.png- 时间戳:当前日期/时间,格式为(24小时制)
yyyy-mm-dd-hh-mm-ss - 名称:简洁的小写文本,用连字符分隔
- 描述性部分保持简洁(通常1-5个词)
- 参考用户prompt或对话上下文
- 若上下文不明确,使用随机标识符(例如、
x9k2)a7b3
示例:
- Prompt "A serene Japanese garden" →
2025-11-23-14-23-05-japanese-garden.png - Prompt "sunset over mountains" →
2025-11-23-15-30-12-sunset-mountains.png - Prompt "create an image of a robot" →
2025-11-23-16-45-33-robot.png - 上下文不明确 →
2025-11-23-17-12-48-x9k2.png
Image Editing
图片编辑
When the user wants to modify an existing image:
- Check if they provide an image path or reference an image in the current directory
- Use parameter with the path to the image
--input-image - The prompt should contain editing instructions (e.g., "make the sky more dramatic", "remove the person", "change to cartoon style")
- Common editing tasks: add/remove elements, change style, adjust colors, blur background, etc.
当用户想要修改现有图片时:
- 检查用户是否提供了图片路径或引用了当前目录中的图片
- 使用参数传入图片路径
--input-image - Prompt应包含编辑指令(例如“让天空更有氛围感”、“移除人物”、“改为卡通风格”)
- 常见编辑任务:添加/移除元素、更改风格、调整颜色、模糊背景等
Prompt Handling
Prompt处理
For generation: Pass user's image description as-is to . Only rework if clearly insufficient.
--promptFor editing: Pass editing instructions in (e.g., "add a rainbow in the sky", "make it look like a watercolor painting")
--promptPreserve user's creative intent in both cases.
生成图片: 将用户的图片描述直接传入。仅在描述明显不充分时进行调整。
--prompt编辑图片: 在中传入编辑指令(例如“在天空中添加彩虹”、“让它看起来像水彩画”)
--prompt两种情况均需保留用户的创意意图。
Prompt Templates (high hit-rate)
高成功率Prompt模板
Use templates when the user is vague or when edits must be precise.
-
Generation template:
- "Create an image of: <subject>. Style: <style>. Composition: <camera/shot>. Lighting: <lighting>. Background: <background>. Color palette: <palette>. Avoid: <list>."
-
Editing template (preserve everything else):
- "Change ONLY: <single change>. Keep identical: subject, composition/crop, pose, lighting, color palette, background, text, and overall style. Do not add new objects. If text exists, keep it unchanged."
当用户描述模糊或编辑需求需要精准时,使用模板。
-
生成模板:
- “Create an image of: <subject>. Style: <style>. Composition: <camera/shot>. Lighting: <lighting>. Background: <background>. Color palette: <palette>. Avoid: <list>."
-
编辑模板(保留其他所有元素):
- “Change ONLY: <single change>. Keep identical: subject, composition/crop, pose, lighting, color palette, background, text, and overall style. Do not add new objects. If text exists, keep it unchanged."
Output
输出
- Saves image to current directory (or specified path if filename includes directory)
- Script outputs the full path to the generated image
- Do not read the image back - just inform the user of the saved path
- 将图片保存到当前目录(若文件名包含目录,则保存到指定路径)
- 脚本会输出生成图片的完整路径
- 请勿读取生成的图片 - 只需告知用户保存路径即可
Examples
示例
Generate new image:
bash
uv run scripts/generate_image.py --prompt "A serene Japanese garden with cherry blossoms" --filename "2025-11-23-14-23-05-japanese-garden.png" --resolution 4KEdit existing image:
bash
uv run scripts/generate_image.py --prompt "make the sky more dramatic with storm clouds" --filename "2025-11-23-14-25-30-dramatic-sky.png" --input-image "original-photo.jpg" --resolution 2K生成新图片:
bash
uv run scripts/generate_image.py --prompt "A serene Japanese garden with cherry blossoms" --filename "2025-11-23-14-23-05-japanese-garden.png" --resolution 4K编辑现有图片:
bash
uv run scripts/generate_image.py --prompt "make the sky more dramatic with storm clouds" --filename "2025-11-23-14-25-30-dramatic-sky.png" --input-image "original-photo.jpg" --resolution 2K