generate-image skill
Generate or edit images with AI models through the OpenRouter Image API (Gemini, Seedream, Recraft, GPT-Image, Riverflow). Use for photos, illustrations, artwork, concept art, visual assets, logos, and image editing or compositing from reference images. For flowcharts, circuits, pathways, and other technical diagrams, use the scientific-schematics skill instead.
Is the generate-image skill safe?
Clean: nothing in its files matched our rules. We read 3 files in the folder on 2026-09-28.
No findings.
Install the generate-image skill
A skill is a folder. Copy it into your agent's skills folder and the agent loads it when the task matches its description.
git clone --depth 1 https://github.com/K-Dense-AI/scientific-agent-skills.git /tmp/scientific-agent-skills mkdir -p ~/.claude/skills cp -r /tmp/scientific-agent-skills/skills/generate-image ~/.claude/skills/generate-image
In the Claude apps, zip the folder and upload it from the Skills settings. The folder on GitHub
The instructions your agent would load
SKILL.md as published, without the frontmatter. Read it on GitHub
Generate Image
Generate and edit images through OpenRouter's Image API, which reaches Gemini, Seedream, Recraft, GPT-Image, Riverflow, 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:
script's own directory
- --api-key
- the OPENROUTERAPIKEY environment variable
- OPENROUTERAPIKEY= in a .env file, searching the working directory upward, then the
If none is present the script exits with setup instructions. Keys: https://openrouter.ai/keys
--list-models, --model-info, and --dry-run need no key.
Quick start
# 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.pngPaths are relative to this skill's directory. Output defaults to generated_image., where the extension follows the media type the model returned. The per-request cost is printed after the run.
Then look at the image. Read the file back and check it before using it anywhere: composition, aspect ratio, and any text are all things models get wrong silently.
Choosing a model
Default: google/gemini-3.1-flash-image.
references/models.md carries the full catalogue with per-model parameters, allowed values, and prices. The live listing is authoritative and free:
python scripts/generate_image.py --list-models # every model and its allowed values
python scripts/generate_image.py --list-models gemini # filtered by substring
python scripts/generate_image.py --model-info openai/gpt-image-1 # one model, plus pricingParameter support varies by model
This is the main thing to get right. Models advertise different parameter sets and different allowed values, and sending something a model does not support is rejected, not ignored.
The script checks the request against the live catalogue before spending anything, so a bad parameter fails locally in under a second with the legal values printed:
$ python scripts/generate_image.py "abstract pattern" -m openai/gpt-image-2 --background transparent
Error: Request rejected before billing (1 problem):
- background=transparent is not allowed; this model accepts: auto, opaqueRough guide — but let the check be the authority, since the catalogue moves:
3.1 Flash, 4K on Gemini 3 Pro / Seedream / Riverflow, and 1K only on gemini-3.1-flash-lite-image and the Krea models.
- --resolution — Gemini, Seedream, Riverflow, Krea, Grok. The tiers differ: 512 only on Gemini
alone). Gemini, OpenAI, Seedream, and Recraft all choose their own container.
- --output-format — Riverflow 2.5 only (png, jpeg, webp; the fast variant takes jpeg
Riverflow 2.5. --background transparent is not available on gpt-image-2 or gpt-5.4-image-2 — use gpt-image-1, gpt-image-1-mini, gpt-5-image, or gpt-5-image-mini.
- --quality, --background, --output-compression — the OpenAI family, plus --background on
1:1, 3:2, 2:3, auto, and gpt-5-image* does not accept it at all.
- --seed — Seedream and Krea. Not Gemini, not OpenAI.
- --aspect-ratio — nearly all models, but the enum differs sharply: gpt-image-1 accepts only
and OpenAI. The Krea models reject it outright.
- --n — capped per model: 1 for Gemini, Riverflow, MAI and Grok, 6 for Recraft, 10 for Seedream
Pass --dry-run to validate and print the exact request body without generating or billing. --no-preflight skips the check when you want the API itself to arbitrate.
Writing the prompt
Prompt quality decides output quality more than model choice does. Name, in one sentence each:
- Subject — what is in frame, and how much of it. "A single pipette tip above a 96-well plate."
- Medium and style — photograph, watercolour, 3D render, flat vector, scientific illustration.
- Lighting and palette — "soft diffuse lighting, cool blue and white palette."
- Composition — "wide shot, subject left of centre, empty space on the right for a title."
- What to avoid — "no text, no labels, no watermark."
Asking for empty space where a caption or title will go is the single most useful compositional instruction for posters and slides.
Iterate cheaply: draft on gemini-3.1-flash-lite-image, then regenerate the wording you settled on with the model you actually want. To refine rather than restart, feed the last output back as a reference (-i out.png) and describe only the change.
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.
# 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.jpgReference limits differ: 16 for OpenAI, 14 for Gemini and Seedream, 10 for riverflow-v2*-pro, 3 for gemini-2.5-flash-image and Grok, 1 for Recraft, MAI, and Krea. Accepted local formats: PNG, JPEG, GIF, WebP. Riverflow v2 bills $0.20 per reference image on top of the output.
Worked examples
The -o paths are destinations the script creates, not files bundled with the skill.
# Wide hero image for a poster, with space reserved for the title
python scripts/generate_image.py \
"Laboratory with modern equipment, photorealistic, well-lit, wide shot, \
equipment on the left, empty wall on the right, no text" \
--aspect-ratio 21:9 --resolution 2K -o poster/hero.png
# Conceptual illustration for a manuscript — illustrative, never presented as data
python scripts/generate_image.py \
"Stylised illustration of immune cells surrounding a tumour cell, scientific illustration, \
cool palette, no text" \
--resolution 2K -o figures/immunotherapy_concept.png
# Vector logo
python scripts/generate_image.py \
"Minimal geometric fox logo, two colors" \
-m recraft/recraft-v4.1-vector -o assets/logo.svg
# Slide background with a transparent alpha channel
python scripts/generate_image.py \
"Abstract molecular pattern, subtle, blue and white, no text" \
-m openai/gpt-image-1 --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
pythoScript parameters
There is no --size: no model in the catalogue accepts a size parameter. Shape output with --aspect-ratio and --resolution.
API shape
For direct requests without the script:
curl -s https://openrouter.ai/api/v1/images \
-H "Authorization: Bearer $OPENROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "google/gemini-3.1-flash-image",
"prompt": "A red bicycle against a white wall",
"aspect_ratio": "16:9"
}'Response:
{
"created": 1748372400,
"data": [{ "b64_json": "<base64>", "media_type": "image/png" }],
"usage": {
"prompt_tokens": 4,
"completion_tokens": 1120,
"total_tokens": 1124,
"cost": 0.0672,
"completion_tokens_details": { "image_tokens": 1120 }
}
}b64json is raw base64, not a data URL. mediatype reflects the real format, so honour it when naming files — vector models return image/svg+xml, and gemini-3.1-flash-lite-image returns JPEG rather than PNG.
Streaming ("stream": true) emits imagegeneration.partialimage, image_generation.completed, and error events, terminating with data: [DONE]. Only the OpenAI models support it, and the bundled script does not use it.
Billing is all-or-nothing: a generation is either completed and billed in full, or it fails and is not billed — so a rejected parameter costs nothing but time. Streaming preview frames are not charged separately. On a bring-your-own-key account usage.cost reads 0 and the real amount is in costdetails.upstreaminference_cost; the script reports that figure rather than claiming the run was free.
Cost
Per-image models are predictable: Seedream $0.04, Recraft v4.1 $0.035 (vector $0.08, pro $0.21), Riverflow 2.5 fast $0.019 and pro $0.13–0.17, Grok $0.05–0.07.
Gemini, OpenAI, and MAI bill per output token, which scales with resolution — a 4K image costs roughly sixteen times a 1K one. Measured: one 1K gemini-3.1-flash-lite-image render is 1120 output tokens, $0.034. At the same size gemini-3.1-flash-image is double that and gemini-3-pro-image four times. Draft at low resolution on a cheap model; pay for size once.
More skills from K-Dense-AI/scientific-agent-skills
- AadaptyvHow to use the Adaptyv Bio Foundry API and Python SDK for protein experiment design, submission, and results retrieval. Use this skill whenever the user mentions Adaptyv, Foundry API, protein binding assays, protein screening experiments, BLI/SPR assays, thermostability assays, or wants to submit protein sequences for experimental characterization. Also trigger when code imports `adaptyv`, `adaptyv_sdk`, or `FoundryClient`, or references `foundry-api-public.adaptyvbio.com`.
- AaeonThis skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations requiring specialized algorithms beyond standard ML approaches. Particularly suited for univariate and multivariate time series analysis with scikit-learn compatible APIs.
- AalphagenomeLook up precomputed AlphaGenome Atlas effects for any GRCh38 single-nucleotide variant (AVI score with Phred and 18 SHAP feature attributions, plus raw and quantile scores for RNA-seq, DNase, ATAC, ChIP-TF, ChIP-histone, CAGE, PRO-cap, splicing, polyadenylation and contact-map tracks), score variants or scan windows on demand with the AlphaGenome model for human and mouse (variant scoring, in silico mutagenesis, REF-versus-ALT track prediction), and build Atlas website deep links. Use when the user mentions AlphaGenome, AlphaGenome Atlas, AVI or AlphaGenome Variant Impact, DeepMind variant effect prediction, or wants to prioritise or mechanistically interpret non-coding, regulatory, splicing, enhancer, promoter, or chromatin-accessibility effects of SNVs from a VCF, credible set, or region. Research use only; not a clinical tool.
- Aanalytical-method-validationPlan, execute, and document validation, verification, and transfer of analytical procedures under the governing framework - ICH Q2(R2) and Q14, USP <1220>/<1225>/<1226>, ICH M10 bioanalytical, CLSI EP, or ISO/IEC 17025. Use for HPLC, LC-MS/MS, GC, CE, ICP-MS, dissolution, qNMR, qPCR, NIR, and ligand binding or cell-based assays whenever the question is whether a procedure is fit for its intended purpose. Triggers include "method validation", "analytical method validation", "AMV", "validation protocol", "acceptance criteria", "linearity", "reportable range", "accuracy and precision", "repeatability", "intermediate precision", "recovery", "LOD", "LOQ", "detection limit", "quantitation limit", "specificity", "robustness", "method transfer", "method comparison", "Deming", "Passing-Bablok", "Bland-Altman", "equivalence testing", "OOS investigation", "ICH Q2", "Q2(R2)", "Q14", "USP 1225", "ICH M10", "incurred sample reanalysis", "ISR", "CLSI EP", and any request to show that an assay works.
- AanndataData structure for annotated matrices in single-cell analysis. Use when working with .h5ad files or integrating with the scverse ecosystem. This is the data format skill—for analysis workflows use scanpy; for probabilistic models use scvi-tools; for population-scale queries use cellxgene-census.
- AarborAutonomously improve a real artifact (code, training recipe, agent harness, data pipeline, prompt) against an objective and an evaluator, using Hypothesis Tree Refinement (HTR) from the Arbor paper. Use this whenever someone wants to iteratively optimize something over many experiments without overfitting — e.g. "get my model's eval score up", "improve this agent/harness", "tune this pipeline", "beat the baseline on this benchmark", "run a search over approaches and keep the best", "do an MLE-bench / Kaggle-style optimization", or any long-horizon "make this artifact better and don't just memorize the dev set" task. Trigger it even when the user doesn't say "Arbor" or "hypothesis tree" but describes repeated experiment-and-evaluate loops, branching exploration of competing ideas, or worries about a dev/test gap. Runs Claude itself as the coordinator with subagent executors in isolated git worktrees; for the standalone `arbor` CLI tool see references/arbor-upstream.md.
- AarboretoInfer gene regulatory networks (GRNs) from gene expression data using scalable algorithms (GRNBoost2, GENIE3). Use when analyzing transcriptomics data (bulk RNA-seq, single-cell RNA-seq) to identify transcription factor-target gene relationships and regulatory interactions. Supports distributed computation for large-scale datasets.
- AastropyCore Python library for astronomy and astrophysics workflows that need Astropy APIs, including units/quantities, coordinates, FITS I/O, tables, time systems, WCS, and cosmology. Use when implementing or debugging astronomical data analysis code with Astropy.
- AautoskillObserve the user's screen via screenpipe, detect repeated research workflows, match them against existing scientific-agent-skills, and draft new skills (or composition recipes that chain existing ones) for the patterns not yet covered. Use when the user asks to analyze their recent work and propose skills based on what they actually do. Requires the screenpipe daemon (https://github.com/screenpipe/screenpipe) running locally on port 3030 — the skill has no other data source and will refuse to run if screenpipe is unreachable. All detection runs locally; only redacted cluster summaries reach the LLM.
- Abenchling-integrationBenchling Python SDK and REST API integration for registry entities, inventory, ELN entries, workflows, Benchling Apps, and Data Warehouse queries. Use when automating lab data with benchling-sdk or the v2 API.
- Abgpt-paper-searchSearch scientific papers and retrieve structured experimental data extracted from full-text studies via the BGPT MCP server. Returns 25+ fields per paper including methods, results, sample sizes, quality scores, and conclusions. Use for literature reviews, evidence synthesis, and finding experimental details not available in abstracts alone.
- AbidsUse this skill when working with Brain Imaging Data Structure (BIDS) datasets: organizing neuroscience and biomedical data (MRI, EEG, MEG, iEEG, PET, microscopy, NIRS, motion capture, EMG, MR spectroscopy, behavioral), querying BIDS layouts, validating compliance, converting DICOM to BIDS, writing metadata sidecars, or creating BIDS derivatives.