Generate images using GLM-Image API. Use when the user wants to generate, create, or draw an image from a text prompt. Triggers on requests like "generate an image of...", "create a picture of...", "draw...", or any image generation request.
Generate images from text prompts using the GLM-Image API.
Attribution: Based on glm-image by ViffyGwaanl (MIT License).
This skill supports two providers. You only need one.
Requires GLM_API_KEY from https://open.bigmodel.cn → Console → API Keys
export GLM_API_KEY=your-key
# or add to ~/.openclaw/config.json: { "api_key": "your-key" }
# or add GLM_API_KEY=your-key to .env
Requires OPENROUTER_API_KEY from https://openrouter.ai → Keys
export OPENROUTER_API_KEY=your-key
# or add to ~/.openclaw/config.json: { "openrouter_api_key": "your-key" }
# or add OPENROUTER_API_KEY=your-key to .env
Default OpenRouter model: google/gemini-3-pro-image-preview. Other options: openai/gpt-5-image-mini, openai/gpt-5-image, google/gemini-2.5-flash-image-preview.
See full list at https://openrouter.ai/collections/image-models
Auto-detection: if both keys are present, GLM is used. Override with --provider openrouter.
When a user requests image generation:
Step 0 — Verify at least one API key is configured
Run:
python3 -c "
import os, json, pathlib
glm = bool(os.environ.get('GLM_API_KEY'))
orouter = bool(os.environ.get('OPENROUTER_API_KEY'))
if not glm and not orouter:
for p in ['~/.openclaw/config.json', '~/.claude/config.json']:
try:
d = json.loads(pathlib.Path(p).expanduser().read_text())
if d.get('api_key'): glm = True
if d.get('openrouter_api_key'): orouter = True
except: pass
keys = []
if glm: keys.append('GLM_API_KEY')
if orouter: keys.append('OPENROUTER_API_KEY')
print('FOUND: ' + ', '.join(keys) if keys else 'KEY_MISSING')
"
If output is KEY_MISSING, tell the user:
"No API key is configured. This skill supports two providers — you only need one:
Option A — GLM (BigModel): Get key at https://open.bigmodel.cn → Console → API Keys, then:
export GLM_API_KEY=your-keyOption B — OpenRouter: Get key at https://openrouter.ai → Keys, then:
export OPENROUTER_API_KEY=your-keyFor either option you can also add the key to
~/.openclaw/config.json:{ "api_key": "glm-key" } { "openrouter_api_key": "openrouter-key" } ```"
Do not proceed until the user confirms a key is set.
Step 1 — Ask for language (MANDATORY, no exceptions)
Before running anything, ask:
"What language is your prompt in? Please choose: zh (Chinese), en (English), ja (Japanese), ko (Korean), fr (French), de (German), es (Spanish)."
Do NOT infer language from the user's message language or any other signal. Do NOT default to any language. Do NOT proceed until the user explicitly states a language code.
Step 2 — Run the generation script
python3 scripts/generate.py "<prompt>" --language <code>
--language is required. The script will error if omitted.
Other defaults:
output/ folderStep 3 — Return the result
Display the markdown image link and local file path.
python3 scripts/generate.py "<prompt>" --language <zh|en|ja|ko|fr|de|es>
Provider is auto-detected from available keys. Override explicitly:
# Force OpenRouter with a specific model
python3 scripts/generate.py "<prompt>" --language en --provider openrouter --model google/gemini-2.5-flash-image-preview
# Force GLM
python3 scripts/generate.py "<prompt>" --language zh --provider glm
--language: (Required) Prompt language. Must be explicitly provided by the user. Supported: zh (Chinese), en (English), ja (Japanese), ko (Korean), fr (French), de (German), es (Spanish)--provider: glm or openrouter. Auto-detected if omitted (GLM preferred when both keys present)--model: OpenRouter model slug (default: google/gemini-3-pro-image-preview). Ignored for GLM. See https://openrouter.ai/collections/image-models--size: Image dimensions, GLM only (default: 1088x1920). Valid range: 512-2048px, multiples of 32--output: Output directory (default: output/)--quality: Image quality, GLM only — "hd" or "standard" (default: hd)--watermark: Enable watermark, GLM onlyzh, en) — do not normalize.After successful generation, display:
output/<timestamp>_<prompt>.pngThis skill is executed by the main OpenClaw agent session. The generate.py script
runs as a shell command via the exec tool. No sub-agents are spawned.
Image generation succeeds when:
Failure conditions: invalid API key, unsupported size, network timeout (120s), API quota exceeded.
requests package (pip install requests)