ms-image-gen
4
总安装量
4
周安装量
#51638
全站排名
安装命令
npx skills add https://github.com/hansonyyds/beary-skills --skill ms-image-gen
Agent 安装分布
gemini-cli
4
github-copilot
4
codex
4
kimi-cli
4
opencode
4
amp
4
Skill 文档
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:
- Create config directory:
~/.modelscope-image-gen/ - 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
| Parameter | Type | Required | Description |
|---|---|---|---|
--prompt |
string | Yes* | Image generation prompt (required unless using –batch) |
--batch |
file | No | Batch prompts file (one per line) |
--model |
string | No | Model ID (default: from config or Tongyi-MAI/Z-Image-Turbo) |
--output |
path | No | Output directory (default: ./generated-images/) |
--filename |
string | No | Output filename without extension |
--width |
int | No | Image width (default: 1024) |
--height |
int | No | Image height (default: 1024) |
--count |
int | No | Number of images to generate (default: 1) |
--timeout |
int | No | Polling timeout in seconds (default: from config or 300) |
How It Works
Async Task Flow
- Submit Request: POST to
/v1/images/generationswith async mode - Poll Status: GET
/v1/tasks/{task_id}until completion - Download: Retrieve image from result URL
Error Handling
| Error | Cause | Solution |
|---|---|---|
FileNotFoundError |
Config missing | Run setup to create config file |
401 Unauthorized |
Invalid API token | Check api_key in config |
429 Rate Limit |
Too many requests | Wait and retry |
TimeoutError |
Task too long | Increase poll_timeout |
Examples
See examples/batch-prompts.txt for sample prompts to use with batch generation.
Best Practices
- Validate prompts before submission to avoid wasted API calls
- Use batch mode for multiple generations to optimize throughput
- Set appropriate timeouts based on prompt complexity
- Save images immediately after successful generation
- Handle rate limits with proper retry strategies