使用 ModelScope 等平台生成 AI 图像。当用户需要生成图像、设计图标、创建角色立绘,或需要帮助编写 AI 绘画提示词时使用此技能。支持直接生成图像和仅优化提示词两种模式。
AI Image Generator 是一个可扩展的图像生成技能,支持通过多个 AI 平台生成高质量图像。当前支持 ModelScope 平台,未来可轻松扩展到 OpenAI DALL-E、Stability AI 等平台。
核心功能:
当用户请求以下任务时,立即使用此技能:
复制配置文件:
cp config.json.example config.json
获取 ModelScope API Key:
编辑 config.json:
{
"platforms": {
"modelscope": {
"api_key": "YOUR_ACTUAL_API_KEY_HERE",
"base_url": "https://api-inference.modelscope.cn/v1"
}
},
"default_platform": "modelscope",
"default_model": "flux-1"
}
安装依赖:
pip install requests Pillow
用户请求 → 选择模型 → 优化提示词 → 调用脚本 → 返回结果
步骤:
理解用户需求
选择合适模型
references/models/overview.md 进行选择优化提示词
references/prompts/[model].md)调用生成脚本
python scripts/generate_image_modelscope.py \
--prompt "优化后的提示词" \
--model flux-1 \
--output output/image.jpg \
--config config.json
解析 JSON 输出
image_url 和 local_patherror_code 和 message,向用户解释向用户展示结果
用户请求 → 选择目标模型 → 读取提示词指南 → 优化提示词 → 返回给用户
步骤:
确认用户意图
选择目标模型
读取提示词指南
references/prompts/[model].md优化提示词
向用户展示
使用 FLUX.1 当:
使用 Qwen-Image 当:
使用 ChenkinNoob-XL 当:
参考 references/models/overview.md 查看完整的模型对比表(基于实际测试数据)和选择建议。
脚本: scripts/generate_image_modelscope.py
基本用法:
python scripts/generate_image_modelscope.py --prompt "一只金色的猫" --output cat.jpg
完整参数:
python scripts/generate_image_modelscope.py \
--prompt "提示词" \
--model flux-1 \
--output output/image.jpg \
--config config.json \
--width 1280 \
--height 1280 \
--steps 30
参数说明:
--prompt: 图像描述(必需)--model: 模型 ID,可选值: flux-1, qwen-image, chenkinnoob-xl(默认: flux-1)--output: 输出文件路径(默认: generated_image.jpg)--config: 配置文件路径(默认: ../config.json)--width: 图像宽度(可选,默认使用模型默认值)--height: 图像高度(可选,默认使用模型默认值)--steps: 推理步数(可选,默认使用模型默认值)输出格式:
成功时(stdout):
{
"status": "success",
"task_id": "xxx",
"model": "MusePublic/489_ckpt_FLUX_1",
"prompt": "a cute cat",
"image_url": "https://...",
"local_path": "cat.jpg",
"generation_time_seconds": 6.5
}
失败时(stderr):
{
"status": "error",
"error_code": "AUTH_FAILED",
"message": "Invalid API key. Please check config.json"
}
references/prompts/flux-1.mdreferences/prompts/qwen-image.mdreferences/prompts/chenkinnoob-xl.md参考各模型的提示词指南文件,其中包含:
原因: API Key 无效或未配置 解决:
原因: 超过免费账户限额(~50-100次/小时) 解决:
原因: 任务超时(超过 120 秒) 解决:
原因: 配置文件格式错误或缺失 解决:
原因: 指定的模型在配置中不存在 解决:
flux-1, qwen-image, 或 chenkinnoob-xl本技能设计为可扩展架构,可以轻松添加新的图像生成平台(如 OpenAI DALL-E、Stability AI 等)。
详细指南: 参见 references/integration/new_platform_guide.md
步骤概览:
generate_image_openai.py)references/models/[platform].md)references/prompts/[model].md)在现有平台添加新模型:
references/prompts/[model].md)references/models/overview.md 的对比表references/models/overview.md - 模型选择指南和对比references/models/modelscope.md - ModelScope 平台详细介绍references/prompts/z-image-turbo.md - Z-Image-Turbo 提示词最佳实践references/prompts/sdxl-base.md - SDXL-Base 提示词最佳实践references/integration/new_platform_guide.md - 添加新平台的完整指南用户: "帮我生成一个手机App图标,蓝色系,简约风格"
Claude 操作:
references/prompts/qwen-image.mdpython scripts/generate_image_modelscope.py \
--prompt "手机App图标,简约扁平风格,蓝色渐变背景,白色图形,圆角方形" \
--model qwen-image \
--output icon.jpg
用户: "I need a fantasy warrior character for my game"
Claude 操作:
references/prompts/chenkinnoob-xl.mdpython scripts/generate_image_modelscope.py \
--prompt "fantasy warrior character, detailed plate armor with gold trim, heroic standing pose with sword raised, dramatic lighting from above, castle ruins background with stormy sky, highly detailed, artstation quality, 8k" \
--model chenkinnoob-xl \
--output warrior.jpg
用户: "Generate a cute cat quickly"
Claude 操作:
references/prompts/flux-1.mdpython scripts/generate_image_modelscope.py \
--prompt "a cute fluffy orange cat with green eyes, sitting on a cozy windowsill, soft natural lighting, peaceful atmosphere" \
--model flux-1 \
--output cat.jpg
用户: "帮我写一个生成游戏道具图标的提示词,我要用 Qwen-Image"
Claude 操作:
references/prompts/qwen-image.md优化后的提示词:
"游戏道具图标,金色宝剑,奇幻风格,金色发光效果,透明背景,精致"
这个提示词:
- 明确了主体(金色宝剑)
- 指定了风格(奇幻)
- 添加了视觉效果(金色发光)
- 指定了背景(透明)
- 添加了质量词(精致)
您可以直接使用这个提示词,或者告诉我需要调整的地方。
需要我帮您生成图像吗?
pip install requests Pillow如果您在使用过程中遇到问题或有改进建议,欢迎:
版本: 1.0.0 最后更新: 2025-12-12 维护者: Claude Code Community