generate-image

Original🇺🇸 English
Translated
1 scripts

Use when the user needs to generate images, UI assets, icons, backgrounds, placeholders, or any visual content. Triggers on requests like "generate an image", "create a picture", "make an icon", "I need a visual for...".

1installs
Added on

NPX Install

npx skill4agent add wxul/openrouter-generate-image-skill generate-image

Tags

Translated version includes tags in frontmatter

Generate Image via OpenRouter

Generate images using OpenRouter's image models from the command line. Default model:
google/gemini-3.1-flash-image-preview
.

Prerequisites

  • OPENROUTER_API_KEY
    environment variable must be set
  • tsx
    available via npx

Usage

Run the script via
npx tsx
:
bash
npx tsx generate-image.ts \
  --prompt "description of the image" \
  --model "google/gemini-3.1-flash-image-preview" \
  --width 1024 --height 1024 \
  --output "filename.png" \
  --dir "./generated-images" \
  --proxy "http://127.0.0.1:7890"

Parameters

ParamRequiredDefaultDescription
--prompt
Yes-Image description
--model
No
google/gemini-3.1-flash-image-preview
OpenRouter model ID
--width
No1024Image width
--height
No1024Image height
--output
Noauto (timestamp-slug.png)Output filename
--dir
No
./generated-images
Output directory
--proxy
No-HTTP proxy URL

Supported Models

  • google/gemini-3.1-flash-image-preview
    (default, recommended)
  • black-forest-labs/flux-1.1-pro
  • black-forest-labs/flux-schnell
  • Any OpenRouter model that supports image generation

How to Use as an Agent

When the user asks you to generate an image:
  1. Compose a detailed English prompt describing the desired image
  2. Choose appropriate model and size for the use case
  3. Run the script using Bash tool
  4. The script outputs the saved file path to stdout — use this path to reference the image in code or tell the user

Quick Examples

bash
# Simple generation with defaults
npx tsx generate-image.ts \
  --prompt "a minimalist logo of a mountain with a sun, flat design, blue and orange"

# With specific model and output
npx tsx generate-image.ts \
  --prompt "abstract gradient background, purple to blue" \
  --model "black-forest-labs/flux-1.1-pro" \
  --output "bg-gradient.png" \
  --dir "./public/images"

# With proxy
npx tsx generate-image.ts \
  --prompt "pixel art cat sitting on a desk" \
  --proxy "http://127.0.0.1:7890"

Troubleshooting