image-generation

Generate base64-encoded images from text prompts using the z-ai-web-dev-sdk API and CLI.

Updated Jul 11, 2026
One-click install
npx skills add https://github.com/mukaddam-ali/Anadolu-Kitchen --skill image-generation-mukaddam-ali
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: image-generation
Source: https://github.com/mukaddam-ali/Anadolu-Kitchen/tree/main/skills/image-generation
Command: npx skills add https://github.com/mukaddam-ali/Anadolu-Kitchen --skill image-generation-mukaddam-ali

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires z-ai-web-dev-sdk, and includes scripts (resource) components.

What problem does it solve? Creating visual assets like hero banners, logos, product images, and illustrations normally requires design tools or stock photo searches. This Skill lets developers generate images directly from text descriptions inside backend code or from the command line. ## Core Features & Use Cases - Text-to-Image API: Generate images via z-ai-web-dev-sdk with seven supported sizes (square, portrait, landscape, wide) returned as base64 data saved to PNG files. - CLI Tool: Run z-ai image -p "prompt" -o output.png -s 1344x768 for quick one-off asset generation without writing code. - Batch & Service Patterns: Includes batch generation, caching, retry logic with exponential backoff, and an Express.js API endpoint example. - Use Case: A developer building a marketing site can generate a hero banner, team illustration, and logo in one shell script, then wire an API endpoint so users can generate images on demand. ## Quick Start Ask the AI to generate a 1440x720 hero banner image of a modern tech office and save it to ./assets/hero.png using the image generation skill.

Frequently Asked Questions about image-generation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate an image from a text prompt in Node.js?

Import ZAI from z-ai-web-dev-sdk, call ZAI.create(), then use zai.images.generations.create with a prompt and size. The response contains base64 image data that you decode with Buffer.from and write to a PNG file.

How to generate images from the command line with z-ai CLI?

Run z-ai image with the -p flag for the prompt, -o for the output path, and -s for size. For example: z-ai image -p "A sunset" -o ./sunset.png -s 1344x768 generates and saves the image directly.

What image sizes does z-ai-web-dev-sdk support?

Seven sizes are supported: 1024x1024 square, 768x1344 and 864x1152 portrait, 1344x768 and 1152x864 landscape, 1440x720 wide landscape, and 720x1440 tall portrait. Other size values are rejected.

Can I use z-ai-web-dev-sdk in client-side browser code?

No, the SDK must be used in backend code only. Calling it from client-side code causes an error. Expose image generation through a server endpoint such as an Express.js API route instead.

Why does image generation fail or return corrupted files?

Failures usually come from invalid size parameters, missing base64 data in the response, or incorrect decoding. Validate the size against the supported list, check response.data[0].base64 exists, and implement retry logic with exponential backoff.