Professional-grade AI image creation skill built on Alibaba Cloud DashScope API.
Warning: Before executing any image task, you must read and follow the "Mandatory Rules" section. Violations will cause task failure.
All image generation, editing, and understanding tasks must and can only be completed by running existing scripts in the scripts/ directory.
wanx-v1, wanx-v2, wan2.6-image and other legacy models are discontinuedMultiModalConversation.call(), Wanx models (wan2.7-) can only use ImageGeneration.call()Based on user request keywords, look up the table to select the script. No other methods are allowed:
User Request KeywordsScriptAPIDefault ModelWanx, wan2.7, reference image + generation, style fusion, multi-image fusion, graffiti-on-car, virtual try-onwanx_generate.py``ImageGeneration.call()``wan2.7-image4K HD text-to-imagewanx_generate.py``ImageGeneration.call()``wan2.7-image-proA set of coherent images, image series generationwanx_generate.py``ImageGeneration.call()``wan2.7-image-proText-to-image, generate image, draw a picture (no reference image)text_to_image.py``MultiModalConversation.call()``qwen-image-2.0-proEdit image (URL input)image_edit.py``MultiModalConversation.call()``qwen-image-edit-maxEdit image (local file)image_edit_base64.py``MultiModalConversation.call()``qwen-image-edit-maxAnalyze/understand image content, describe imageimage_understanding.py``chat.completions.create()``qwen3.5-plus
Disambiguation Priority Rules (when multiple keywords match simultaneously):
wanx_generate.py directly, regardless of whether "generate image" or similar words are presentwanx_generate.py (Wanx supports multi-image reference input)text_to_image.pyAllowed Models:
ScriptAllowed Modelstext_to_image.py``qwen-image-2.0-pro, qwen-image-2.0``wanx_generate.py``wan2.7-image-pro, wan2.7-image``image_edit.py / image_edit_base64.py``qwen-image-edit-max, qwen-image-2.0-pro, qwen-image-edit-plus, qwen-image-edit``image_understanding.py``qwen3.5-plus, qwen-vl-max, qwen-vl-plus
Scripts automatically handle key retrieval via api_key.py. The Agent does not need to and should not manually extract, set, or pass API Key values.
api_key.py to automatically obtain keys from config files/environment variables, or auto-create via CLI. The Agent only needs to run the script commandapi_key = "sk-...", export DASHSCOPE_API_KEY="sk-...", and assigning keys in shell scriptsaliyun modelstudio create-api-key is automatically saved by api_key.py. The Agent must not write this value into any script, variable, or filesk-cat ~/.aliyun/config.json, jq, python -c, or other commands to read and output API Key values from config filesaliyun modelstudio create-api-key or aliyun modelstudio list-api-keys. These commands are only called internally by api_key.pygrep -rn "sk-" <output_directory>/ to check all output files; if any strings starting with sk- are found (excluding "sk-xxx" placeholders), delete the affected files and regenerateCheck status code: API response status_code must be 200, otherwise abort the task
Check output content: Response must contain valid image URLs (starting with http). No valid URL means failure
Never fabricate results: Do not generate simulated data, false success reports, or placeholder image URLs
Never mock/simulate: Do not create mock scripts or simulate API calls to bypass real calls
Correct behavior on failure:
api_key.py will automatically retry creationgrep -rn "sk-" <output_directory>/ to check all output files (including logs, summaries, scripts). If leaks are found, delete and regenerateModel FamilySize FormatSupported Valuesqwen-image-2.0-pro / qwen-image-2.0 (text-to-image)"width*height"``1024*1024, 720*1280, 1280*720, 1440*720, 720*1440``qwen-image-edit-* / qwen-image-2.0-pro (editing)"width*height"Width and height each [512, 2048], freely combinedwan2.7-image-pro (text-to-image)Preset tier1K, 2K, 4K``wan2.7-image-pro (editing/series)Preset tier1K, 2K``wan2.7-imagePreset tier1K, 2K
Mapping Rules:
1280x720) -> Choose Qwen series, set size='1280*720'720*1280)size can only be 1K/ 2K/ 4K, not pixel valuesbash
pip install -r scripts/requirements.txt
Selection Logic: First check if the user mentions "Wanx"/"wan2.7" or provides reference image URLs -> If yes, use wanx_generate.py; otherwise match by other keywords in the mapping table.
API Key is automatically managed by scripts (three-level retrieval: config file -> environment variable -> auto-create). No manual key handling is needed. The Agent only needs to run the commands in the table below. Do not write your own scripts, set environment variables, or use curl to call APIs.
ScenarioCommandExampleText-to-image (Qwen)python scripts/text_to_image.py <prompt> [size] [model]``python scripts/text_to_image.py 'An orange cat sitting on a windowsill, 8K' 1024*1024 qwen-image-2.0-proText-to-image / Multi-image fusion (Wanx)python scripts/wanx_generate.py <prompt> [ref_image_URLs...]``python scripts/wanx_generate.py 'Paint the graffiti from image 2 on the car in image 1' url1 url2Image editing (URL input)python scripts/image_edit.py <instruction> <image_URL1> [URL2] [URL3]``python scripts/image_edit.py 'Change the background to white' https://example.com/photo.pngImage editing (local file)python scripts/image_edit_base64.py <instruction> <local_image1> [image2] [image3]``python scripts/image_edit_base64.py 'Change the background to white' ./photo.pngImage understandingpython scripts/image_understanding.py <image_URL> [question]``python scripts/image_understanding.py https://example.com/photo.jpg 'What is in this image?'
Scripts will print the list of generated image URLs; text_to_image.py also auto-downloads images to the current directory.
ConditionChoiceReasonNeed accurate in-image text renderingqwen-image-2.0-proQwen series has the strongest text rendering capabilityNeed 4K ultra-high definitionwan2.7-image-proOnly Wanx pro text-to-image supports 4KNeed a set of style-consistent imageswan2.7-image-pro + enable_sequentialWanx exclusive image series capabilityProduct/industrial design editingqwen-image-edit-maxStronger geometric reasoning and character consistencyMulti-image reference + compositionwan2.7-imageWanx supports flexible multi-image reference editingImage content analysis/Q&Aqwen3.5-plusGeneral multimodal understanding, cost-effectiveComplex visual reasoningqwen-vl-maxStronger visual understanding capabilityLow cost priorityqwen-image-2.0 / wan2.7-imageStandard version at lower costNo special requirements (default)qwen-image-2.0-proMost balanced overall capability
For detailed guide, see Prompt Design Guide
Prompt structure formula: [Subject description] + [Scene/environment] + [Lighting/mood] + [Composition/angle] + [Art style] + [Quality parameters]
Complete example:
text
A 30-year-old Asian male detective standing on a rainy night Tokyo street, wearing a dark gray trench coat, holding a black umbrella, neon red and blue lights reflecting on his face, raindrops dripping along the umbrella edge, puddles on the ground reflecting brilliant city lights, Rembrandt lighting, volumetric fog, cinematic composition, 35mm anamorphic lens, film grain, moody atmosphere, high detail, photorealistic, 8K
Negative prompt template (Qwen series supports negative_prompt, Wanx series does not):
text
low quality, blurry, pixelated, oversaturated, deformed hands, extra fingers, distorted face, uncanny valley, text, watermark, logo, signature, cropped, out of frame, worst quality
PackageVersion ConstraintPurposedashscope``==1.25.16Text-to-image, image editing, Wanx generationopenai``==2.23.0Image understanding (OpenAI-compatible interface)
This skill manages DashScope API Keys through scripts/api_key.py, which automatically validates key format (detects invalid keys like sk-sp-).
Retrieval Priority: ~/.aliyun/config.json > Environment variable DASHSCOPE_API_KEY > Auto-create via Alibaba Cloud CLI
Method 1: Alibaba Cloud CLI Config File (Recommended)
Add a dashscope field to the current profile in ~/.aliyun/config.json:
json
{
"current": "default",
"profiles": [
{
"name": "default",
"mode": "AK",
"access_key_id": "...",
"access_key_secret": "...",
"dashscope": {
"api_key": "sk-xxx",
"api_key_id": "4359606"
}
}
]
}
Method 2: System Environment Variable
bash
export DASHSCOPE_API_KEY=sk-xxx
ItemDescriptionKey Formatsk-xxx (standard DashScope API Key)Not Supportedsk-sp-xxx (Coding Plan Key, does not support image generation)Get Keyhttps://help.aliyun.com/zh/model-studio/get-api-keySecurityNever hardcode; use from api_key import get_api_key; never output full API Key values to terminal, logs, or any files
scripts/api_key.py creates and deletes API Keys via aliyun modelstudio commands. Complete the following setup before use:
bash
# Enable AI-Mode (allow Agent to call CLI)
aliyun configure ai-mode enable
# Set User-Agent
aliyun configure ai-mode set-user-agent --user-agent "AlibabaCloud-Agent-Skills/alibabacloud-bailian-image-creator"
# Update plugins to latest version
aliyun plugin update
# Install ModelStudio plugin (if not already installed)
aliyun plugin install --names aliyun-cli-modelstudio --enable-pre
# Disable AI-Mode after task completion
aliyun configure ai-mode disable
CommandPurposeCalled Fromaliyun modelstudio list-workspacesGet Bailian Workspace IDapi_key.py: generate_api_key()``aliyun modelstudio create-api-keyCreate DashScope API Keyapi_key.py: generate_api_key()``aliyun modelstudio list-api-keysList existing API Keys (used for limit recycling)api_key.py: generate_api_key()``aliyun modelstudio delete-api-keyDelete cloud API Keyapi_key.py: delete_api_key() / generate_api_key()
RegionDashScope APIOpenAI Compatible ModeBeijing (China)https://dashscope.aliyuncs.com/api/v1``https://dashscope.aliyuncs.com/compatible-mode/v1Singaporehttps://dashscope-intl.aliyuncs.com/api/v1``https://dashscope-intl.aliyuncs.com/compatible-mode/v1Virginia (US)https://dashscope-us.aliyuncs.com/api/v1``https://dashscope-us.aliyuncs.com/compatible-mode/v1
Note: API Keys are not interchangeable between regions.
ParameterDescriptionsizeOnly supports 1024*1024, 720*1280, 1280*720, 1440*720, 720*1440``prompt_extendTrue to auto-optimize promptsnegative_promptNegative prompt to avoid generating undesired contentwatermarkWhether to add watermark
ParameterTypeDescriptionnintNumber of output images, 1-6 ( qwen-image-edit fixed at 1)sizestrOutput resolution, format "width*height", range [512, 2048]negative_promptstrNegative promptprompt_extendboolSmart prompt rewriting, default truewatermarkboolWhether to add watermark, default falseseedintRandom seed [0, 2147483647], for result reproduction
Editing Model Comparison:
ModelStrengthsUse Caseqwen-image-edit-maxStrong geometric reasoning, character consistencyProduct design, precise editingqwen-image-2.0-proStrong text rendering, realistic qualityGeneral editing, text editingqwen-image-edit-plusMulti-image output and custom resolutionGeneral editingqwen-image-editBasic version, fixed single image outputSimple editing
Common Resolution Recommendations:
Aspect RatioRecommended Resolution1:11024*1024, 1536*15362:3768*1152, 1024*15363:21152*768, 1536*10243:4960*1280, 1080*14404:31280*960, 1440*10809:16720*1280, 1080*192016:91280*720, 1920*108021:91344*576, 2048*872
Image Input Methods:
"https://example.com/image.png""data:image/png;base64,..." -- See scripts/image_edit_base64.pyn parameter)ParameterDescriptionsize``1K, 2K, 4K (4K only for wan2.7-image-pro text-to-image)enable_sequentialSeries mode, generates 1-12 style-consistent imagesthinking_modeDefault true, enhances reasoning quality (increases latency)nNormal mode 1-4, series mode 1-12ModelStrengthswan2.7-image-proPro version, text-to-image supports 4K HDwan2.7-imageStandard version, faster generation
Uses OpenAI-compatible mode to call DashScope. Default model qwen3.5-plus (general understanding), optional qwen-vl-max (complex reasoning).
ModelUnit PriceNotesqwen-image-2.0-proCN pricePro version, strongest text rendering and realistic qualityqwen-image-edit-maxCN pricePro version, image generation and editing fusionqwen-image-2.0CN priceStandard versionqwen-image-edit-plusCN priceStandard editingwan2.7-image-proCN priceWanx pro versionwan2.7-imageCN priceWanx standard version
New users get 100 free image credits (valid for 90 days) after activating Bailian. View bills: https://usercenter2.aliyun.com/finance/expense-center/overview
prompt_extend=True to let the model auto-optimize promptsnegative_prompt, Wanx series does not support this parametern parameter to generate multiple images at once for selectionfile:// protocol for large filesScripts have built-in error handling logic. For errors, refer to: https://help.aliyun.com/zh/model-studio/developer-reference/error-code
ScriptFunctionDescriptiontext_to_image.pyText-to-imageGenerate images from text descriptions, supports auto-downloadimage_edit.pyImage editingSupports URL, local file, and Base64 input methodsimage_edit_base64.pyBase64 image editingDemonstrates Base64 encoding methodbase64_tool.pyBase64 toolCLI tool for image-Base64 conversionwanx_generate.pyWanx generationUses wan2.7-image model for generationimage_understanding.pyImage understandingAnalyze image content, answer questions