Skip to main content
ClaudeWave
Skill2.3k repo starsupdated 23d ago

generate-image

The generate-image skill produces high-quality images using FLUX.2 Pro and Gemini 3 Pro models through OpenRouter's API. Use it for creating photorealistic images, artistic illustrations, concept art, visual assets, and general image editing, while reserving the scientific-schematics skill for technical diagrams, flowcharts, circuits, and biological pathways.

Install in Claude Code
Copy
git clone --depth 1 https://github.com/K-Dense-AI/claude-scientific-writer /tmp/generate-image && cp -r /tmp/generate-image/skills/generate-image ~/.claude/skills/generate-image
Then start a new Claude Code session; the skill loads automatically.

SKILL.md

# Generate Image

Generate and edit images through OpenRouter's Image API, which reaches Gemini, FLUX, Seedream,
Recraft, GPT-Image, and roughly thirty other models behind one request shape.

## When to use

**Use this skill for:** photos and photorealistic images, illustrations and artwork, concept art,
presentation and poster visuals, logos and vector marks, image editing, and compositing from
reference images.

**Use `scientific-schematics` instead for:** flowcharts, circuit diagrams, biological pathways,
system architecture diagrams, CONSORT diagrams, and other technical schematics.

## API key

Generation requires an OpenRouter key. The script resolves it in this order:

1. `--api-key`
2. the `OPENROUTER_API_KEY` environment variable
3. `OPENROUTER_API_KEY=` in a `.env` file, searching the working directory upward

If none is present the script exits with setup instructions. Keys: https://openrouter.ai/keys

`--list-models` needs no key.

## Quick start

```bash
# Generate
python scripts/generate_image.py "A beautiful sunset over mountains"

# Edit an existing image
python scripts/generate_image.py "Make the sky purple" -i photo.jpg -o edited.png
```

Output defaults to `generated_image.<ext>`, where the extension follows the media type the model
returned. The per-request cost is printed from `usage.cost`.

## Choosing a model

Default: `google/gemini-3.1-flash-image`.

| Need | Model |
| --- | --- |
| General quality, prompt adherence | `google/gemini-3.1-flash-image` |
| Highest Gemini tier | `google/gemini-3-pro-image` |
| Photoreal control, reproducible seeds | `black-forest-labs/flux.2-pro` |
| Cheap iteration | `black-forest-labs/flux.2-klein-4b` |
| Several images per request | `bytedance-seed/seedream-4.5`, `openai/gpt-image-2` |
| Vector / SVG output | `recraft/recraft-v4-vector` |
| Transparent background | `openai/gpt-image-2` with `--background transparent` |

`references/models.md` carries the full catalogue with per-model parameter support. The live
listing is authoritative:

```bash
python scripts/generate_image.py --list-models
```

## Parameter support varies by model

This is the main thing to get right. Models advertise different parameter sets, and **sending a
parameter a model does not support is rejected, not ignored**. The script omits every flag you do
not pass, so pass only what the target model accepts.

- `--resolution` (`512`, `1K`, `2K`, `4K`) — Gemini, Seedream, Riverflow, Krea, Grok. **Not FLUX.**
- `--output-format` — FLUX and Riverflow 2.5. **Not Gemini.**
- `--quality`, `--background`, `--output-compression` — the OpenAI family.
- `--seed` — FLUX, Seedream, Krea. **Not Gemini, not OpenAI.**
- `--aspect-ratio` — nearly all models, but the allowed enum differs.
- `--n` — capped per model: 1 for Gemini and FLUX, 6 for Recraft, 10 for Seedream and OpenAI.

On an HTTP 400 the script prints OpenRouter's message and points at `--list-models`.

## Editing and reference images

`-i/--input` is repeatable and accepts local paths, HTTP(S) URLs, or data URLs. Local files are
base64-encoded and sent as `input_references`.

```bash
# Single-image edit
python scripts/generate_image.py "Add sunglasses to the person" -i portrait.png

# Composite several references
python scripts/generate_image.py "Blend these two styles" -i style_a.png -i style_b.jpg -o blend.png

# Reference an image already on the web
python scripts/generate_image.py "Restyle as a watercolor" -i https://example.com/photo.jpg
```

Reference limits differ: 16 for OpenAI, 14 for Gemini and Seedream, 8 for FLUX, 1 for Recraft and
MAI. Accepted local formats: PNG, JPEG, GIF, WebP.

## Worked examples

```bash
# Wide hero image for a poster
python scripts/generate_image.py \
  "Laboratory with modern equipment, photorealistic, well-lit" \
  -m black-forest-labs/flux.2-pro --aspect-ratio 21:9 -o poster/hero.png

# Conceptual figure for a manuscript
python scripts/generate_image.py \
  "Microscopic view of cancer cells attacked by immunotherapy agents, scientific illustration" \
  --resolution 2K -o figures/immunotherapy_concept.png

# Vector logo
python scripts/generate_image.py \
  "Minimal geometric fox logo, two colors" \
  -m recraft/recraft-v4-vector -o assets/logo.svg

# Slide background with a transparent alpha channel
python scripts/generate_image.py \
  "Abstract molecular pattern, subtle, blue and white" \
  -m openai/gpt-image-2 --background transparent -o slides/bg.png

# Four variations in one request
python scripts/generate_image.py \
  "Stylized neuron network illustration" \
  -m bytedance-seed/seedream-4.5 --n 4 -o variations.png
# -> variations_1.png ... variations_4.png

# Reproducible output
python scripts/generate_image.py "A cat astronaut" \
  -m black-forest-labs/flux.2-pro --seed 42
```

## Script parameters

| Flag | Purpose |
| --- | --- |
| `prompt` | Image description, or the edit to apply (required unless `--list-models`) |
| `-m`, `--model` | Model slug (default `google/gemini-3.1-flash-image`) |
| `-o`, `--output` | Output path; extension defaults to the returned media type |
| `-i`, `--input` | Reference image — path, URL, or data URL. Repeatable |
| `--n` | Images per request, model-capped |
| `--aspect-ratio` | `1:1`, `16:9`, `9:16`, `4:3`, `3:2`, `21:9`, … |
| `--resolution` | `512`, `1K`, `2K`, `4K` |
| `--size` | Explicit pixels, e.g. `2048x2048` |
| `--quality` | `auto`, `low`, `medium`, `high` |
| `--output-format` | `png`, `jpeg`, `webp`, `svg` |
| `--background` | `auto`, `transparent`, `opaque` |
| `--output-compression` | 0–100, for WebP/JPEG |
| `--seed` | Deterministic output where supported |
| `--api-key` | Overrides the environment and `.env` |
| `--timeout` | Request timeout, seconds (default 300) |
| `--list-models` | Print the catalogue with parameter support, then exit |

## API shape

For direct requests without the script:

```bash
curl -s https://openrouter.ai/api/v1/images \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -H "Content-Type: app
citation-managementSkill

Comprehensive citation management for academic research. Search Google Scholar and PubMed for papers, extract accurate metadata, validate citations, and generate properly formatted BibTeX entries. This skill should be used when you need to find papers, verify citation information, convert DOIs to BibTeX, or ensure reference accuracy in scientific writing.

clinical-decision-supportSkill

Prepare and validate research-only clinical decision-support evaluation, evidence-profile, cohort, survival, biomarker/model, privacy, and governance artifacts. Use for aggregate or synthetic research documentation and traceability—not patient care or live clinical operation.

clinical-reportsSkill

Create safety-bounded draft structures and run local deterministic checks for clinical case, diagnostic, trial, safety, and aggregate research reports. Use only with synthetic, de-identified, or aggregate inputs and verified source-fact manifests; every output requires qualified review.

docxSkill

Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.

pdfSkill

Use this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.

pptxSkill

Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions \"deck,\" \"slides,\" \"presentation,\" or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill.

xlsxSkill

Create, edit, analyze, or convert Excel spreadsheets (.xlsx, .xlsm, .xltx) where the workbook file is the primary deliverable. Use for formulas, formatting, financial models, multi-sheet workbooks, and tabular cleanup exported to Excel. Also applies to .csv/.tsv when the user wants spreadsheet output. Do NOT use for Word documents, HTML reports, standalone Python scripts, database pipelines, or Google Sheets API work.

hypothesis-generationSkill

Formulate evidence-bounded scientific questions, candidate hypotheses, rival explanations, causal or associational claims, discriminating predictions, measurements, and preregistration-ready analysis plans. Use when turning observations or preliminary findings into transparent, testable research plans without treating hypotheses as facts.