Generate or edit images using AI models, defaulting to google/gemini-3.1-flash-image-preview for standard-quality output. Use for general-purpose image generation including photos, illustrations, artwork, visual assets, concept art, and any image that isn't a technical diagram or schematic. For flowcharts, circuits, pathways, and technical diagrams, use the scientific-schematics skill instead.
Generate and edit standard-quality images using OpenRouter's image generation models, defaulting to google/gemini-3.1-flash-image-preview.
Use generate-image for:
Use scientific-schematics instead for:
Use the scripts/generate_image.py script to generate or edit images:
# Generate a new image
python scripts/generate_image.py "A beautiful sunset over mountains"
# Edit an existing image
python scripts/generate_image.py "Make the sky purple" --input photo.jpg
This generates/edits an image and saves it as generated_image.png in the current directory.
CRITICAL: The script requires an OpenRouter API key. Before running, check if the user has configured their API key:
.env file in the project directory or parent directoriesOPENROUTER_API_KEY=<key> in the .env file.env file with OPENROUTER_API_KEY=your-api-key-hereexport OPENROUTER_API_KEY=your-api-key-hereThe script will automatically detect the .env file and provide clear error messages if the API key is missing.
Default model: google/gemini-3.1-flash-image-preview (standard quality, recommended)
Use google/gemini-3.1-flash-image-preview by default for both generation and editing. Treat this as the house default unless the user explicitly asks for a different model.
Alternative models:
black-forest-labs/flux.2-pro - alternative option for generation + editing when the user explicitly requests itblack-forest-labs/flux.2-flex - cheaper generation-only fallback when neededDefault to standard quality. Do not optimize for premium/high-fidelity output unless the user explicitly asks for that.
python scripts/generate_image.py "Your prompt here"
python scripts/generate_image.py "A cat in space" --model "google/gemini-3.1-flash-image-preview"
python scripts/generate_image.py "Abstract art" --output artwork.png
python scripts/generate_image.py "Make the background blue" --input photo.jpg
python scripts/generate_image.py "Add sunglasses to the person" --input portrait.png --model "google/gemini-3.1-flash-image-preview"
python scripts/generate_image.py "Remove the text from the image" --input screenshot.png --output cleaned.png
Run the script multiple times with different prompts or output paths:
python scripts/generate_image.py "Image 1 description" --output image1.png
python scripts/generate_image.py "Image 2 description" --output image2.png
prompt (required): Text description of the image to generate, or editing instructions--input or -i: Input image path for editing (enables edit mode)--model or -m: OpenRouter model ID (default: google/gemini-3.1-flash-image-preview; only override when the user explicitly asks)--output or -o: Output file path (default: generated_image.png)--api-key: OpenRouter API key (overrides .env file)After generation, the script automatically:
.webp or .jpg file.This keeps cover images lightweight and suitable for blog use without leaving oversized assets behind. The Pillow library is required for post-processing:
pip install Pillow
If Pillow is not installed, a warning is printed and post-processing is skipped.
When using this skill for blog cover images or social preview artwork:
.webp or .jpg path rather than preserving the original PNG extension.# Generate a conceptual illustration for a paper
python scripts/generate_image.py "Microscopic view of cancer cells being attacked by immunotherapy agents, scientific illustration style" --output figures/immunotherapy_concept.png
# Create a visual for a presentation
python scripts/generate_image.py "DNA double helix structure with highlighted mutation site, modern scientific visualization" --output slides/dna_mutation.png
# Title slide background
python scripts/generate_image.py "Abstract blue and white background with subtle molecular patterns, professional presentation style" --output slides/background.png
# Poster hero image
python scripts/generate_image.py "Laboratory setting with modern equipment, photorealistic, well-lit" --output poster/hero.png
# Website or documentation images
python scripts/generate_image.py "Professional team collaboration around a digital whiteboard, modern office" --output docs/team_collaboration.png
# Marketing materials
python scripts/generate_image.py "Futuristic AI brain concept with glowing neural networks" --output marketing/ai_concept.png
The script provides clear error messages for:
If the script fails, read the error message and address the issue before retrying.
IMPORTANT: No Meta Instructions in Output
When generating prompts for the AI image generation models, ensure the generated image does NOT contain any visible text showing:
The image should only contain the requested visual content. Always include this instruction in your prompts: "Do not include any text showing the prompt, instructions, layout descriptions, font/color specifications, or metadata in the generated image."
.webp or .jpgimages and content response formats from different OpenRouter models