Flux-2 图生图
接口
POST /images/generations
完整 URL: https://modelfold.ai/v1/images/generations
鉴权:所有请求都需要
Authorization: Bearer <API_KEY>请求头。
模型参数直接放在 JSON 请求体中,不要套 input。请求等待生成完成后返回 data[].url;支持的媒体模型也可使用 异步创建、轮询及回调。示例素材地址须替换为自己的公开可访问文件。计费及错误说明见 API 网关。
生成任务的输入参数
请求参数
请求体 (application/json)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 用于生成的模型名称。必填字段。 - 此端点必须使用 flux-2/flex-image-to-image 默认值:"flux-2/flex-image-to-image"。 可选值:flux-2/flex-image-to-image。 示例:flux-2/flex-image-to-image。 |
input_urls | array<string> | 是 | 输入参考图像(1-8 张)。(上传后的文件 URL,非文件内容;支持类型:image/jpeg、image/png、image/webp;最大大小:10.0MB) maxItems: 8. |
prompt | string | 是 | 本站网关要求传入 prompt,最长 2000 字。长度必须在 3-5000 字符之间。(最大长度:5000 字符) maxLength: 2000. 示例:Replace the can in image 2 with the can from image 1。 |
aspect_ratio | string | 是 | 必填。生成图像的宽高比。选择 auto 可匹配首张输入图像的比例(需传入输入图像)。 可选值:1:1 / 4:3 / 3:4 / 16:9 / 9:16 / 3:2 / 2:3 / auto。 示例:1:1。 |
resolution | string | 是 | 必填。输出图像分辨率。 可选值:1K / 2K。 示例:1K。 |
nsfw_checker | boolean | 否 | 默认 false。为 false 时不额外进行内容过滤,结果由模型直接返回。 |
请求示例
bash
curl -X POST "https://modelfold.ai/v1/images/generations" \
-H "Authorization: Bearer $MODELFOLD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "flux-2/flex-image-to-image",
"input_urls": [
"https://example.com/reference.png"
],
"prompt": "Replace the can in image 2 with the can from image 1",
"aspect_ratio": "1:1",
"resolution": "1K"
}'json
{
"model": "flux-2/flex-image-to-image",
"input_urls": [
"https://example.com/reference.png"
],
"prompt": "Replace the can in image 2 with the can from image 1",
"aspect_ratio": "1:1",
"resolution": "1K"
}响应
200 — 生成完成。usage 返回实际计费明细;结果地址仅作结构示例。
json
{
"ok": true,
"created": 1792134000,
"data": [
{
"url": "https://modelfold.ai/uploads/outputs/result.png"
}
],
"usage": {}
}