generate-image
Scannednpx machina-cli add skill Microck/ordinary-claude-skills/generate-image --openclawGenerate Image
Generate and edit high-quality images using OpenRouter's image generation models including FLUX.2 Pro and Nano Banana Pro (Gemini 3 Pro).
Quick Start
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.
API Key Setup
CRITICAL: The script requires an OpenRouter API key. Before running, check if the user has configured their API key:
- Look for a
.envfile in the project directory or parent directories - Check for
OPENROUTER_API_KEY=<key>in the.envfile - If not found, inform the user they need to:
- Create a
.envfile withOPENROUTER_API_KEY=your-api-key-here - Or set the environment variable:
export OPENROUTER_API_KEY=your-api-key-here - Get an API key from: https://openrouter.ai/keys
- Create a
The script will automatically detect the .env file and provide clear error messages if the API key is missing.
Model Selection
Default model: google/gemini-3-pro-image-preview (high quality, recommended)
Available models for generation and editing:
google/gemini-3-pro-image-preview- High quality, supports generation + editingblack-forest-labs/flux.2-pro- Fast, high quality, supports generation + editing
Generation only:
black-forest-labs/flux.2-dev- Development version, generation only
Select based on:
- Quality: Use gemini-3-pro or flux.2-pro
- Editing: Use gemini-3-pro or flux.2-pro (both support image editing)
- Cost: Use flux.2-dev for generation only
Common Usage Patterns
Basic generation
python scripts/generate_image.py "Your prompt here"
Specify model
python scripts/generate_image.py "A cat in space" --model "black-forest-labs/flux.2-pro"
Custom output path
python scripts/generate_image.py "Abstract art" --output artwork.png
Edit an existing image
python scripts/generate_image.py "Make the background blue" --input photo.jpg
Edit with a specific model
python scripts/generate_image.py "Add sunglasses to the person" --input portrait.png --model "black-forest-labs/flux.2-pro"
Edit with custom output
python scripts/generate_image.py "Remove the text from the image" --input screenshot.png --output cleaned.png
Multiple images
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
Script Parameters
prompt(required): Text description of the image to generate, or editing instructions--inputor-i: Input image path for editing (enables edit mode)--modelor-m: OpenRouter model ID (default: google/gemini-3-pro-image-preview)--outputor-o: Output file path (default: generated_image.png)--api-key: OpenRouter API key (overrides .env file)
Error Handling
The script provides clear error messages for:
- Missing API key (with setup instructions)
- API errors (with status codes)
- Unexpected response formats
- Missing dependencies (requests library)
If the script fails, read the error message and address the issue before retrying.
Notes
- Images are returned as base64-encoded data URLs and automatically saved as PNG files
- The script supports both
imagesandcontentresponse formats from different OpenRouter models - Generation time varies by model (typically 5-30 seconds)
- For image editing, the input image is encoded as base64 and sent to the model
- Supported input image formats: PNG, JPEG, GIF, WebP
- Check OpenRouter pricing for cost information: https://openrouter.ai/models
Image Editing Tips
- Be specific about what changes you want (e.g., "change the sky to sunset colors" vs "edit the sky")
- Reference specific elements in the image when possible
- For best results, use clear and detailed editing instructions
- Both Gemini 3 Pro and FLUX.2 Pro support image editing through OpenRouter
Source
git clone https://github.com/Microck/ordinary-claude-skills/blob/main/skills_all/claude-scientific-skills/scientific-skills/generate-image/SKILL.mdView on GitHub Overview
Generate and edit high-quality images using OpenRouter's image models (FLUX.2 Pro and Gemini). Suitable for scientific illustrations, diagrams, schematics, infographics, concept visuals, and posters, with editing capabilities to adjust colors, add/remove elements, or apply styles.
How This Skill Works
Run the Python script scripts/generate_image.py with a text prompt to generate an image, or provide --input to edit an existing image. You can choose models (default google/gemini-3-pro-image-preview or black-forest-labs/flux.2-pro) for quality and editing; outputs are saved as PNG (generated_image.png by default) in the current directory.
When to Use It
- Create a scientific diagram or schematic
- Produce an infographic or poster
- Generate concept visuals for presentations
- Edit an existing image by changing colors or adding elements
- Create artistic images or data visualizations
Quick Start
- Step 1: Run a basic generation: python scripts/generate_image.py "Your prompt here"
- Step 2: Edit an existing image: python scripts/generate_image.py "Edit instruction" --input image.jpg
- Step 3: Retrieve the output from generated_image.png or your specified --output file
Best Practices
- Be explicit in prompts with detailed visual descriptors
- Use --input for edits when modifying an existing image
- Choose the right model for your task (gemini-3-pro or flux.2-pro for quality and editing; flux.2-dev for generation only)
- Specify a clear --output path to avoid overwrites
- Ensure your OpenRouter API key is configured via .env or environment variable before running
Example Use Cases
- A cellular pathway diagram for a biology paper
- A circuit schematic illustration for a conference poster
- An infographic comparing data trends across experiments
- A concept visualization of a workflow in a product design
- An artistic poster inspired by a research topic