Generate Image Skill
Generate AI-powered images from text prompts using the Nano Banana Pro API via the img-gen tool.
When to Use This Skill
Invoke this skill when the user requests:
- •Creating or generating images from text descriptions
- •Making visual assets, illustrations, or graphics
- •Generating images with specific aspect ratios or sizes
- •Creating images for documentation, presentations, or projects
Prerequisites Check
Before invoking this skill, the following must be satisfied:
- •The
img-gentool must be installed and in the system PATH - •The
NANOBANANA_API_KEYenvironment variable must be set
Important: The skill will fail gracefully with clear error messages if prerequisites are missing. Do not attempt to verify prerequisites yourself—let the skill handle this and communicate any errors to the user.
How to Invoke
Use the Skill tool with the following parameters:
Skill tool: skill: "generate-image" args: 'prompt="your image description" aspect_ratio="16:9" image_size="2K" output_dir="./images/"'
Directly invoke the executable with the proper parameters. You can get the required parameters by running img-gen --describe in the terminal.
For Windows, the executable is img-gen.exe.
do not invoke it with bash or shell commands. Always use the img-gen command with proper arguments.
Parameters
- •
prompt (required): Text description of the image to generate
- •Be specific and detailed for better results
- •Include style, mood, composition details when relevant
- •
aspect_ratio (optional, default: "16:9"):
- •Valid values:
1:1,16:9,4:3,3:2 - •Choose based on use case:
1:1for social media,16:9for presentations, etc.
- •Valid values:
- •
image_size (optional, default: "2K"):
- •Valid values:
1K,2K,4K - •Larger sizes take longer but provide higher quality
- •Valid values:
- •
output_dir (optional, default: "./images/"):
- •Must be a relative path within the current repository
- •Directory will be created automatically if it doesn't exist
- •For security, paths outside the repository are rejected
Communication Flow
Before invoking:
- •Acknowledge what image you're generating
- •Mention the key parameters (aspect ratio, size, output location)
- •If the user hasn't specified an output directory, use the default
./images/
After invoking:
- •Check the JSON response status
- •If successful, inform the user of:
- •The saved file path (make it a clickable markdown link)
- •The image specifications used
- •If failed, explain the error and provide the solution from the error message
Example Usage
Simple generation:
User: "Generate an image of a serene mountain landscape at sunset" You: "I'll generate a serene mountain landscape at sunset image for you." Skill tool: skill: "generate-image" args: 'prompt="A serene mountain landscape at sunset with a lake reflecting the golden sky, misty mountains in the background, peaceful atmosphere"' After success: "I've generated your image and saved it to [images/mountain-landscape.png](images/mountain-landscape.png). The image was created in 16:9 aspect ratio at 2K resolution."
With custom parameters:
User: "Create a square profile picture of a cute robot, high quality" You: "I'll create a square, high-quality image of a cute robot for you." Skill tool: skill: "generate-image" args: 'prompt="A cute friendly robot with rounded edges, soft colors, appealing design, suitable for profile picture" aspect_ratio="1:1" image_size="4K" output_dir="./profile-images/"'
Error Handling
The skill returns JSON responses. Handle these cases:
Missing tool:
- •Error: "img-gen tool is not installed or not in PATH"
- •Response: "The image generation tool isn't installed. You need to install the
img-gentool and add it to your system PATH. See installation instructions."
Missing API key:
- •Error: "NANOBANANA_API_KEY environment variable is not set"
- •Response: "The NANOBANANA_API_KEY environment variable isn't configured. You need to add it to your shell profile. [Instructions provided in the error message]."
Invalid output directory:
- •Error: "output_dir must be within the current repository"
- •Response: "For security, images can only be saved within the current repository. Please use a relative path like
./images/instead."
Invalid parameters:
- •Explain what was invalid and the correct format
- •Re-invoke with corrected parameters if you can infer the user's intent
Important Notes
- •
Security: Never attempt to save images outside the repository—the skill enforces this restriction
- •
Prompt Quality: More detailed, specific prompts yield better results. When the user provides a brief description, consider enriching it with relevant details while preserving their core intent.
- •
Path Formatting: Always format the saved image path as a clickable markdown link:
[filename.png](relative/path/to/filename.png) - •
No Prerequisites Verification: Don't check for tool installation or API keys yourself—let the skill handle it and surface any errors to the user
- •
Async Operation: Image generation may take a few seconds. Set appropriate expectations with the user.
Verification
After successful generation:
- •Confirm the file exists at the specified path
- •Provide the user with the path as a markdown link they can click to view the image