generate-image
Generate or edit images using AI models (FLUX, Gemini). Use for scientific illustrations, diagrams, schematics, infographics, concept visualizations…
它会碰到什么
逐条看命中(11 条严重或高危)
- 严重
scripts/generate_image.py:23cred-paths"""Check if .env file exists and contains OPENROUTER_API_KEY."""
- 严重
scripts/generate_image.py:24cred-paths# Look for .env in current directory and parent directories
- 严重
scripts/generate_image.py:27cred-pathsenv_file = parent / ".env"
- 严重
scripts/generate_image.py:89cred-pathsapi_key: OpenRouter API key (will check .env if not provided)
- 严重
scripts/generate_image.py:107cred-pathsprint("\nPlease create a .env file in your project directory with:") - 严重
scripts/generate_image.py:266cred-pathshelp="OpenRouter API key (will check .env if not provided)"
- 严重
SKILL.md:28cred-paths1. Look for a `.env` file in the project directory or parent directories
- 严重
SKILL.md:29cred-paths2. Check for `OPENROUTER_API_KEY=<key>` in the `.env` file
- 严重
SKILL.md:31cred-paths- Create a `.env` file with `OPENROUTER_API_KEY=your-api-key-here`
- 严重
SKILL.md:35cred-pathsThe script will automatically detect the `.env` file and provide clear error messages if the API key is missing.
- 严重
SKILL.md:98cred-paths- `--api-key`: OpenRouter API key (overrides .env file)
这一栏是扫描器报的事实,不是结论。命中多不等于有毒(安全工具、规则库、示例脚本本来就会包含危险写法),命中少也不等于干净。它和你手上的凭据、文件、网络有什么关系,需要你自己看。
技能内容
Generate 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
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
想直接用这个技能?
本站把开放许可(MIT / Apache 等)的技能按仓库打包整理到网盘,点一下转存到你自己的网盘,不用一个个从 GitHub 拉。许可未声明的技能只给原始仓库链接,不打包。
它属于哪个仓库
skills_all/claude-scientific-skills/scientific-skills/generate-image/SKILL.md同一个仓库里的其他技能
同名技能的其他版本
有 5 个不同仓库或目录里都有叫 generate-image 的技能。它们内容并不相同,别混用:
- Microck/ordinary-claude-skills — Generate or edit images using AI models (FLUX, Gemini). Use for scientific illustrations,
- Microck/ordinary-claude-skills — Generate or edit images using AI models (FLUX, Gemini). Use for scientific illustrations,
- Microck/ordinary-claude-skills — Generate or edit images using AI models (FLUX, Gemini). Use for scientific illustrations,
- Microck/ordinary-claude-skills — Generate or edit images using AI models (FLUX, Gemini). Use for scientific illustrations,