SKILLS/image-generation-qwen/SKILL.md

4.1 KiB

name description metadata
qwen-image-generation Generate images using Qwen DashScope API with support for custom prompts, aspect ratios, and multiple image generation.
clawdbot
emoji os
🎨
linux
darwin
win32

Qwen Image Generation SKILL

Description

Generate images using Qwen (通义千问) API via DashScope. Supports custom prompts, aspect ratios, generation count, prompt enhancement, and image-to-image generation.

Quick Start (MCP Server)

Setup

  1. Set the environment variable:

    export DASHSCOPE_API_KEY=your-api-key
    
  2. Add to your MCP client config (e.g., Claude Desktop, Cursor, etc.):

    {
      "mcpServers": {
        "qwen-image": {
          "command": "python",
          "args": ["path/to/qwen_image_mcp.py"]
        }
      }
    }
    
  3. Use the generate_image tool:

    generate_image({
      prompt: "A beautiful mountain landscape at sunset",
      size: "1024*1024"
    })
    

MCP Tool: generate_image

Parameter Type Required Default Description
prompt string true - Image generation prompt (max 800 chars)
negative_prompt string false - Negative prompt to avoid elements (max 500 chars)
prompt_extend boolean false true Enable prompt enhancement
size string false 1024*1024 Image resolution
n integer false 1 Number of images (1-6)
image_url string false - Reference image URL for img2img
output_path string false - Local path to save image

Size Options

Size Aspect Ratio
1024*1024 1:1 (default)
1344*768 16:9
768*1344 9:16
1184*864 4:3
864*1184 3:4

Example Usage

// Basic generation
{
  "prompt": "A beautiful mountain landscape at sunset"
}

// High resolution with multiple images
{
  "prompt": "A realistic portrait",
  "size": "1024*1024",
  "n": 3
}

// With reference image
{
  "prompt": "Transform to oil painting style",
  "image_url": "https://example.com/input.jpg"
}

// With local save
{
  "prompt": "A sunset over the ocean",
  "output_path": "./output/sunset"
}

// With negative prompt
{
  "prompt": "A beautiful garden",
  "negative_prompt": "blurry, low quality, distorted"
}

CLI Usage

python scripts/run.py --api-key "your-api-key" --prompt "your-prompt" [options]

CLI Arguments

Argument Type Required Description
--api-key string true DashScope API key
--prompt string true Generation prompt
--size string false Image size (default: 1024*1024)
--n integer false Number of images (default: 1, max: 6)
--negative-prompt string false Negative prompt
--prompt-extend boolean false Enable prompt extend (default: true)
--image-url string false Reference image URL for img2img
--output-path string false Local path to save image

API Reference

  • Endpoint: POST https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation
  • Auth: Bearer Token
  • Env Var: DASHSCOPE_API_KEY
  • Model: qwen-image-2.0-pro

Examples

MCP Server Examples

generate_image({ prompt: "A sunset over the ocean" })

generate_image({ 
  prompt: "A realistic portrait",
  size: "1024*1024",
  n: 3
})

generate_image({
  prompt: "Transform into anime style",
  image_url: "https://example.com/photo.jpg"
})

CLI Examples

# Basic generation
python scripts/run.py --api-key "sk-xxx" --prompt "A sunset"

# Multiple images with custom size
python scripts/run.py --api-key "sk-xxx" --prompt "A portrait" --size "1024*1024" --n 3

# With negative prompt
python scripts/run.py --api-key "sk-xxx" --prompt "A garden" --negative-prompt "blurry, low quality"

# With reference image
python scripts/run.py --api-key "sk-xxx" --prompt "Transform to anime style" --image-url "https://example.com/photo.jpg"

# Save to local path
python scripts/run.py --api-key "sk-xxx" --prompt "A mountain" --output-path "./output/mountain"