POST /v1/images/generations,区别在于图生图在请求体中额外传入 subject_reference(人物主体参考)参数。POST /v1/images/generationshttps://moyunapi.comAuthorization: Bearer sk-xxxapplication/jsonsubject_reference 是一个数组,每个元素包含:| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
type | string | 是 | 主体类型,目前仅支持 "character"(人像主体参考) |
image_file | string | 是 | 参考图片,支持两种格式 |
image_file 支持的格式:data:image/jpeg;base64,{data}注意:数组长度暂仅支持 1(单图参考)。
| 要求 | 说明 |
|---|---|
| 图片格式 | jpg、jpeg、png |
| 图片大小 | 小于 10MB |
| 推荐内容 | 单人正面人脸照片,模型能更好理解人像信息 |
| 数组长度 | 暂仅支持 1(单图参考) |
| aspect_ratio | 分辨率 | 说明 |
|---|---|---|
1:1 | 1024×1024 | 默认正方形 |
16:9 | 1280×720 | 宽屏横图 |
4:3 | 1152×864 | 标准横图 |
3:2 | 1248×832 | 摄影横图 |
2:3 | 832×1248 | 竖版海报 |
3:4 | 864×1152 | 标准竖图 |
9:16 | 720×1280 | 手机竖屏 |
21:9 | 1344×576 | 超宽横图(仅 image-01) |
subject_reference 需通过 OpenAI SDK 的 extra_body 传递。response_format 为 url 时,URL 有效期为 24 小时。prompt 最长 1500 字符。n 取值范围 [1, 9]。curl --location 'https://moyunapi.com/v1/images/generations' \
--header 'Accept;' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "MiniMax-image-01",
"prompt": "A girl looking into the distance from a library window",
"subject_reference": [
{
"type": "character",
"image_file": "https://cdn.hailuoai.com/prod/2025-08-12-17/video_cover/1754990600020238321-411603868533342214-cover.jpg"
}
],
"aspect_ratio": "16:9",
"n": 2,
"response_format": "url"
}'{
"created": 1719600000,
"data": [
{
"url": "https://files.moyunapi.com/image/img1.png"
},
{
"url": "https://files.moyunapi.com/image/img2.png"
}
]
}