modelscope-zimage-generator
Original:🇺🇸 English
Translated
1 scriptsChecked / no sensitive code detected
Generate images using ModelScope Z-Image models (Z-Image-Turbo, Z-Image, Z-Image-Edit). Use when user asks to generate images, create artwork, or requests image generation functionality. Supports async generation with polling and optional LoRA configurations. IMPORTANT - Model Selection Rule: If the user explicitly mentions "Z-Image-Turbo" in their prompt, use "Tongyi-MAI/Z-Image-Turbo"; if they explicitly mention "Z-Image" (without Turbo), use "Tongyi-MAI/Z-Image"; otherwise, use the default "Tongyi-MAI/Z-Image-Turbo".
5installs
Sourcehaiyuan-ai/agent-skills
Added on
NPX Install
npx skill4agent add haiyuan-ai/agent-skills modelscope-zimage-generatorTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →ModelScope Z-Image Generator
Generate images using ModelScope's Z-Image series models.
IMPORTANT: Response Format
After generating an image, you MUST:
- Use the Python script to generate the image
- Respond with ONLY a simple text message like: "Image saved to: /path/to/output.jpg"
- DO NOT include the image URL in your response
- DO NOT try to display or reference the image URL - this will cause errors with non-multimodal models
The user can view the generated image at the file path you provide.
Prerequisites
Get your ModelScope API key from: https://modelscope.cn/my/myaccesstoken
The script will automatically prompt for your API key the first time you use it and offer to save it for future use.
Optional: Manual Configuration
You can also manually configure the API key:
Config file:
bash
mkdir -p ~/.config/modelscope
cat > ~/.config/modelscope/config.json << EOF
{
"api_key": "ms-your-api-key-here"
}
EOFEnvironment variable:
bash
export MODELSCOPE_API_KEY="ms-your-api-key-here"Quick Start
Use the Python script to generate images:
bash
cd /Users/ningoo/.claude/skills/modelscope-image-generator/scripts
python generate_image.py "A golden cat" output.jpgModels
Available Z-Image models:
- (default, fast generation)
Tongyi-MAI/Z-Image-Turbo - (balanced quality and speed)
Tongyi-MAI/Z-Image - (image editing)
Tongyi-MAI/Z-Image-Edit
Model Selection Rule
- If the user explicitly mentions "Z-Image-Turbo", use
Tongyi-MAI/Z-Image-Turbo - If the user explicitly mentions "Z-Image" (without Turbo), use
Tongyi-MAI/Z-Image - Otherwise, use the default
Tongyi-MAI/Z-Image-Turbo
Specify a different model using :
--modelbash
python generate_image.py "A golden cat" output.jpg --model "Tongyi-MAI/Z-Image-Turbo"LoRA Support
Single LoRA:
python
"loras": "<lora-repo-id>"Multiple LoRAs (weights must sum to 1.0):
python
"loras": {"<lora-id1>": 0.6, "<lora-id2>": 0.4}API Flow
- Submit generation request with
X-ModelScope-Async-Mode: true - Receive in response
task_id - Poll with
/v1/tasks/{task_id}X-ModelScope-Task-Type: image_generation - Wait for status or
SUCCEEDFAILED - Download image from URL
output_images[0]