# Image Generation

Implement AI image generation capabilities using the z-ai-web-dev-sdk.

- Repository: https://github.com/jjyaoao/HelloAgents (3333 stars)
- Category: Design
- License: MIT
- Last updated: 2026-10-06
- Runs scripts: yes, review before use

## Install

Claude Code: `npx skills add jjyaoao/HelloAgents --skill image-generation -g -a claude-code -y`
Codex: `npx skills add jjyaoao/HelloAgents --skill image-generation -g -a codex -y`
Cursor: `npx skills add jjyaoao/HelloAgents --skill image-generation -g -a cursor -y`
Gemini CLI: `npx skills add jjyaoao/HelloAgents --skill image-generation -g -a gemini-cli -y`

## Description

Implement AI image generation capabilities using the z-ai-web-dev-sdk. Use this skill when the user needs to create images from text descriptions, generate visual content, create artwork, design assets, or build applications with AI-powered image creation. Supports multiple image sizes and returns base64 encoded images. Also includes CLI tool for quick image generation.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Image Generation Skill

This skill guides the implementation of image generation functionality using the z-ai-web-dev-sdk package and CLI tool, enabling creation of high-quality images from text descriptions.

## Skills Path

**Skill Location**: `{project_path}/skills/image-generation`

this skill is located at above path in your project.

**Reference Scripts**: Example test scripts are available in the `{Skill Location}/scripts/` directory for quick testing and reference. See `{Skill Location}/scripts/image-generation.ts` for a working example.

## Overview

Image Generation allows you to build applications that create visual content from text prompts using AI models, enabling creative workflows, design automation, and visual content production.

**IMPORTANT**: z-ai-web-dev-sdk MUST be used in backend code only. Never use it in client-side code.

## Prerequisites

The z-ai-web-dev-sdk package is already installed. Import it as shown in the examples below.

## Basic Image Generation

### Simple Image Creation

```javascript
import ZAI from 'z-ai-web-dev-sdk';
import fs from 'fs';

async function generateImage(prompt, outputPath) {
  const zai = await ZAI.create();

  const response = await zai.images.generations.create({
    prompt: prompt,
    size: '1024x1024'
  });

  const imageBase64 = response.data[0].base64;
  
  // Save image
  const buffer = Buffer.from(imageBase64, 'base64');
  fs.writeFileSync(outputPath, buffer);
  
  console.log(`Image saved to ${outputPath}`);
  return outputPath;
}

// Usage
await generateImage(
  'A cute cat playing in the garden',
  './cat_image.png'
);
```

### Multiple Image Sizes

```javascript
import ZAI from 'z-ai-web-dev-sdk';
import fs from 'fs';

// Supported sizes
const SUPPORTED_SIZES = [
  '1024x1024',  // Square
  '768x1344',   // Portrait
  '864x1152',   // Portrait
  '1344x768',   // Landscape
  '1152x864',   // Landscape
  '1440x720',   // Wide landscape
  '720x1440'    // Tall portrait
];

The rest: https://github.com/jjyaoao/HelloAgents/blob/HEAD/skills/image-generation/SKILL.md
