闲社服务运行正常AI智能体自动化平台
t

通义千问图像生成

技能标识:taizi-alicloud-ai-image

Generate images with Model Studio DashScope SDK using Qwen Image generation models (qwen-image-max, qwen-image-plus-2026-01-09). Use when implementing or documenting image.generate requests/responses, mapping prompt/negative_prompt/size/seed/reference_image, or integrating image generation into the video-agent pipeline.

作者:admin | 来源记录:ClawHub
登记来源
ClawHub
版本
V 1.0.0
检测标记
后台标记通过
免费
免费获取
0
收藏
来源与检测标记为平台登记信息,并不代表已展示可复核的检测报告。使用前请核对版本、依赖和所需权限,建议先在隔离环境中运行。
概述
安装方式
版本历史

通义千问图像生成

技能名称: taizi-alicloud-ai-image
详细描述:
分类: provider

Model Studio Qwen Image

通过标准化 image.generate 的输入/输出,并使用 DashScope SDK(Python)配合精确模型名称,为视频智能体管道构建一致的图像生成行为。

前提条件

  • - 安装 SDK(建议在虚拟环境中安装,以避免 PEP 668 限制):

bash
python3 -m venv .venv
. .venv/bin/activate
python -m pip install dashscope

  • - 在环境中设置 DASHSCOPEAPIKEY,或将 dashscopeapikey 添加到 ~/.alibabacloud/credentials 文件中(环境变量优先级更高)。

关键模型名称

使用以下精确模型字符串之一:

  • - qwen-image-max
  • qwen-image-plus-2026-01-09

标准化接口 (image.generate)

请求

  • - prompt(字符串,必填)
  • negativeprompt(字符串,可选)
  • size(字符串,必填)例如 10241024、7681024
  • style(字符串,可选)
  • seed(整数,可选)
  • referenceimage(字符串 | 字节,可选)

响应

  • - image_url(字符串)
  • width(整数)
  • height(整数)
  • seed(整数)

快速开始(标准化请求 + 预览)

最小化的标准化请求体:

json
{
prompt: a cinematic portrait of a cyclist at dusk, soft rim light, shallow depth of field,
negative_prompt: blurry, low quality, watermark,
size: 1024*1024,
seed: 1234
}

预览工作流(下载后打开):

bash
curl -L -o output/ai-image-qwen-image/images/preview.png URLFROM_RESPONSE> && open output/ai-image-qwen-image/images/preview.png

本地辅助脚本(JSON 请求 -> 图像文件):

bash
python skills/ai/image/alicloud-ai-image-qwen-image/scripts/generate_image.py \\
--request {prompt:a studio product photo of headphones,size:1024*1024} \\
--output output/ai-image-qwen-image/images/headphones.png \\
--print-response

参数一览

字段必填说明
prompt是描述场景,而不仅仅是关键词。
negative_prompt
否 | 尽力而为,后端可能忽略。 | | size | 是 | WxH 格式,例如 10241024、7681024。 | | style | 否 | 可选的风格提示。 | | seed | 否 | 在支持时用于结果可复现性。 | | reference_image | 否 | URL/文件/字节,SDK 特定的映射方式。 |

快速入门(Python + DashScope SDK)

使用 DashScope SDK,并将标准化请求映射到 SDK 调用中。
注意:对于 qwen-image-max,DashScope SDK 当前通过 ImageGeneration(基于消息)成功执行,而不是 ImageSynthesis。
如果您使用的 SDK 版本对参考图像期望不同的字段名称,请相应地调整 input 映射。

python
import os
from dashscope.aigc.image_generation import ImageGeneration

优先使用环境变量进行身份验证:export DASHSCOPEAPIKEY=...

或者使用 ~/.alibabacloud/credentials 文件,在 [default] 下包含 dashscopeapikey。

def generate_image(req: dict) -> dict:
messages = [
{
role: user,
content: [{text: req[prompt]}],
}
]

if req.get(reference_image):
# 某些 SDK 版本在消息内容中接受 {image: }。
messages[0][content].insert(0, {image: req[reference_image]})

response = ImageGeneration.call(
model=req.get(model, qwen-image-max),
messages=messages,
size=req.get(size, 1024*1024),
apikey=os.getenv(DASHSCOPEAPI_KEY),
# 如果后端支持,传递可选参数。
negativeprompt=req.get(negativeprompt),
style=req.get(style),
seed=req.get(seed),
)

# 响应是生成风格的信封;提取第一个图像 URL。
content = response.output[choices][0][message][content]
image_url = None
for item in content:
if isinstance(item, dict) and item.get(image):
image_url = item[image]
break
return {
imageurl: imageurl,
width: response.usage.get(width),
height: response.usage.get(height),
seed: req.get(seed),
}

错误处理

错误可能原因操作
401/403DASHSCOPEAPIKEY 缺失或无效检查环境变量或 ~/.alibabacloud/credentials 文件,以及访问策略。
400
不支持的尺寸或错误的请求格式 | 使用常见的 WxH 格式并验证字段。 | | 429 | 速率限制或配额不足 | 使用退避策略重试,或降低并发。 | | 5xx | 临时后端错误 | 使用退避策略重试一两次。 |

输出位置

  • - 默认输出:output/ai-image-qwen-image/images/
  • 通过 OUTPUT_DIR 覆盖基础目录。

操作指南

  • - 将返回的图像存储在对象存储中,仅在元数据中持久化 URL。
  • 通过 (prompt, negativeprompt, size, seed, referenceimage hash) 缓存结果,以避免重复费用。
  • 为临时性的 429/5xx 响应添加指数退避重试。
  • 某些后端会忽略 negative_prompt、style 或 seed;将其视为尽力而为的输入。
  • 如果响应中不包含图像 URL,则显示明确的错误,并使用简化的提示重试一次。

尺寸说明

  • - 使用 WxH 格式(例如 10241024、7681024)。
  • 优先使用常见尺寸;不支持的尺寸可能返回 400 错误。

Telegram / 频道投递

当用户通过 Telegram(或其他渠道)请求图像生成时,在生成图像并将其保存到工作区 output/ai-image-qwen-image/images/ 后,使用 message 工具发送图像:action=send,target=telegram,media=。当会话可能包含混合来源(例如 control-ui)时,始终传递明确的 target:从用户消息的 Conversation info 元数据中提取 senderid,并使用 target: id>(例如 target: 6869266119)以确保投递到正确的 Telegram 私聊,并避免出现“bot is not a member of the channel chat”错误。使用 file:// 绝对路径(例如 file:///Users/fresh/.openclaw/workspace/output/ai-image-qwen-image/images/xxx.png)。不要使用 ~/ 路径。

反模式

  • - 不要发明模型名称或别名;仅使用官方模型 ID。
  • 不要在数据库行中存储大型 base64 数据;请使用对象存储。
  • 对于长时间生成,不要省略用户可见的进度。

参考

  • - 有关更详细的 DashScope SDK 映射和响应解析技巧,请参阅 references/api_reference.md。
  • 有关提示模式和示例,请参阅 references/prompt-guide.md。
  • 对于编辑工作流,请使用 skills/ai/image/alicloud-ai-image-qwen-image-edit/。
  • - 来源列表:references/sources.md

标签

skill ai

通过对话安装

以下为平台配置的接入选项,并非逐项实测通过。能否安装取决于客户端支持、技能来源和运行环境:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 taizi-alicloud-ai-image-1776060686 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 taizi-alicloud-ai-image-1776060686 技能

通过命令行安装

skillhub install taizi-alicloud-ai-image-1776060686

下载

⬇ 下载 taizi-alicloud-ai-image v1.0.0(免费)

文件大小: 6.21 KB | 发布时间: 2026-4-15 14:35

v1.0.0 最新 2026-4-15 14:35
taizi-alicloud-ai-image v1.0.0

- Initial release: Standardizes image generation using Alibaba Cloud Model Studio Qwen Image models via DashScope SDK.
- Defines a normalized `image.generate` request/response mapping for consistent integration.
- Supports key parameters: prompt, negative_prompt, size, style, seed, and reference_image.
- Provides quickstart examples for CLI and Python, error handling guidance, and operational tips.
- Includes detailed usage instructions for Telegram (and other channel) delivery, caching, and output location.
- Clearly documents supported model names: `qwen-image-max` and `qwen-image-plus-2026-01-09`.
返回顶部