Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
k-dense-ai avatar

Generate Image

  • 916 installs
  • 31.9k repo stars
  • Updated July 28, 2026
  • k-dense-ai/scientific-agent-skills

This is a copy of generate-image by davila7 - installs and ranking accrue to the original listing.

generate-image is a Claude Code skill with a Python script that generates and edits images from prompts or reference images using top-tier models via the OpenRouter API for developers who need programmatic image creation

About

generate-image is a scientific-agent skill from k-dense-ai/scientific-agent-skills shipping a Python CLI for OpenRouter-backed image generation and editing. Supported models include google/gemini-3.1-flash-image-preview, black-forest-labs/flux.2-pro, and black-forest-labs/flux.2-flex, with editing via an input image plus prompt. The script checks for OPENROUTER_API_KEY in environment or .env files and outputs generated or edited image files. Developers reach for generate-image when agents or pipelines need reproducible image creation without wiring each model SDK manually.

  • Supports google/gemini-3.1-flash-image-preview for generation and editing
  • Supports black-forest-labs/flux.2-pro for generation and editing
  • Supports black-forest-labs/flux.2-flex for high-quality generation
  • Automatic .env lookup for OPENROUTER_API_KEY in current or parent directories
  • Converts local images to base64 for seamless editing workflows

Generate Image by the numbers

  • 916 all-time installs (skills.sh)
  • +49 installs in the week ending Jul 28, 2026 (Skillselion tracking)
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Jul 28, 2026 (Skillselion catalog sync)
npx skills add https://github.com/k-dense-ai/scientific-agent-skills --skill generate-image

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs916
repo stars31.9k
Security audit3 / 3 scanners passed
Last updatedJuly 28, 2026
Repositoryk-dense-ai/scientific-agent-skills

How do you generate images with OpenRouter API?

Generate and edit images directly from prompts or reference images using top-tier models via OpenRouter.

Who is it for?

Developers and research agents needing scripted image generation or editing through OpenRouter with multiple model options.

Skip if: Local-only diffusion pipelines or design workflows requiring manual Figma asset handoff without API generation.

When should I use this skill?

User needs to generate or edit images programmatically using OpenRouter models from prompts or reference images.

What you get

Generated or edited image files from OpenRouter model API calls

  • generated image file
  • edited image file

Files

SKILL.mdMarkdownGitHub ↗

Generate Image

Generate and edit high-quality images using OpenRouter's image generation models including FLUX.2 Pro and Gemini 3.1 Flash Image Preview.

When to Use This Skill

Use generate-image for:

  • Photos and photorealistic images
  • Artistic illustrations and artwork
  • Concept art and visual concepts
  • Visual assets for presentations or documents
  • Image editing and modifications
  • Any general-purpose image generation needs

Use scientific-schematics instead for:

  • Flowcharts and process diagrams
  • Circuit diagrams and electrical schematics
  • Biological pathways and signaling cascades
  • System architecture diagrams
  • CONSORT diagrams and methodology flowcharts
  • Any technical/schematic diagrams

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:

1. Look for a .env file in the project directory or parent directories 2. Check for OPENROUTER_API_KEY=<key> in the .env file 3. If not found, inform the user they need to:

  • Create a .env file with OPENROUTER_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.1-flash-image-preview (high quality, recommended)

Available models for generation and editing:

  • google/gemini-3.1-flash-image-preview - High quality, supports generation + editing
  • black-forest-labs/flux.2-pro - Fast, high quality, supports generation + editing

Generation only:

  • black-forest-labs/flux.2-flex - Fast and cheap, but not as high quality as pro

Select based on:

  • Quality: Use gemini-3.1-flash-image-preview or flux.2-pro
  • Editing: Use gemini-3.1-flash-image-preview or flux.2-pro (both support image editing)
  • Cost: Use flux.2-flex 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
  • --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)
  • --output or -o: Output file path (default: generated_image.png)
  • --api-key: OpenRouter API key (overrides .env file)

Example Use Cases

For Scientific Documents

# 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

For Presentations and Posters

# 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

For General Visual Content

# 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

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 images and content response 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.1 Flash Image Preview and FLUX.2 Pro support image editing through OpenRouter

Integration with Other Skills

  • scientific-schematics: Use for technical diagrams, flowcharts, circuits, pathways
  • generate-image: Use for photos, illustrations, artwork, visual concepts
  • scientific-slides: Combine with generate-image for visually rich presentations
  • latex-posters: Use generate-image for poster visuals and hero images

Related skills

FAQ

Which image models does generate-image support?

generate-image supports OpenRouter models including google/gemini-3.1-flash-image-preview, black-forest-labs/flux.2-pro, and black-forest-labs/flux.2-flex for generation and editing workflows.

How does generate-image authenticate to OpenRouter?

generate-image checks for OPENROUTER_API_KEY in the environment or a .env file in the current or parent directory before making OpenRouter image API requests.

Is Generate Image safe to install?

skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

Generative Mediaagentsautomation

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.