name: aliyun-image description: "阿里雲百鍊影像生成、編輯與翻譯。文生圖:根據文本生成影像,支援複雜文字渲染。影像編輯:單圖編輯、多圖融合、風格遷移、物體增刪。影像翻譯:翻譯影像中的文字,保留原始排版,支援11種源語言和14種目標語言。觸發詞:生成圖片、AI作畫、文生圖、影像編輯、修圖、換背景、風格遷移、多圖融合、影像翻譯、圖片翻譯。模型:qwen-image-plus(預設)、qwen-image-max、qwen-image-edit-plus(預設)、qwen-image-edit-max、qwen-mt-image。" metadata: { "openclaw": { "repository": "https://github.com/StanleyChanH/aliyun-image-skill", "clawhub": "https://clawhub.com/skill/aliyun-image", "sync": "GitHub 和 ClawHub 同步更新" } }
7w4.net小蔥技能站收錄全網優質技能,值得收藏。
# 配置 API Key
export DASHSCOPE_API_KEY="sk-xxxx"
import os, requests
resp = requests.post(
"https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation",
headers={"Authorization": f"Bearer {os.getenv('DASHSCOPE_API_KEY')}"},
json={
"model": "qwen-image-plus",
"input": {"messages": [{"role": "user", "content": [{"text": "一隻橘貓在陽光下打盹"}]}]},
"parameters": {"prompt_extend": True, "watermark": False}
}
)
print(resp.json()["output"]["choices"][0]["message"]["content"][0]["image"])
resp = requests.post(
"https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation",
headers={"Authorization": f"Bearer {os.getenv('DASHSCOPE_API_KEY')}"},
json={
"model": "qwen-image-edit-plus",
"input": {"messages": [{"role": "user", "content": [
{"image": "https://example.com/photo.jpg"},
{"text": "把背景換成星空"}
]}]},
"parameters": {"prompt_extend": True, "watermark": False}
}
)
print(resp.json()["output"]["choices"][0]["message"]["content"][0]["image"])
import os, requests, time
# 1. 建立翻譯任務
resp = requests.post(
"https://dashscope.aliyuncs.com/api/v1/services/aigc/image2image/image-synthesis",
headers={
"Authorization": f"Bearer {os.getenv('DASHSCOPE_API_KEY')}",
"X-DashScope-Async": "enable"
},
json={
"model": "qwen-mt-image",
"input": {
"image_url": "https://example.com/english-poster.jpg",
"source_lang": "en",
"target_lang": "zh"
}
}
)
task_id = resp.json()["output"]["task_id"]
# 2. 輪詢獲取結果
while True:
time.sleep(3)
result = requests.get(
f"https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}",
headers={"Authorization": f"Bearer {os.getenv('DASHSCOPE_API_KEY')}"}
).json()
if result["output"]["task_status"] == "SUCCEEDED":
print(result["output"]["image_url"])
break
| 場景 | 預設模型 | 高質量模型 |
|---|---|---|
| 文生圖 | qwen-image-plus |
qwen-image-max |
| 影像編輯 | qwen-image-edit-plus |
qwen-image-edit-max |
| 影像翻譯 | qwen-mt-image |
- |
規則:預設使用 Plus 系列,僅當用戶明確要求"最好的"、"最高質量"時使用 Max 系列。
{
"negative_prompt": "低解析度,低畫質,肢體畸形,手指畸形,畫面過飽和,蠟像感",
"prompt_extend": true,
"watermark": false
}
按需載入以下文件:
| 文件 | 用途 |
|---|---|
| references/text-to-image.md | 文生圖完整API參考:模型列表、解析度、所有引數 |
| references/image-edit.md | 影像編輯完整API參考:單圖編輯、多圖融合、輸入要求 |
| references/image-translate.md | 影像翻譯完整API參考:支援語言、非同步呼叫、術語定義 |
| 指令碼 | 用途 |
|---|---|
| scripts/client.py | 封裝好的API客戶端,支援文生圖、影像編輯和影像翻譯 |
使用指令碼:
# 文生圖
python scripts/client.py generate "一隻橘貓在陽光下打盹" --size 1920*1080
# 影像編輯
python scripts/client.py edit "https://example.com/photo.jpg" "把背景換成星空" -n 2
# 影像翻譯
python scripts/client.py translate "https://example.com/english.jpg" --source en --target zh
| 錯誤碼 | 原因 | 解決方案 |
|---|---|---|
InvalidApiKey |
API Key無效 | 檢查環境變數配置 |
InvalidParameter |
引數錯誤 | 檢查請求格式 |
DataInspectionFailed |
內容稽核失敗 | 修改輸入內容 |
這個Skill質量中規中矩,勝在功能全面,一站式提供影像生成、編輯、翻譯三種能力。文件示例豐富,小白也能照著上手。但說明書有點冗長,找重點要費點功夫。翻譯功能支援的語言多是個亮點,整體適合需要阿里雲圖像能力的開發者使用,普通使用者可能需要花點時間消化。.