Files
market/skills/dashscope-image-gen/SKILL.md
xyx 42617e292d fix(dashscope-image-gen): 切换到 /images/generations 端点 v1.3.0 (#26)
## 概要 / Summary

修复 dashscope-image-gen 技能的核心端点问题,从 `/chat/completions`(对 wan 图片模型返回 HTTP
400)切换到 `/images/generations`,同时新增多项防护措施防止模型偏离执行路径。

Fix the core endpoint issue: switch from `/chat/completions` (returns
HTTP 400 for wan image models) to `/images/generations`, with enhanced
guardrails to prevent model deviation.

## 变更内容 / Changes

**核心修复**
- 端点:`/chat/completions` → `/images/generations`
- 请求体:`messages` 数组 → `prompt` 字符串 + `size` + `n`
- 响应处理:`choices[].message.content` 图片 URL → `b64_json` base64 解码

**新增防护**
- `curl -o` 保存响应到临时文件,避免 ~2MB base64 灌入终端浪费 token
- 新增"供应商与默认算力"章节,明确 DesireCore Cloud 始终可用,无需探索
- 强化 7 条强制规则(原 5 条),禁止探索未列出的模型/端点/配置文件
- 端口发现优先从系统提示词获取,兜底 `${DESIRECORE_HOME:-$HOME/.desirecore}`
- 错误处理改为表格格式 + "禁止自行重试其他方案"

## 测试 / Test Plan

- [x] dev 模式端到端测试:用户输入"生成一张小猪" → 4 次工具调用,0 失败,图片成功生成并展示
- [x] 对比历史:第一次测试 472 条/7+ 失败 → 第二次 141 条/5 失败 → **本次 108 条/0 失败**
2026-06-10 17:23:52 +08:00

9.4 KiB
Raw Blame History

name, description, license, version, type, risk_level, status, disable-model-invocation, provider, tags, requires, metadata, market
name description license version type risk_level status disable-model-invocation provider tags requires metadata market
dashscope-image-gen Use this skill when the user wants to generate images using Alibaba Cloud DashScope's Wan (通义万相) series models. Supports text-to-image with multiple model tiers (wan2.7-image-pro, wan2.7-image). Uses OpenAI-compatible images/generations API for synchronous image generation. Use when 用户提到 生成图片、画图、文生图、创建图片、AI 绘画、 生成插图、画一张、帮我画、设计图片、通义万相、万相、阿里云画图、dashscope 画图。 Complete terms in LICENSE.txt 1.3.0 procedural low enabled false auto
media
image
generation
dashscope
alibaba
tools
Bash
author updated_at i18n
desirecore 2026-06-10
default_locale source_locale locales zh-CN en-US
en-US zh-CN
zh-CN
en-US
name short_desc description body source_hash translated_by
阿里云 文生图 基于阿里云通义万相的文本生成图片技能 当用户希望使用阿里云 DashScope 的通义万相系列模型生成图片时使用此技能。支持多种模型层级wan2.7-image-pro / wan2.7-image的文生图通过 OpenAI 兼容的 images/generations API 同步生成图片。用户提到 生成图片、画图、文生图、创建图片、AI 绘画、生成插图、画一张、帮我画、设计图片、通义万相、万相、阿里云画图、dashscope 画图。 ./SKILL.zh-CN.md sha256:a2c4e8f01b3d5e7f human
name short_desc description body source_hash translated_by
DashScope Image Generation Text-to-image generation using Alibaba Cloud Wan (通义万相) models Use this skill when the user wants to generate images using Alibaba Cloud DashScope's Wan (通义万相) series models. Supports text-to-image with multiple model tiers (wan2.7-image-pro, wan2.7-image) via the OpenAI-compatible images/generations API. Trigger keywords: generate image, draw, text-to-image, create image, AI painting, illustration, design picture, Wan, Tongyi Wanxiang, DashScope. ./SKILL.md sha256:a2c4e8f01b3d5e7f human
icon short_desc category maintainer channel
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"><rect x="3" y="3" width="18" height="18" rx="3" stroke="#34C759" stroke-width="1.5" fill="#34C759" fill-opacity="0.1"/><path d="M7 14l3-4 2.5 3 3.5-5 4 6H7z" fill="#34C759" fill-opacity="0.4" stroke="#34C759" stroke-width="1.2" stroke-linejoin="round"/><circle cx="15.5" cy="8.5" r="1.5" fill="#34C759" fill-opacity="0.6"/></svg> 基于阿里云通义万相的文本生成图片技能 media
name verified
DesireCore Official true
latest

dashscope-image-gen Skill

Mandatory Rules (violations cause failure)

  1. STRICTLY follow the execution steps below — do NOT improvise, explore alternative endpoints, or try models not listed in this document
  2. Must access agent-service over HTTPS — the API address is already provided in the system prompt under "本机 API" section (e.g. https://127.0.0.1:PORT); use it directly with -k to skip certificate verification
  3. Must upload to media-store via /api/media/upload/tmp is only a transient download/decode location, never use a local path as the final output
  4. Must use the dc-media:// protocol to display images — the only form the frontend can render correctly
  5. Use Bash curl throughout — do not use the HttpRequest tool or Python
  6. Use /images/generations endpoint — synchronous call; the response contains b64_json image data
  7. Only use models listed below — do NOT try dall-e-3, qwen-vl, or any model not in the Model Selection table

Provider & Default Compute

This skill uses Alibaba Cloud DashScope's Wan (通义万相) models. You do NOT need to specify a provider — just pass "serviceType": "image_gen" and the system will automatically route to the correct provider:

  • DesireCore Cloud (default, always available): The built-in compute provider already supports image_gen with Wan models. Users can generate images immediately without any configuration.
  • DashScope (user-configured): If the user has configured their own DashScope API key, the system may route to it.

Never try to query provider lists, read compute.json, or explore available models through API calls. The models listed below are guaranteed to work.

Model Selection

Model Characteristics When to use
wan2.7-image-pro Flagship, 4K resolution, thinking_mode User asks for top quality, 4K, or rich detail
wan2.7-image Standard high quality, thinking_mode Default, for unspecified requests

Default rule: if the user does not specify a model, use wan2.7-image.

Full Execution Flow (strictly follow these steps)

How to get the API address

The system prompt already contains the agent-service API address under "本机 API" (e.g. Agent Service: https://127.0.0.1:61000). Extract the URL from there and use it directly.

If for any reason you cannot find it in the system prompt, use this fallback:

PORT=$(cat "${DESIRECORE_HOME:-$HOME/.desirecore}/agent-service.port")
# Then use https://127.0.0.1:${PORT}

Step 1: Generate the image (single curl command)

Call /images/generations through media-proxy. You MUST use this exact request structure — do not add messages, response_format, or any other parameters not shown here:

# Save response to a temp file to avoid base64 flooding the terminal
curl -sk -X POST "https://127.0.0.1:${PORT}/api/media-proxy" \
  -H "Content-Type: application/json" \
  -d '{
    "serviceType": "image_gen",
    "endpoint": "/images/generations",
    "body": {
      "model": "wan2.7-image",
      "prompt": "Replace this with the image description (English usually gives better results)",
      "size": "1024x1024",
      "n": 1
    },
    "responseType": "json"
  }' -o /tmp/dashscope-response.json

# Check success and extract b64_json directly to image file (NEVER cat the response to stdout)
python3 -c "
import json, base64, sys
with open('/tmp/dashscope-response.json') as f:
    resp = json.load(f)
if not resp.get('success'):
    print('ERROR:', json.dumps(resp, ensure_ascii=False)[:500])
    sys.exit(1)
b64 = resp['data']['data'][0]['b64_json']
with open('/tmp/dashscope-gen.png', 'wb') as f:
    f.write(base64.b64decode(b64))
print('OK: saved to /tmp/dashscope-gen.png')
"

CRITICAL: The response contains a large base64 image (~2MB). NEVER print the raw response or b64_json to the terminal. Always save to file with -o and extract with the python3 script above.

Response format (saved in /tmp/dashscope-response.json):

{
  "success": true,
  "data": {
    "created": 1781060911,
    "data": [{"b64_json": "<very large base64 string>"}],
    "size": "1024x1024"
  }
}

Step 2: Upload to media-store

curl -sk -X POST "https://127.0.0.1:${PORT}/api/media/upload" \
  -F "file=@/tmp/dashscope-gen.png;type=image/png"

Pick the mediaId field from the JSON response (format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.png).

Step 3: Render the image via the dc-media protocol

In your reply text, write Markdown image syntax directly:

![Image description](dc-media://replace-with-mediaId)

For example: ![White fox in a forest](dc-media://a1b2c3d4-e5f6-47a8-b9c0-d1e2f3a4b5c6.png)

The frontend will translate dc-media:// into a reachable image URL and render it.

Parameter Mapping

Size selection

Pass size in the body object:

{
  "model": "wan2.7-image",
  "prompt": "your image description",
  "size": "1024x1024",
  "n": 1
}
User intent size value
Square / avatar / default "1024x1024"
Landscape / scenery / wallpaper "1792x1024"
Portrait / mobile / poster "1024x1792"

Optional parameters (top-level body fields)

Parameter Description
n Number of images, 1-4, default 1
size Image size, e.g. "1024x1024"

Multiple Image Generation

When n > 1, download and upload each image, then render them one by one:

![Image 1 description](dc-media://mediaId1)
![Image 2 description](dc-media://mediaId2)

Error Handling

Error Meaning Action
"No matching provider" No enabled provider supports image_gen Tell user to enable a provider with image_gen support in settings
"API Key not configured" API Key missing Tell user to configure API key
statusCode: 401 API Key invalid or expired Tell user to check API key
statusCode: 429 Rate limited Wait and retry once
statusCode: 400 Bad parameters Check model name and size are from the tables above
statusCode: 403 AccessDenied.Unpurchased Model not activated Tell user to enable the model in Alibaba Cloud console

On any error: Do NOT try alternative models, alternative endpoints, or read config files. Report the error to the user clearly.

Notes

  • Image generation calls are synchronous and typically return in 10-60 seconds (wan2.7-image-pro can take longer)
  • Image URLs expire; download promptly
  • English prompts usually produce the best results; Chinese is also supported
  • When the user does not specify a model or size, default to wan2.7-image + 1024x1024