name: image-gen description: | Generate AI images from text prompts. Triggers on: "生成圖片", "畫一張", "AI圖", "generate image", "配圖", "create picture", "draw", "visualize", "generate an image". metadata: openclaw: emoji: "🖼️" requires: env: ["LISTENHUB_API_KEY"] primaryEnv: "LISTENHUB_API_KEY"
7w4.net小蔥技能站,你的AI助手技能庫。
/podcast, /speech)/explainer)/content-parser)Generate AI images using the Labnana API. Supports text prompts with optional reference images, multiple resolutions, and aspect ratios. Images are saved as local files.
shared/authentication.md for API key and headersshared/common-patterns.md for error handlinghttps://api.labnana.com/openapi/v1shared/config-pattern.md before any interaction.listenhub/image-gen/YYYY-MM-DD-{jobId}/ — never ~/Downloads/Follow shared/config-pattern.md § API Key Check. If the key is missing, stop immediately.
Follow shared/config-pattern.md Step 0.
If file doesn't exist — ask location, then create immediately:
mkdir -p ".listenhub/image-gen"
echo '{"outputDir":".listenhub","outputMode":"inline"}' > ".listenhub/image-gen/config.json"
CONFIG_PATH=".listenhub/image-gen/config.json"
# (or $HOME/.listenhub/image-gen/config.json for global)
Then run Setup Flow below.
If file exists — read config, display summary, and confirm:
當前配置 (image-gen):
輸出方式:{inline / download / both}
Ask: "使用已儲存的配置?" → 確認,直接繼續 / 重新配置
shared/output-mode.md § Setup Flow Question.Save immediately:
# Follow shared/output-mode.md § Save to Config
NEW_CONFIG=$(echo "$CONFIG" | jq --arg m "$OUTPUT_MODE" '. + {"outputMode": $m}')
echo "$NEW_CONFIG" > "$CONFIG_PATH"
CONFIG=$(cat "$CONFIG_PATH")
Free text input. Ask the user:
Describe the image you want to generate.
If the prompt is very short (< 10 words) and the user hasn't asked for verbatim generation, offer to help enrich the prompt. Otherwise, use as-is.
Ask:
Question: "Which model?"
Options:
- "pro (recommended)" — gemini-3-pro-image-preview, higher quality
- "flash" — gemini-3.1-flash-image-preview, faster and cheaper, unlocks extreme aspect ratios (1:4, 4:1, 1:8, 8:1)
Ask both together (independent parameters):
Question: "What resolution?"
Options:
- "1K" — Standard quality
- "2K (recommended)" — High quality, good balance
- "4K" — Ultra high quality, slower generation
Question: "What aspect ratio?"
Options (all models):
- "16:9" — Landscape, widescreen
- "1:1" — Square
- "9:16" — Portrait, phone screen
- "Other" — 2:3, 3:2, 3:4, 4:3, 21:9
If flash model was selected, also offer: 1:4 (narrow portrait), 4:1 (wide landscape), 1:8 (extreme portrait), 8:1 (panoramic)
Question: "Any reference images for style guidance?"
Options:
- "Yes, I have URL(s)" — Provide reference image URLs
- "No references" — Generate from prompt only
If yes, collect URLs (comma-separated, max 14). For each URL, infer mimeType from suffix and build:
{ "fileData": { "fileUri": "<url>", "mimeType": "<inferred>" } }
Suffix mapping: .jpg/.jpeg → image/jpeg, .png → image/png, .webp → image/webp, .gif → image/gif
Summarize all choices:
Ready to generate image:
Prompt: {prompt text}
Model: {pro / flash}
Resolution: {1K / 2K / 4K}
Aspect ratio: {ratio}
References: {yes (N URLs) / no}
Proceed?
Wait for explicit confirmation before calling the API.
POST https://api.labnana.com/openapi/v1/images/generation with timeout of 600sRead OUTPUT_MODE from config. Follow shared/output-mode.md for behavior.
inline or both: Decode base64 to a temp file, then use the Read tool.
JOB_ID=$(date +%s)
echo "$BASE64_DATA" | base64 -D > /tmp/image-gen-${JOB_ID}.jpg
Then use the Read tool on /tmp/image-gen-{jobId}.jpg. The image displays inline in the conversation.
Present:
圖片已生成!
download or both: Save to the artifact directory.
JOB_ID=$(date +%s)
DATE=$(date +%Y-%m-%d)
JOB_DIR=".listenhub/image-gen/${DATE}-${JOB_ID}"
mkdir -p "$JOB_DIR"
echo "$BASE64_DATA" | base64 -D > "${JOB_DIR}/${JOB_ID}.jpg"
Present:
圖片已生成!
已儲存到 .listenhub/image-gen/{YYYY-MM-DD}-{jobId}/:
{jobId}.jpg
Base64 decoding (cross-platform):
# Linux
echo "$BASE64_DATA" | base64 -d > output.jpg
# macOS
echo "$BASE64_DATA" | base64 -D > output.jpg
# or
echo "$BASE64_DATA" | base64 --decode > output.jpg
Retry logic: On 429 (rate limit), wait 15 seconds and retry. Max 3 retries.
Default: Pass the user's prompt directly without modification.
When to offer optimization: - Prompt is very short (a few words) AND user hasn't requested verbatim - Ask: "Would you like help enriching the prompt with style/lighting/composition details?"
When to never modify: - Long, detailed, or structured prompts — treat the user as experienced - User says "use this prompt exactly"
Optimization techniques (if user agrees): - Style: "cyberpunk" → add "neon lights, futuristic, dystopian" - Scene: time of day, lighting, weather - Quality: "highly detailed", "8K quality", "cinematic composition" - Always use English keywords (models trained on English) - Show optimized prompt before submitting
shared/api-image.mdshared/common-patterns.md § Error HandlingUser: "Generate an image: cyberpunk city at night"
Agent workflow: 1. Prompt is short → offer enrichment → user declines 2. Ask model → "pro" 3. Ask resolution → "2K" 4. Ask ratio → "16:9" 5. No references
RESPONSE=$(curl -sS -X POST "https://api.labnana.com/openapi/v1/images/generation" \
-H "Authorization: Bearer $LISTENHUB_API_KEY" \
-H "Content-Type: application/json" \
--max-time 600 \
-d '{
"provider": "google",
"model": "gemini-3-pro-image-preview",
"prompt": "cyberpunk city at night",
"imageConfig": {"imageSize": "2K", "aspectRatio": "16:9"}
}')
BASE64_DATA=$(echo "$RESPONSE" | jq -r '.candidates[0].content.parts[0].inlineData.data // .data')
JOB_ID=$(date +%s)
DATE=$(date +%Y-%m-%d)
JOB_DIR=".listenhub/image-gen/${DATE}-${JOB_ID}"
mkdir -p "$JOB_DIR"
echo "$BASE64_DATA" | base64 -D > "${JOB_DIR}/${JOB_ID}.jpg"
Decode the base64 data per outputMode (see shared/output-mode.md).
質量較好。文件寫得詳細清楚,互動步驟安排合理,會在生成前讓你確認所有選項,避免誤操作。支援多種風格和尺寸選擇,還有 prompt 最佳化建議幫助你寫出更好的描述。功能比較全面,常見需求都能覆蓋。不過示例偏少,遇到複雜需求時可能缺少參考,而且文件有些地方寫得比較簡略,遇到問題不太好排查。整體來說是個好用的 Skill,能滿足日常配圖、封面等場景需求。