🎨 ChatGPT 最新生图 gpt-image-2-all 已上线 | Now Live:$0.03/张图,对话式端点提示词遵循最佳!详情 Details
curl --request POST \
--url https://api.apiyi.com/v1/images/edits \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form model=flux-2-pro \
--form 'prompt=Place the person from image 1 into the scene from image 2' \
--form image=https://your-oss.example.com/image1.jpg{
"created": 1776832476,
"data": [
{
"url": "https://delivery-eu.bfl.ai/results/xxx/sample.jpeg?signature=..."
}
]
}FLUX 图片编辑 API 参考与在线调试 — 上传参考图(最多 8 张)+ 指令进行单图改图、多图融合,FLUX.2 全系列 + FLUX.1 Kontext 通用
curl --request POST \
--url https://api.apiyi.com/v1/images/edits \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form model=flux-2-pro \
--form 'prompt=Place the person from image 1 into the scene from image 2' \
--form image=https://your-oss.example.com/image1.jpg{
"created": 1776832476,
"data": [
{
"url": "https://delivery-eu.bfl.ai/results/xxx/sample.jpeg?signature=..."
}
]
}Bearer sk-xxx),所有参考图都填公网 URL 字符串:第 1 张填 image,第 2–8 张填 input_image_2 … input_image_8,然后填 prompt、model 一键发送即可。本地图片需先上传到图床/OSS 拿到公网 URL。multipart/form-data 传输,但所有参考图字段都是 URL 字符串而非二进制文件 —— 实测 apiyi 对 FLUX 的二进制 image 翻译不生效,URL 字段才能可靠地传给 BFL。如需纯文本生成图片,请使用 文生图接口。image,第 2–8 张填 input_image_2 … input_image_8png / jpg / webpdata[0].url 必须立即下载aspect_ratio 时,输出尺寸自动匹配第一张输入图input_image / input_image_2 / input_image_3 … 的编号 就是 prompt 中「image 1 / image 2 / image 3」的引用依据。建议在 prompt 中显式指代,例如:Place the person from image 1 into the scene from image 2, applying the color palette of image 3.每张图必须为可公网访问的 URL(推荐 ≤ 20MB),或
data:image/png;base64,xxx 格式 base64 data URL。curl -X POST "https://api.apiyi.com/v1/images/edits" \
-H "Authorization: Bearer sk-your-api-key" \
-F "model=flux-2-pro" \
-F "prompt=Place the person from image 1 into the scene from image 2, color palette from image 3" \
-F "image=https://your-oss.example.com/person.png" \
-F "input_image_2=https://your-oss.example.com/scene.png" \
-F "input_image_3=https://your-oss.example.com/style.png" \
-F "aspect_ratio=3:2"
curl -X POST "https://api.apiyi.com/v1/images/edits" \
-H "Authorization: Bearer sk-your-api-key" \
-F "model=flux-kontext-pro" \
-F "prompt=Convert this architectural photo into a pencil sketch style, preserve all structural details" \
-F "image=https://your-oss.example.com/architecture.jpg"
import requests
resp = requests.post(
"https://api.apiyi.com/v1/images/edits",
headers={"Authorization": "Bearer sk-your-api-key"},
files={ # 用 files 触发 requests 自动设置 multipart/form-data
"model": (None, "flux-2-pro"),
"prompt": (None, "Place the person from image 1 into the scene from image 2, color palette from image 3"),
"image": (None, "https://your-oss.example.com/person.png"),
"input_image_2": (None, "https://your-oss.example.com/scene.png"),
"input_image_3": (None, "https://your-oss.example.com/style.png"),
"aspect_ratio": (None, "3:2"),
},
timeout=120,
)
image_url = resp.json()["data"][0]["url"]
# data[0].url 仅 10 分钟有效,立即下载
with open("fused.jpg", "wb") as f:
f.write(requests.get(image_url, timeout=30).content)
const form = new FormData();
form.append('model', 'flux-2-pro');
form.append('prompt', 'Replace the top of the person from image 1 with the one from image 2');
form.append('image', 'https://your-oss.example.com/person.png');
form.append('input_image_2', 'https://your-oss.example.com/outfit.png');
form.append('aspect_ratio', '1:1');
const resp = await fetch('https://api.apiyi.com/v1/images/edits', {
method: 'POST',
headers: { 'Authorization': 'Bearer sk-your-api-key' },
body: form,
});
const { data } = await resp.json();
const img = await fetch(data[0].url);
const fs = await import('node:fs');
fs.writeFileSync('fused.jpg', Buffer.from(await img.arrayBuffer()));
| 字段 | 类型 | 必填 | 默认 | 说明 |
|---|---|---|---|---|
model | string | 是 | — | FLUX 模型 ID,多图融合推荐 flux-2-pro / flux-2-max,单图改图也可用 flux-kontext-max / flux-kontext-pro |
prompt | string | 是 | — | 编辑 / 融合指令,最长 32K tokens;多图场景用「image 1 / image 2 / image 3」指代 image / input_image_2 / input_image_3 顺序 |
image | string | 是 | — | 参考图 1 的公网 URL(apiyi 网关检查需此字段存在,apiyi 映射为 BFL 的 input_image) |
input_image_2 ~ input_image_8 | string | 否 | — | 第 2–8 张参考图的公网 URL。FLUX.2 [pro/max/flex] 最多 8 张,[klein] 4 张,Kontext 不支持 |
aspect_ratio | string | 否 | 跟随首图 | 例如 1:1 / 16:9 / 9:16 / 4:3 / 3:2 |
seed | integer | 否 | 随机 | 固定可复现 |
safety_tolerance | integer | 否 | 2 | 0(最严)– 6(最宽松) |
output_format | string | 否 | jpeg | jpeg / png |
prompt_upsampling | boolean | 否 | false | 是否自动扩写 prompt |
steps | integer | 否 | 50 | 仅 flux-2-flex,最大 50 |
guidance | number | 否 | 4.5 | 仅 flux-2-flex,1.5–10 |
角色一致性(最多 8 张)
Eight consistent characters from the reference images,
in a fashion editorial set on a Tokyo rooftop at golden hour
风格迁移
Using the style of image 2, render the subject from image 1
对象组合
The person from image 1 is petting the cat from image 2,
the bird from image 3 is next to them
服装/产品换样
Replace the top of the person in image 1 with the one from image 2,
keep the pose and background unchanged
data[0].url 重新下载后作为下一次 image[] 输入,配合新指令逐步精调画面。每轮按张数计费。{
"created": 1776832476,
"data": [
{
"url": "https://delivery-eu.bfl.ai/results/xxx/sample.jpeg?signature=..."
}
]
}
data[0].url 仅 10 分钟有效delivery-eu.bfl.ai / delivery-us.bfl.ai,签名 10 分钟过期fetch 会被拦b64_json,仅返回 url在 API易控制台获取的 API Key
FLUX 模型 ID。多图融合推荐 flux-2-pro / flux-2-max;单图改图也可用 flux-kontext-max / flux-kontext-pro
flux-2-pro, flux-2-max, flux-2-flex, flux-2-klein-9b, flux-2-klein-4b, flux-kontext-max, flux-kontext-pro 编辑/融合指令。多图场景用「image 1 / image 2 / image 3」指代 image / input_image_2 / input_image_3 顺序
"Place the person from image 1 into the scene from image 2"
参考图 1 的公网 URL(必填)。本地图片需先上传到任意图床/OSS 拿到 URL 再填入
"https://your-oss.example.com/image1.jpg"
参考图 2 的公网 URL(可选)。apiyi 直通给 BFL
参考图 3 的公网 URL(可选)
参考图 4 的公网 URL(可选)
参考图 5 的公网 URL(可选)
参考图 6 的公网 URL(可选)
参考图 7 的公网 URL(可选)
参考图 8 的公网 URL(可选,仅 FLUX.2 [pro/max/flex] 支持到 8 张)
宽高比,例如 1:1 / 16:9 / 9:16 / 4:3 / 3:4。不传则跟随首张输入图
固定可复现
审核档位。0 最严格,6 最宽松,默认 2
0 <= x <= 6输出格式,默认 jpeg
jpeg, png 是否自动扩写 prompt,默认 false
仅 flux-2-flex。推理步数,默认 50
1 <= x <= 50仅 flux-2-flex。引导强度,默认 4.5
1.5 <= x <= 10