$npx -y skills add LeonChaoX/qinyan-academic-skills --skill generate-imageGenerate or edit images using AI models (FLUX, Nano Banana 2). Use for general-purpose image generation including photos, illustrations, artwork, visual assets, concept art, and any image that is not a technical diagram or schematic. For flowcharts, circuits, pathways, and techni
| 1 | # Generate Image |
| 2 | |
| 3 | Generate and edit high-quality images using OpenRouter's image generation models including FLUX.2 Pro and Gemini 3.1 Flash Image Preview. |
| 4 | |
| 5 | ## When to Use This Skill |
| 6 | |
| 7 | **Use generate-image for:** |
| 8 | - Photos and photorealistic images |
| 9 | - Artistic illustrations and artwork |
| 10 | - Concept art and visual concepts |
| 11 | - Visual assets for presentations or documents |
| 12 | - Image editing and modifications |
| 13 | - Any general-purpose image generation needs |
| 14 | |
| 15 | **Use scientific-schematics instead for:** |
| 16 | - Flowcharts and process diagrams |
| 17 | - Circuit diagrams and electrical schematics |
| 18 | - Biological pathways and signaling cascades |
| 19 | - System architecture diagrams |
| 20 | - CONSORT diagrams and methodology flowcharts |
| 21 | - Any technical/schematic diagrams |
| 22 | |
| 23 | ## Quick Start |
| 24 | |
| 25 | Use the `scripts/generate_image.py` script to generate or edit images: |
| 26 | |
| 27 | ```bash |
| 28 | # Generate a new image |
| 29 | python scripts/generate_image.py "A beautiful sunset over mountains" |
| 30 | |
| 31 | # Edit an existing image |
| 32 | python scripts/generate_image.py "Make the sky purple" --input photo.jpg |
| 33 | ``` |
| 34 | |
| 35 | This generates/edits an image and saves it as `generated_image.png` in the current directory. |
| 36 | |
| 37 | ## API Key Setup |
| 38 | |
| 39 | **CRITICAL**: The script requires an OpenRouter API key. Before running, check if the user has configured their API key: |
| 40 | |
| 41 | 1. Look for a `.env` file in the project directory or parent directories |
| 42 | 2. Check for `OPENROUTER_API_KEY=<key>` in the `.env` file |
| 43 | 3. If not found, inform the user they need to: |
| 44 | - Create a `.env` file with `OPENROUTER_API_KEY=your-api-key-here` |
| 45 | - Or set the environment variable: `export OPENROUTER_API_KEY=your-api-key-here` |
| 46 | - Get an API key from: https://openrouter.ai/keys |
| 47 | |
| 48 | The script will automatically detect the `.env` file and provide clear error messages if the API key is missing. |
| 49 | |
| 50 | ## Model Selection |
| 51 | |
| 52 | **Default model**: `google/gemini-3.1-flash-image-preview` (high quality, recommended) |
| 53 | |
| 54 | **Available models for generation and editing**: |
| 55 | - `google/gemini-3.1-flash-image-preview` - High quality, supports generation + editing |
| 56 | - `black-forest-labs/flux.2-pro` - Fast, high quality, supports generation + editing |
| 57 | |
| 58 | **Generation only**: |
| 59 | - `black-forest-labs/flux.2-flex` - Fast and cheap, but not as high quality as pro |
| 60 | |
| 61 | Select based on: |
| 62 | - **Quality**: Use gemini-3.1-flash-image-preview or flux.2-pro |
| 63 | - **Editing**: Use gemini-3.1-flash-image-preview or flux.2-pro (both support image editing) |
| 64 | - **Cost**: Use flux.2-flex for generation only |
| 65 | |
| 66 | ## Common Usage Patterns |
| 67 | |
| 68 | ### Basic generation |
| 69 | ```bash |
| 70 | python scripts/generate_image.py "Your prompt here" |
| 71 | ``` |
| 72 | |
| 73 | ### Specify model |
| 74 | ```bash |
| 75 | python scripts/generate_image.py "A cat in space" --model "black-forest-labs/flux.2-pro" |
| 76 | ``` |
| 77 | |
| 78 | ### Custom output path |
| 79 | ```bash |
| 80 | python scripts/generate_image.py "Abstract art" --output artwork.png |
| 81 | ``` |
| 82 | |
| 83 | ### Edit an existing image |
| 84 | ```bash |
| 85 | python scripts/generate_image.py "Make the background blue" --input photo.jpg |
| 86 | ``` |
| 87 | |
| 88 | ### Edit with a specific model |
| 89 | ```bash |
| 90 | python scripts/generate_image.py "Add sunglasses to the person" --input portrait.png --model "black-forest-labs/flux.2-pro" |
| 91 | ``` |
| 92 | |
| 93 | ### Edit with custom output |
| 94 | ```bash |
| 95 | python scripts/generate_image.py "Remove the text from the image" --input screenshot.png --output cleaned.png |
| 96 | ``` |
| 97 | |
| 98 | ### Multiple images |
| 99 | Run the script multiple times with different prompts or output paths: |
| 100 | ```bash |
| 101 | python scripts/generate_image.py "Image 1 description" --output image1.png |
| 102 | python scripts/generate_image.py "Image 2 description" --output image2.png |
| 103 | ``` |
| 104 | |
| 105 | ## Script Parameters |
| 106 | |
| 107 | - `prompt` (required): Text description of the image to generate, or editing instructions |
| 108 | - `--input` or `-i`: Input image path for editing (enables edit mode) |
| 109 | - `--model` or `-m`: OpenRouter model ID (default: google/gemini-3.1-flash-image-preview) |
| 110 | - `--output` or `-o`: Output file path (default: generated_image.png) |
| 111 | - `--api-key`: OpenRouter API key (overrides .env file) |
| 112 | |
| 113 | ## Example Use Cases |
| 114 | |
| 115 | ### For Scientific Documents |
| 116 | ```bash |
| 117 | # Generate a conceptual illustration for a paper |
| 118 | python scripts/generate_image.py "Microscopic view of cancer cells being attacked by immunotherapy agents, scientific illustration style" --output figures/immunotherapy_concept.png |
| 119 | |
| 120 | # Create a visual for a presentation |
| 121 | python scripts/generate_image.py "DNA double helix structure with highlighted mutation site, modern scientific visualization" --output slides/dna_mutation.png |
| 122 | ``` |
| 123 | |
| 124 | ### For Presentations and Posters |
| 125 | ```bash |
| 126 | # Title slide background |
| 127 | python scripts/generate_image.py "Abstract blue and white background with subtle molecular patterns, professional |