{"skill":{"slug":"glm-image","displayName":"GLM Image Generator","summary":"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...","description":"---\nname: glm-image\ndescription: 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.\n---\n\n# GLM-Image Generator\n\nGenerate images from text prompts using the GLM-Image API.\n\n> **Attribution:** Based on [glm-image](https://github.com/ViffyGwaanl/glm-image) by ViffyGwaanl (MIT License).\n\n## Setup\n\nThis skill supports two providers. **You only need one.**\n\n### Option A — GLM (BigModel / Zhipu AI)\n\nRequires `GLM_API_KEY` from https://open.bigmodel.cn → Console → API Keys\n\n```bash\nexport GLM_API_KEY=your-key\n# or add to ~/.openclaw/config.json: { \"api_key\": \"your-key\" }\n# or add GLM_API_KEY=your-key to .env\n```\n\n### Option B — OpenRouter\n\nRequires `OPENROUTER_API_KEY` from https://openrouter.ai → Keys\n\n```bash\nexport OPENROUTER_API_KEY=your-key\n# or add to ~/.openclaw/config.json: { \"openrouter_api_key\": \"your-key\" }\n# or add OPENROUTER_API_KEY=your-key to .env\n```\n\nDefault 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`.\nSee full list at https://openrouter.ai/collections/image-models\n\n**Auto-detection:** if both keys are present, GLM is used. Override with `--provider openrouter`.\n\n## Usage\n\nWhen a user requests image generation:\n\n**Step 0 — Verify at least one API key is configured**\n\nRun:\n\n```bash\npython3 -c \"\nimport os, json, pathlib\nglm = bool(os.environ.get('GLM_API_KEY'))\norouter = bool(os.environ.get('OPENROUTER_API_KEY'))\nif not glm and not orouter:\n    for p in ['~/.openclaw/config.json', '~/.claude/config.json']:\n        try:\n            d = json.loads(pathlib.Path(p).expanduser().read_text())\n            if d.get('api_key'): glm = True\n            if d.get('openrouter_api_key'): orouter = True\n        except: pass\nkeys = []\nif glm: keys.append('GLM_API_KEY')\nif orouter: keys.append('OPENROUTER_API_KEY')\nprint('FOUND: ' + ', '.join(keys) if keys else 'KEY_MISSING')\n\"\n```\n\nIf output is `KEY_MISSING`, tell the user:\n\n> \"No API key is configured. This skill supports two providers — you only need one:\n>\n> **Option A — GLM (BigModel):** Get key at https://open.bigmodel.cn → Console → API Keys, then:\n> ```\n> export GLM_API_KEY=your-key\n> ```\n>\n> **Option B — OpenRouter:** Get key at https://openrouter.ai → Keys, then:\n> ```\n> export OPENROUTER_API_KEY=your-key\n> ```\n>\n> For either option you can also add the key to `~/.openclaw/config.json`:\n> ```json\n> { \"api_key\": \"glm-key\" }\n> { \"openrouter_api_key\": \"openrouter-key\" }\n> ```\"\n\nDo not proceed until the user confirms a key is set.\n\n**Step 1 — Ask for language (MANDATORY, no exceptions)**\n\nBefore running anything, ask:\n\n> \"What language is your prompt in? Please choose: zh (Chinese), en (English), ja (Japanese), ko (Korean), fr (French), de (German), es (Spanish).\"\n\nDo 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.\n\n**Step 2 — Run the generation script**\n\n```bash\npython3 scripts/generate.py \"<prompt>\" --language <code>\n```\n\n`--language` is required. The script will error if omitted.\n\nOther defaults:\n\n- Size: 1088x1920 (portrait HD)\n- Output: `output/` folder\n- No watermark\n\n**Step 3 — Return the result**\n\nDisplay the markdown image link and local file path.\n\n## Generate Image\n\n```bash\npython3 scripts/generate.py \"<prompt>\" --language <zh|en|ja|ko|fr|de|es>\n```\n\nProvider is auto-detected from available keys. Override explicitly:\n\n```bash\n# Force OpenRouter with a specific model\npython3 scripts/generate.py \"<prompt>\" --language en --provider openrouter --model google/gemini-2.5-flash-image-preview\n\n# Force GLM\npython3 scripts/generate.py \"<prompt>\" --language zh --provider glm\n```\n\n### Options\n\n- `--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)\n- `--provider`: `glm` or `openrouter`. Auto-detected if omitted (GLM preferred when both keys present)\n- `--model`: OpenRouter model slug (default: `google/gemini-3-pro-image-preview`). Ignored for GLM. See https://openrouter.ai/collections/image-models\n- `--size`: Image dimensions, GLM only (default: 1088x1920). Valid range: 512-2048px, multiples of 32\n- `--output`: Output directory (default: output/)\n- `--quality`: Image quality, GLM only — \"hd\" or \"standard\" (default: hd)\n- `--watermark`: Enable watermark, GLM only\n\n### Language Selection Rules\n\n- **Always ask explicitly.** Never guess from the user's message language.\n- **Never default.** If the user does not specify, ask again.\n- **Record as-typed.** Pass exactly what the user said (e.g., `zh`, `en`) — do not normalize.\n- Reason: GLM is a Chinese-native model; prompt language significantly affects output quality and style.\n\n### Available Sizes\n\n- 1088x1920 (default, portrait HD)\n- 1920x1088 (landscape HD)\n- 1280x1280 (square)\n- 1568x1056, 1056x1568\n- 1472x1088, 1088x1472\n- 1728x960, 960x1728\n\n## Output Format\n\nAfter successful generation, display:\n\n1. Local file path: `output/<timestamp>_<prompt>.png`\n2. Markdown image link: `![<prompt>](<url>)`\n\n## Agent Owner\n\nThis skill is executed by the main OpenClaw agent session. The `generate.py` script\nruns as a shell command via the exec tool. No sub-agents are spawned.\n\n## Success Criteria\n\nImage generation succeeds when:\n1. Script exits with code 0\n2. Image file saved to output/ directory\n3. Markdown image link displayed to user\n\nFailure conditions: invalid API key, unsupported size, network timeout (120s), API quota exceeded.\n\n## Edge Cases\n\n- Invalid size: must be 512-2048px in multiples of 32 — script will fail with API error\n- Long prompts: prompt truncated to 30 chars in filename (full prompt used for generation)\n- Network timeout: 120s API timeout, 60s download timeout — retry once if timeout\n- Missing API key: script exits with clear error message listing search locations\n- Chinese characters in prompt: supported, filename sanitized automatically\n\n## Requirements\n\n- GLM API key configured (see Setup section above)\n- Python 3 with `requests` package (`pip install requests`)\n","topics":["Image Generation","Prompt"],"tags":{"latest":"1.9.0"},"stats":{"comments":0,"downloads":409,"installsAllTime":15,"installsCurrent":1,"stars":0,"versions":2},"createdAt":1771397700097,"updatedAt":1778991383354},"latestVersion":{"version":"1.9.0","createdAt":1771487613137,"changelog":"Default OpenRouter model changed to google/gemini-3-pro-image-preview — better fallback when GLM API not present. Margin guard relaxed: model flexibility on dimensions while keeping comfortable margins. OpenRouter dual provider, cost display, language flag.","license":null},"metadata":null,"owner":{"handle":"chunhualiao","userId":"s17czb50cec363y7yz4cchy9p9848424","displayName":"Chunhua Liao","image":"https://avatars.githubusercontent.com/u/1627206?v=4"},"moderation":{"isSuspicious":false,"isMalwareBlocked":false,"verdict":"clean","reasonCodes":["review.llm_review"],"summary":"Review: review.llm_review","engineVersion":"v2.4.24","updatedAt":1779920613262}}