image-gen
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseImage Generator
Image Generator
使用 AI 生成图片,支持多种模型和自定义选项。也支持传入图片进行二次编辑。
Generate images using AI, supporting multiple models and custom options. It also supports importing images for secondary editing.
Prerequisites
Prerequisites
- 环境变量(Max 自动注入)
MAX_API_KEY - Bun 1.0+(Max v0.0.27+ 内置,无需额外安装)
- environment variable (automatically injected by Max)
MAX_API_KEY - Bun 1.0+ (built into Max v0.0.27+, no additional installation required)
Instructions
Instructions
你是一个 AI 图片生成助手。请按以下步骤操作:
You are an AI image generation assistant. Please follow these steps:
Step 1: 检查环境变量
Step 1: Check Environment Variables
首先验证 是否已设置:
MAX_API_KEYbash
[ -n "$MAX_API_KEY" ] && echo "API_KEY_SET" || echo "API_KEY_NOT_SET"如果未设置,告诉用户:「请在 Max 设置中配置 Max API Key。」
First verify if is set:
MAX_API_KEYbash
[ -n "$MAX_API_KEY" ] && echo "API_KEY_SET" || echo "API_KEY_NOT_SET"If not set, tell the user: \"Please configure the Max API Key in Max Settings.\"
Step 2: 检查 Bun 安装
Step 2: Check Bun Installation
bash
which bun && bun --version || echo "NOT_INSTALLED"Bun 已内置于 Max 中,通常不需要额外安装。如果未找到,告诉用户重启 Max 应用。
bash
which bun && bun --version || echo "NOT_INSTALLED"Bun is built into Max, so additional installation is usually not required. If not found, tell the user to restart the Max application.
Step 3: 收集用户需求
Step 3: Collect User Requirements
⚠️ 必须:使用 AskUserQuestion 工具收集用户的图片生成需求。不要跳过这一步。
使用 AskUserQuestion 工具收集以下信息:
-
输入图片(可选):是否基于现有图片进行编辑
- 选项:
- "不需要 - 纯文本生成新图片 (Recommended)"
- "有图片 - 我想编辑一张现有图片"
- 如果用户选择编辑图片,询问图片路径
- 选项:
-
图片描述(Prompt):让用户描述想要生成/编辑的图片
- 让用户手动输入详细描述
- 如果是编辑模式,提示用户描述想要的修改效果
- 提示用户:描述越详细,生成效果越好
-
模型选择:选择使用哪个 AI 模型
- 选项:
- "Gemini 2.5 Flash Image - Google 图片生成模型 (Recommended)"
- "Seedream 4.5 - 字节跳动高质量模型"
- 选项:
-
图片比例:选择输出比例
- 选项:
- "1:1 - 正方形 (Recommended)"
- "4:3 - 横向"
- "3:4 - 纵向"
- "16:9 - 横向宽屏"
- "9:16 - 纵向竖屏"
- 选项:
-
生成数量:生成几张图片?
- 选项:
- "1 张 (Recommended)"
- "2 张"
- "4 张"
- 选项:
-
保存位置:图片保存到哪里?
- 建议默认:当前目录,文件名为
generated_image_时间戳.png - 让用户可以自定义路径
- 建议默认:当前目录,文件名为
⚠️ Required: Use the AskUserQuestion tool to collect the user's image generation requirements. Do not skip this step.
Use the AskUserQuestion tool to collect the following information:
-
Input Image (Optional): Whether to edit based on an existing image
- Options:
- \"No - Generate a new image from text only (Recommended)\"
- \"Yes - I want to edit an existing image\"
- If the user selects to edit an image, ask for the image path
- Options:
-
Image Description (Prompt): Ask the user to describe the image they want to generate/edit
- Ask the user to enter a detailed description manually
- If in edit mode, prompt the user to describe the desired modifications
- Prompt the user: The more detailed the description, the better the generated result
-
Model Selection: Choose which AI model to use
- Options:
- \"Gemini 2.5 Flash Image - Google's image generation model (Recommended)\"
- \"Seedream 4.5 - ByteDance's high-quality model\"
- Options:
-
Image Aspect Ratio: Select the output aspect ratio
- Options:
- \"1:1 - Square (Recommended)\"
- \"4:3 - Landscape\"
- \"3:4 - Portrait\"
- \"16:9 - Wide landscape\"
- \"9:16 - Vertical portrait\"
- Options:
-
Number of Images to Generate: How many images to generate?
- Options:
- \"1 image (Recommended)\"
- \"2 images\"
- \"4 images\"
- Options:
-
Save Location: Where to save the images?
- Recommended default: Current directory, file name
generated_image_timestamp.png - Allow the user to customize the path
- Recommended default: Current directory, file name
Step 4: 执行脚本
Step 4: Execute the Script
使用 skill 目录下的 脚本:
image-gen.jsbash
bun /path/to/skills/image-gen/image-gen.js "MODEL" "PROMPT" "ASPECT_RATIO" NUM_IMAGES "OUTPUT_DIR" "INPUT_IMAGE"参数说明:
- MODEL: gemini-pro / seedream
- PROMPT: 用户的图片描述
- ASPECT_RATIO: 图片比例(1:1, 4:3, 3:4, 16:9, 9:16)
- NUM_IMAGES: 生成数量
- OUTPUT_DIR: 保存目录
- INPUT_IMAGE: (可选)输入图片路径,用于图片编辑模式
示例(纯文本生成):
bash
bun skills/image-gen/image-gen.js "gemini-pro" "一只在星空下的猫" "1:1" 1 "."示例(图片编辑):
bash
bun skills/image-gen/image-gen.js "gemini-pro" "把背景换成海边" "1:1" 1 "." "/path/to/input.jpg"Use the script in the skill directory:
image-gen.jsbash
bun /path/to/skills/image-gen/image-gen.js \\"MODEL\\" \\"PROMPT\\" \\"ASPECT_RATIO\\" NUM_IMAGES \\"OUTPUT_DIR\\" \\"INPUT_IMAGE\\"Parameter Description:
- MODEL: gemini-pro / seedream
- PROMPT: User's image description
- ASPECT_RATIO: Image aspect ratio (1:1, 4:3, 3:4, 16:9, 9:16)
- NUM_IMAGES: Number of images to generate
- OUTPUT_DIR: Save directory
- INPUT_IMAGE: (Optional) Path to input image, used for image editing mode
Example (Text-only generation):
bash
bun skills/image-gen/image-gen.js \\"gemini-pro\\" \\"a cat under the starry sky\\" \\"1:1\\" 1 \"."Example (Image editing):
bash
bun skills/image-gen/image-gen.js \\"gemini-pro\\" \\"change the background to a seaside\\" \\"1:1\\" 1 \".\\" \\"/path/to/input.jpg\\"Step 5: 展示结果
Step 5: Display Results
生成完成后:
- 告诉用户图片保存的完整路径
- 显示生成的图片(如果系统支持):
bash
# macOS 上打开图片 open "OUTPUT_PATH" - 报告使用的 tokens/credits(如果 API 返回)
After generation is complete:
- Tell the user the full path where the image is saved
- Display the generated image (if the system supports it):
bash
# Open image on macOS open \\"OUTPUT_PATH\\" - Report the tokens/credits used (if returned by the API)
常见问题处理
Common Issue Handling
API Key 无效:
- 请在 Max 设置中检查 Max API Key 是否正确配置
生成失败:
- 检查 prompt 是否包含违规内容
- 尝试换一个模型
- 检查网络连接
图片打不开:
- 确认文件完整下载
- 尝试使用其他图片查看器
Invalid API Key:
- Please check if the Max API Key is correctly configured in Max Settings
Generation Failed:
- Check if the prompt contains prohibited content
- Try switching to another model
- Check network connectivity
Image Cannot Be Opened:
- Confirm the file was downloaded completely
- Try using another image viewer
示例交互
Example Interaction
用户:帮我生成一张图片,一只在星空下的猫
助手:
- 检查环境变量和 Bun ✓
- 使用 AskUserQuestion 询问用户偏好
- 根据选择执行脚本
- 展示生成的图片
User: Help me generate an image of a cat under the starry sky
Assistant:
- Check environment variables and Bun ✓
- Use AskUserQuestion to ask for user preferences
- Execute the script based on the selection
- Display the generated image
交互风格
Interaction Style
- 使用简单友好的语言
- 帮助用户优化 prompt(如果描述太简单,建议添加更多细节)
- 如果遇到错误,提供清晰的解决方案
- 生成成功后给予积极反馈
- Use simple and friendly language
- Help the user optimize the prompt (if the description is too simple, suggest adding more details)
- If an error occurs, provide clear solutions
- Give positive feedback after successful generation",