使用 MiniMax API 进行文本到图像和图像到图像生成,根据文本提示 (t2i) 或参考图像 (i2i) 生成或转换图像。
MiniMax 图像生成( 文本到图像和图像到图像) QQ 需要编码计划 API 密钥是一项面向实际任务的技能,主要用于下写于 https://platre. minimaxi.com/subcritics/ coding- plan.;Text- to- image (t2i) 和 图像到im。
实际使用前应先确认任务范围、数据来源、运行环境、必要权限和关键参数,再依据技能说明逐步执行;若输入条件不完整,应先补齐信息或采用保守配置,避免因错误假设导致结果偏离需求。执行过程中需要关注工具调用是否成功、接口或依赖是否可用、输出格式是否符合预期,并对异常提示、缺失字段和边界情况进行处理;
涉及批量任务时,还应保存进度,避免中断后重复操作。该技能适合用于一次性任务,也可以接入自动化工作流,与其他技能或上层代理配合完成更完整的业务链路;在组合使用时,应明确每一步的输入输出关系,并避免不同步骤之间出现参数冲突。
⚠️ 需要一个 Coding Plan API Key
订阅地址:https://platform.minimaxi.com/subscribe/coding-plan
基于 MiniMax 图像生成 API 实现的文本生成图像(t2i)与图像生成图像(i2i)工具。
openclaw config set skills.entries.minimax-image-generator.apiKey "sk-your-key"
或在 openclaw.json 的 skills entries 中添加:
{
"skills": {
"entries": {
"minimax-image-generator": {
"apiKey": "sk-your-key"
}
}
}
}
pip install requests
~/.openclaw/workspace/skills/minimax-image-generator/
├── SKILL.md
├── _meta.json
└── scripts/
└── minimax_image_gen.py
# 文本生成图像(t2i)——基础用法 MINIMAX_API_KEY="sk-your-key" python3 scripts/minimax_image_gen.py "海面上壮丽的日落" # 带参数的文本生成图像 MINIMAX_API_KEY="sk-your-key" python3 scripts/minimax_image_gen.py "一只猫" --model image-01 --aspect-ratio 16:9 --n 2 # 图像生成图像(i2i)——通过 URL 引用参考图像 MINIMAX_API_KEY="sk-your-key" python3 scripts/minimax_image_gen.py "转换为动漫风格" --image-url "https://example.com/photo.jpg" # 图像生成图像(i2i)——使用 base64 编码图像 MINIMAX_API_KEY="sk-your-key" python3 scripts/minimax_image_gen.py "让画面更明亮" --image-base64 "data:image/jpeg;base64,..." # 保存结果到文件 MINIMAX_API_KEY="sk-your-key" python3 scripts/minimax_image_gen.py "一只猫" --save cat.png
from minimax_image_gen import generate_image
# 文本生成图像
result = generate_image(
prompt="海面上壮丽的日落",
model="image-01",
aspect_ratio="16:9",
n=1
)
# 图像生成图像(URL 方式)
result = generate_image(
prompt="转换为动漫风格",
image_url="https://example.com/photo.jpg"
)
# 图像生成图像(base64 方式)
result = generate_image(
prompt="让画面更明亮",
image_base64="data:image/jpeg;base64,..."
)
名称:minimax_image_gen
输入 Schema:
{
"type": "object",
"properties": {
"prompt": {
"type": "string",
"description": "图像描述文本,最长 1500 字符。"
},
"model": {
"type": "string",
"enum": ["image-01", "image-01-live"],
"default": "image-01",
"description": "模型名称。"
},
"image_url": {
"type": "string",
"description": "图像生成图像(i2i)所用的参考图像 URL。支持公开可访问的 URL。"
},
"image_base64": {
"type": "string",
"description": "i2i 所用的 base64 格式参考图像 Data URL。格式示例:data:image/jpeg;base64,..."
},
"aspect_ratio": {
"type": "string",
"enum": ["1:1", "16:9", "4:3", "3:2", "2:3", "3:4", "9:16", "21:9"],
"default": "1:1",
"description": "图像宽高比。"
},
"style_type": {
"type": "string",
"enum": ["漫画", "元气", "中世纪", "水彩"],
"description": "风格类型(仅适用于 image-01-live)。"
},
"n": {
"type": "integer",
"minimum": 1,
"maximum": 9,
"default": 1,
"description": "生成图像的数量。"
},
"response_format": {
"type": "string",
"enum": ["url", "base64"],
"default": "url",
"description": "返回格式。"
},
"prompt_optimizer": {
"type": "boolean",
"default": false,
"description": "启用提示词自动优化功能。"
}
},
"required": ["prompt"]
}
输出:包含图像 URL 或 base64 数据的 JSON
| 代码 | 含义 |
|---|---|
| 0 | 成功 |
| 1002 | 请求频率超限 |
| 1004 | 鉴权失败 —— 请检查 API Key |
| 1008 | 余额不足 |
| 1026 | 内容违规 |
| 2013 | 参数错误 |
| 2049 | API Key 无效 |
相关专题
热门下载
相关下载
精品课程
共1课时 | 523人学习
共0课时 | 0人学习
共1课时 | 193人学习