generate-image
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
By k-dense-ai · 1,500 installs
npx skills add k-dense-ai/scientific-agent-skills --skill generate-image
Source repository · Upstream listing
Generate Image
Generate and edit images through OpenRouter's Image API, which reaches Gemini, Seedream, Recraft,
GPT Image, Riverflow, and 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, then the
script's own directory
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
Run these commands from the skill directory; input and output paths resolve from the working
directory. Output defaults to generated image.<ext , using each image's returned media type
(or .bin when unknown). An explicit output suffix is kept, with a warning on mismatch; the
script does not transcode. OpenRouter and upstream costs are printed separately when supplied.
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 .
Need Model
General quality, prompt adherence google/gemini 3.1 flash image
Highest Gemini tier google/gemini 3 pro image
Cheap iteration google/gemini 3.1 flash lite image (1K only), openai/gpt image 1 mini
Photoreal control, seeded generation bytedance seed/seedream 4.5
Several images per request bytedance seed/seedream 4.5 , openai/gpt image 2 (up to 10)
Vector / SVG output recraft/recraft v4.1 vector
Transparent background openai/gpt image 1 with background transparent
Legible text inside the image recraft/recraft v4.1 , sourceful/riverflow v2.5 pro — see the caveat below
[references/models.md](references/models.md) carries the reviewed capability and pricing snapshot. The live listing is authoritative and free:
Parameter support varies by model
This is the main thing to get right. Models advertise different parameter sets and different
allowed values . The CLI conservatively rejects unadvertised options; individual providers may
ignore or normalize some fields. The generic guide can lag the discovery records.
The script checks the model catalogue and requires at least one provider endpoint to accept the
complete combination before generation. Model capabilities are a union across endpoints, not a
promise that every provider supports them. Unsupported requests fail locally with legal values:
Current examples of capability differences (reviewed 2026 09 30):
resolution : Gemini 3.1 Flash accepts 512 , 1K , 2K , 4K ; Flash Lite and Krea
accept only 1K . Seedream 5.0 Lite accepts 2K / 4K , while 5.0 Pro accepts 1K / 2K .
output format : Riverflow 2.5 Pro accepts png / jpeg / webp ; its Fast variant accepts
only jpeg . Recraft vector models accept svg . OpenAI models do not advertise this flag.
quality : GPT Image 2.5 Flare/Sunburst also accept xhigh / max ; Grok 2.0 accepts
only low / medium . Inspect the specific model before selecting a quality value.
background transparent is not available on gpt image 2 or gpt 5.4 image 2 .
It is advertised on GPT Image 1 and 2.5. Do not combine transparency with JPEG; when no
output format is selectable, inspect the returned file for an actual alpha channel.
aspect ratio : GPT 5 Image and Mini now accept 1:1 , 3:2 , 2:3 , auto ;
GPT 5.4 Image 2 also accepts wider ratios. None accept a resolution flag in this snapshot.
n is an upper bound, not a guarantee: providers may return fewer images. Seedream 4.5
caps at 10, Seedream 5.0 Lite at 4, and 5.0 Pro at 1. Krea does not advertise n .
seed is available on Seedream, Krea, Qwen and FLUX, but not Gemini or OpenAI.
Keep the model/provider, prompt and parameters fixed; a seed is not a cross version guarantee.
dry run performs free discovery and prints the request without generating. If discovery
fails, the command stops; no preflight explicitly bypasses it. Combining both flags is an
offline payload inspection, not validation of provider support.
Writing the prompt
Prompt quality decides output quality more than model choice does. Name, in one sentence each:
1. Subject — what is in frame, and how much of it. "A single pipette tip above a 96 well plate."
2. Medium and style — photograph, watercolour, 3D render, flat vector, scientific illustration.
3. Lighting and palette — "soft diffuse lighting, cool blue and white palette."
4. Composition — "wide shot, subject left of centre, empty space on the right for a title."
5. 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 .
Reference ranges include both a minimum and a maximum: OpenAI accepts up to 16, Gemini 3 and
Seedream up to 14, Riverflow Pro up to 10, and MAI 2.6 up to 5. Recraft v4 Styles requires
1–10 references; its regular v4/v4.1 models accept 0–1. Ming Design Layer requires exactly one,
while Ming Design and Recraft Flash are text only. The CLI checks required and zero reference
limits too. Local formats supported by the helper: PNG, JPEG, GIF, WebP; provider decoding rules
still apply. Local files and data URLs send their bytes; URL references are fetched by the service.
Do not use private or credential bearing URLs. Riverflow v2 bills $0.20 per reference image.
Worked examples
The o paths are destinations the script creates, not bundled files. These are generation
examples, not authenticated end to end results from this review. Their request parameters were
checked against public discovery, and local encoding/response handling was tested with mocks.
Script parameters
Flag Purpose
prompt Image description, or the edit to apply (required unless list models / model info )
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 Upper bound on returned images, 1–10 and model capped
aspect ratio 1:1 , 16:9 , 9:16 , 4:3 , 3:2 , 21:9 , … — enum differs per model
resolution 512 , 1K , 2K , 4K — tiers differ per model
quality Model specific quality; checked against live values
output format png , jpeg , webp , svg ; model dependent
background auto , transparent , opaque
output compression 0–100, OpenAI models
seed Seed for repeatability where supported
api key Overrides the environment and .env
timeout Request timeout, seconds (default 300)
retries Retries for rate limits and 5xx responses (default 2)
no preflight Skip the free capability check before the billed request
dry run Validate and print the request, then exit without generating
list models Print the catalogue with allowed values, optionally filtered, then exit
model info Print one model's allowed values and pricing, then exit
The bundled CLI has no size ; use aspect ratio and resolution with it.
The [current Image API](https://openrouter.ai/docs/guides/overview/multimodal/image generation)
also documents a size shorthand for direct requests. API support does not imply that
this CLI exposes the parameter; check live model and endpoint capabilities.
API shape
For direct requests without the script:
Illustrative response (token counts and cost are not a quote):
b64 json is raw base64, not a data URL. media type describes the actual format when
identifiable; it may be absent. Vector outputs use image/svg+xml . Never infer a file's format
from the requested filename or assume every model returns PNG. The helper rejects invalid base64
and chooses an extension per returned image.
Streaming ( "stream": true ) emits image generation.partial image , image generation.completed ,
and error events, terminating with data: [DONE] . Use it only when the selected endpoint advertises supports streaming: true ;
the bundled script uses buffered responses and does not implement SSE.
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. For BYOK, usage.cost may include an OpenRouter fee while
usage.cost details.upstream inference cost reports upstream inference. The helper prints both;
it does not assume that BYOK always has zero OpenRouter cost or sum potentially overlapping fields.
Cost
Inspect model info for per endpoint billable units, input charges and resolution variants.
A per output image rate is not necessarily the whole request cost. The reviewed snapshot includes
Seedream 4.5 at $0.04/output image and Recraft v4.1 Vector at $0.08/output image; see
[the model reference](references/models.md) for the dated rates and caveats.
Do not estimate token billed image cost from pixel area alone: the relation between resolution,
quality and token count depends on the model. Krea currently publishes no endpoint price; the
Ming entries report zero rates, which is discovery metadata, not a guarantee of free generation.
[BYOK fees](https://openrouter.ai/docs/guides/overview/auth/byok) can apply in addition to upstream
billing. Inspect actual usage for completed calls. No paid generation was run during this review.
Notes and caveats
Models cannot be trusted with text. Words inside a generated image come back misspelled,
garbled, or invented. Ask for "no text" and overlay real type in LaTeX, PowerPoint, or HTML — or
use scientific schematics when labels are the point.
A generated image is an illustration, never evidence. It shows nothing that was measured.
Never present one as microscopy, imaging, gel, or instrument output, never let it stand in for a
figure that reports results, and label it as an illustration in captions. Check the target venue's current generative AI imagery and disclosure policy before submitting.
Generation is a paid API call. Prefer a cheap model and low resolution while iterating on wording.
Generation can take minutes; the CLI defaults to a 300 second request timeout.
Reference images are uploaded to OpenRouter. Do not send unpublished or sensitive data, patient
images, or anything under embargo.
Never hardcode the API key. Keep it in the environment or an ignored .env .
Prompt specifically when editing: "change the sky to sunset colours" beats "edit the sky".
Inspect the returned error: 401 concerns credentials, 402 credits or spending limits, and 403
may concern permissions, guardrails or moderation. Refusals need not all share one HTTP code.
The helper retries HTTP 429 and selected 5xx responses, but not other HTTP errors. A temporary
402 in flight budget limit may in