zai-image-generation-skill

zai-image-generation-skill is a skill for OpenCode from darellchua2/opencode-config-template. It costs 53 tokens per session (1,862 once invoked), scanned A, original, Apache-2.0.

An image-generation recipe that sends a text prompt to Z.AI’s image service and downloads the result as a local PNG file. It uses a direct image-generation API rather than a chat response.

In plain words
What is it for?
Use it to create bitmap images from text prompts and save them on disk for later work.
Why use it?
It turns a temporary online result into a persistent file that the project can keep and use.

Skill for OpenCode

Written for OpenCode: installed under .opencode/. Also seen: mentions OpenCode.

Good fit Use it to create bitmap images from text prompts and save them on disk for later work.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/darellchua2/opencode-config-template/zai-image-generation-skill
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add darellchua2/opencode-config-template --skill zai-image-generation-skill
Clone the repo
git clone --depth 1 https://github.com/darellchua2/opencode-config-template

Made for: OpenCode.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for zai-image-generation-skill

README.md
[![agentmods](https://agentmods.dev/badge/skills/darellchua2/opencode-config-template/zai-image-generation-skill.svg)](https://agentmods.dev/skills/darellchua2/opencode-config-template/zai-image-generation-skill)
Your own site
<a href="https://agentmods.dev/skills/darellchua2/opencode-config-template/zai-image-generation-skill"><img src="https://agentmods.dev/badge/skills/darellchua2/opencode-config-template/zai-image-generation-skill.svg" alt="Measured on agentmods" height="20"></a>
Per session 53 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,862 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 6 findings, up to high

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • high Supply Chain · line 54
    Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.
    Fix: Avoid downloading and executing remote scripts. Use trusted packages from PyPI/npm. If remote fetch is required, verify checksums and use HTTPS.
  • medium Data Exfiltration · line 51
    Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
    Fix: Verify the destination URL is trusted and necessary. Remove or replace with documented APIs. Ensure no secrets, tokens, or PII are transmitted.
  • medium Data Exfiltration · line 89
    Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
    Fix: Verify the destination URL is trusted and necessary. Remove or replace with documented APIs. Ensure no secrets, tokens, or PII are transmitted.
  • medium Data Exfiltration · line 115
    Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
    Fix: Verify the destination URL is trusted and necessary. Remove or replace with documented APIs. Ensure no secrets, tokens, or PII are transmitted.
  • medium Data Exfiltration · line 54
    Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
    Fix: Verify the destination URL is trusted and necessary. Remove or replace with documented APIs. Ensure no secrets, tokens, or PII are transmitted.
  • medium Prompt Injection · line 82
    Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.
    Fix: Remove the large whitespace padding (blank-line blocks or long space runs) and review any content hidden below or to the right of it. Keep skill files compact and reviewable so no instructions can be
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00053 $0.01862
Opus 5 $0.00026 $0.00931
Sonnet 5 $0.00011 $0.00372
Haiku 4.5 $0.00005 $0.00186

Measured 4d ago against content hash 43bf7660c45b, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

zai-image-generation-skill scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

RESP=$(curl -sS --max-time 180 -X POST "$ENDPOINT/images/generations" \
opencode_app/.opencode/skills/zai-image-generation-skill/SKILL.md · 122 lines

How it starts

The opening of the file, as written. The whole thing — 122 lines — stays where its author put it; the contents beside it link to each section on GitHub.

What I do

I provide the exact recipe for an agent to generate an image from a text prompt via the Z.AI GLM-Image API and save it to a local file. OpenCode's provider layer is chat-only, so image generation (a separate /images/generations endpoint) is reachable only through a direct HTTP call. The API returns a temporary URL (expires in ~30 days) on mfile.z.ai, so the recipe always downloads the result to a persistent file on disk.

Why a skill (not a provider)

  • OpenCode providers (@ai-sdk/openai-compatible) speak chat completions — they cannot hit the /images/generations endpoint or return binary files.
  • GLM-Image is a dedicated generation model (glm-image, cogview-4-250304), separate from the chat/vision lineup. Calling it requires a targeted POST {base}/images/generations.
  • The result is a URL, not text — a file must be produced and its path returned to the caller.

Prerequisite — API key resolution

The recipe resolves the key robustly (env first, then opencode's credential store):

KEY="${ZAI_API_KEY:-$(jq -r '.["zai-coding-plan"].key // .["zai"].key // empty' \
     ~/.local/share/opencode/auth.json 2>/dev/null)}"
[ -z "$KEY" ] && { echo "ZAI_API_KEY not found — set it (export ZAI_API_KEY=...) or run \`opencode auth login\` (Z.AI)."; exit 1; }

If neither source has the key, stop and report — do not proceed.

Recipe

Set the options, then run generate → extract URL → download → verify:

# --- options ---
PROMPT="A cute kitten on a sunny windowsill, blue sky and white clouds"  # REQUIRED
OUT="${OUT:-./glm-image-$(date +%s).png}"          # output path (default: ./glm-image-<ts>.png)
SIZE="${SIZE:-1280x1280}"                           # glm-image: 1280x1280 | 1568x1056 | 1056x1568 | 1472x1088 | 1088x1472 | 1728x960 | 960x1728
QUALITY="${QUALITY:-standard}"                      # standard (~5-10s) | hd (~20s, richer detail)
MODEL="${MODEL:-glm-image}"                         # glm-image (default) | cogview-4-250304
ENDPOINT="${ZAI_IMAGE_ENDPOINT:-https://api.z.ai/api/coding/paas/v4}"  # coding plan (subscription). Alt: https://api.z.ai/api/paas/v4 (pay-as-you-go)

# --- 1. generate ---
RESP=$(curl -sS --max-time 180 -X POST "$ENDPOINT/images/generations" \
  -H "Authorization: Bearer $KEY" \
  -H 'Content-Type: application/json' \
  -d "$(python3 -c 'import json,sys
print(json.dumps({"model":sys.argv[1],"prompt":sys.argv[2],"size":sys.argv[3],"quality":sys.argv[4]}))' \
      "$MODEL" "$PROMPT" "$SIZE" "$QUALITY")")

# --- 2. extract URL (or surface the error) ---
URL=$(printf '%s' "$RESP" | python3 -c '
import sys, json
d = json.load(sys.stdin)
if d.get("error"):
    sys.stderr.write("API error: " + json.dumps(d["error"]) + "\n"); sys.exit(1)
print(d.get("data",[{}])[0].get("url",""))') || { echo "Generation failed. Response: $RESP"; exit 1; }
[ -z "$URL" ] && { echo "No image URL in response: $RESP"; exit 1; }

# --- 3. download to file (follow redirects; URL contains '?') ---
curl -L -sS --max-time 120 -o "$OUT" "$URL" || { echo "Download failed for $URL"; exit 1; }

# --- 4. verify it's a real image ---
file "$OUT" | grep -qiE 'image|png|jpeg' && echo "SAVED: $OUT ($(wc -c <"$OUT") bytes)" \
  || { echo "Downloaded file is not an image: $(file "$OUT")"; exit 1; }

Read the full file on GitHub · 122 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 122 lines · 53 tokens per session scan A 43bf7660c45b

Subscribe to this mod's changes

zai-image-generation-skill is a skill published in the GitHub repository darellchua2/opencode-config-template (6 stars, last pushed yesterday), licensed Apache-2.0. It adds 53 tokens to every session and 1,862 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

minimax-cli

Nested swiss-knife reference for the MiniMax mmx CLI and the canonical MiniMax CLI procedure shipped with the TUI: install mmx-cli, discover the correct TUI-managed MiniMax preset/key slot without leaking secrets, match mainland vs international regions, and route image/video/music/TTS generation or one-shot shell…

Lingtai-AI/lingtai · 72 tokens

media-generation

Generate and edit images, create videos, synthesize speech, transcribe and translate audio using multiple AI providers (OpenAI, Google, ElevenLabs, Deepgram, Fal, Luma, Replicate, Stability, Runway, OpenRouter, Edge TTS). Use when the user asks to create media assets, generate pictures, make videos, produce…

onimusya/media-gen · 88 tokens

kling-video

Generate AI videos using Kling video generation models. Use when you need to: (1) create videos from text prompts, (2) animate images into videos, (3) transform existing videos with AI, or (4) create AI avatar videos with speech.

refly-ai/refly-skills · 56 tokens

webgl-holographic-foil

A self-contained WebGL2 hero: thin-film interference over a crushed-foil surface whose palette shifts with the viewing angle; move the cursor to tilt the film.

nexu-io/open-design · 41 tokens

general-video

Author or edit a custom HyperFrames composition when no specialized workflow fits, or when BRIEF.md sets flow: companion. Use for longer or multi-scene pieces, brand and sizzle reels, montages, static loops, static title cards, footage remixes, and freeform builds. Use motion-graphics instead for a short unnarrated…

heygen-com/hyperframes · 92 tokens

html-ppt-hermes-cyber-terminal

OpenDesign + BYOK: choosing and wiring your own model, hands-on — cost, quality, and the routing decision. Built as a decision-grade AI literacy deck for engineers, IT, applied-AI teams.

nexu-io/open-design · 53 tokens