Install
openclaw skills install openrouter-image-genGenerate images using Google Gemini via OpenRouter API. Supports text-to-image and reference-image-guided generation. Use when the user asks to generate, create, draw, or design images/illustrations/covers/avatars.
openclaw skills install openrouter-image-genGenerate images via google/gemini-3.1-flash-image-preview on OpenRouter. Cheap ($0.25/M in, $1.5/M out), fast, good quality.
python3 scripts/generate.py "a watercolor illustration of a cozy café" -o output.png
With reference image (style/character guidance):
python3 scripts/generate.py "same character but waving hello" -o wave.png --ref reference.png
Script path: skills/gemini-image-gen/scripts/generate.py
OPENROUTER_API_KEY environment variable (or --api-key flag)/chat/completions with modalities: ["text", "image"]choices[0].message.images[0].image_url.url (data:image/png;base64,...)--ref, describe the character features explicitly in the prompt AND provide the reference image⚠️ Critical: Images must be saved to a path within localRoots (typically your OpenClaw workspace dir). /tmp is NOT whitelisted on Feishu.
# Save to workspace, not /tmp
output_path = "my_image.png" # relative to workspace
# Send via message tool:
# media: "file://<workspace_path>/my_image.png"
# (use 'media' parameter, NOT 'filePath')
After sending, clean up temporary images to avoid workspace clutter.
import os, sys
sys.path.insert(0, "skills/gemini-image-gen/scripts")
from generate import generate
generate(
prompt="a cute robot reading a philosophy book",
output="robot.png",
ref_image=None, # or path to reference image
)
| Model | Cost | Notes |
|---|---|---|
google/gemini-3.1-flash-image-preview | $0.25/$1.5 per M tokens | Default. Best balance of cost and quality |
google/gemini-3.1-pro-preview | $2/$12 per M tokens | Higher quality but 8x more expensive |
openai/gpt-image-1 | varies | OpenAI's image model, different API format — not supported by this script |
.debug.json file created alongside output. Usually means the prompt triggered safety filters or the model returned text-only.