ms-image-gen

AI image generation using ModelScope API. Use when user requests to generate, create, draw, paint, or make images through natural language. Supports Chinese and English prompts. Handles async API tasks, batch generation, and automatic configuration management.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "ms-image-gen" with this command: npx skills add hansonyyds/beary-skills/hansonyyds-beary-skills-ms-image-gen

ModelScope Image Generation

Generate AI images through ModelScope API with natural language support in Chinese and English.

Quick Start

Generate an image directly:

python "${SKILL_ROOT}/scripts/image-gen.py" --prompt "A golden cat sitting on velvet"

Or with Chinese:

python "${SKILL_ROOT}/scripts/image-gen.py" --prompt "一只金色的猫坐在天鹅绒垫子上"

Natural Language Triggers

This skill automatically activates when users say:

Chinese:

  • "生成[描述]" - Generate [description]
  • "画一个[描述]" - Draw a [description]
  • "创建一张[描述]图片" - Create a [description] image
  • "帮我画..." - Help me draw...
  • "AI绘画..." - AI art...

English:

  • "Generate [description]"
  • "Draw a [description]"
  • "Create a [description] image"
  • "Make a picture of..."
  • "Create an image of..."

Configuration

Setup API Token

Before generating images, configure your ModelScope API token:

  1. Create config directory: ~/.modelscope-image-gen/
  2. Create modelscope-image-gen.local.md:
---
api_key: your_modelscope_api_token_here
default_model: Tongyi-MAI/Z-Image-Turbo
default_width: 1024
default_height: 1024
poll_timeout: 300
output_dir: ./generated-images/
---

Getting API Token

Visit ModelScope to get your API token.

Usage

Single Image Generation

python "${SKILL_ROOT}/scripts/image-gen.py" \
  --prompt "A sunset over mountains" \
  --output ./generated-images/

Batch Generation

Create a prompts file (one per line):

python "${SKILL_ROOT}/scripts/image-gen.py" \
  --batch examples/batch-prompts.txt \
  --output ./generated-images/

Custom Parameters

python "${SKILL_ROOT}/scripts/image-gen.py" \
  --prompt "Futuristic city at night" \
  --model Tongyi-MAI/Z-Image-Turbo \
  --width 1024 \
  --height 1024 \
  --filename city-night \
  --timeout 300

Multiple Images

python "${SKILL_ROOT}/scripts/image-gen.py" \
  --prompt "Abstract art" \
  --count 5 \
  --output ./generated-images/

Script Parameters

ParameterTypeRequiredDescription
--promptstringYes*Image generation prompt (required unless using --batch)
--batchfileNoBatch prompts file (one per line)
--modelstringNoModel ID (default: from config or Tongyi-MAI/Z-Image-Turbo)
--outputpathNoOutput directory (default: ./generated-images/)
--filenamestringNoOutput filename without extension
--widthintNoImage width (default: 1024)
--heightintNoImage height (default: 1024)
--countintNoNumber of images to generate (default: 1)
--timeoutintNoPolling timeout in seconds (default: from config or 300)

How It Works

Async Task Flow

  1. Submit Request: POST to /v1/images/generations with async mode
  2. Poll Status: GET /v1/tasks/{task_id} until completion
  3. Download: Retrieve image from result URL

Error Handling

ErrorCauseSolution
FileNotFoundErrorConfig missingRun setup to create config file
401 UnauthorizedInvalid API tokenCheck api_key in config
429 Rate LimitToo many requestsWait and retry
TimeoutErrorTask too longIncrease poll_timeout

Examples

See examples/batch-prompts.txt for sample prompts to use with batch generation.

Best Practices

  1. Validate prompts before submission to avoid wasted API calls
  2. Use batch mode for multiple generations to optimize throughput
  3. Set appropriate timeouts based on prompt complexity
  4. Save images immediately after successful generation
  5. Handle rate limits with proper retry strategies

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

polisher

No summary provided by upstream source.

Repository SourceNeeds Review
General

article-analyzer

No summary provided by upstream source.

Repository SourceNeeds Review
General

outliner

No summary provided by upstream source.

Repository SourceNeeds Review
General

beary-style

No summary provided by upstream source.

Repository SourceNeeds Review