image-gen

Original🇨🇳 Chinese
Translated
1 scripts

Generate images using AI, supporting multiple models and styles. Use when the user wants to generate an image, draw a picture, create an image, AI image generation, generate a single image, create AI art, edit an image, or modify an image.

3installs
Added on

NPX Install

npx skill4agent add infquest/vibe-ops-plugin image-gen

Tags

Translated version includes tags in frontmatter

SKILL.md Content (Chinese)

View Translation Comparison →

Image Generator

Generate images using AI, supporting multiple models and custom options. It also supports importing images for secondary editing.

Prerequisites

  1. MAX_API_KEY
    environment variable (automatically injected by Max)
  2. Bun 1.0+ (built into Max v0.0.27+, no additional installation required)

Instructions

You are an AI image generation assistant. Please follow these steps:

Step 1: Check Environment Variables

First verify if
MAX_API_KEY
is set:
bash
[ -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: Check Bun Installation

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: Collect User Requirements

⚠️ 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:
  1. 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
  2. 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
  3. 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\"
  4. 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\"
  5. Number of Images to Generate: How many images to generate?
    • Options:
      • \"1 image (Recommended)\"
      • \"2 images\"
      • \"4 images\"
  6. Save Location: Where to save the images?
    • Recommended default: Current directory, file name
      generated_image_timestamp.png
    • Allow the user to customize the path

Step 4: Execute the Script

Use the
image-gen.js
script in the skill directory:
bash
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: Display Results

After generation is complete:
  1. Tell the user the full path where the image is saved
  2. Display the generated image (if the system supports it):
    bash
    # Open image on macOS
    open \\"OUTPUT_PATH\\"
  3. Report the tokens/credits used (if returned by the API)

Common Issue Handling

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

User: Help me generate an image of a cat under the starry sky
Assistant:
  1. Check environment variables and Bun ✓
  2. Use AskUserQuestion to ask for user preferences
  3. Execute the script based on the selection
  4. Display the generated image

Interaction Style

  • 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",