Qwen Image Edit Spicy API
用一句文字指令改图:传要编辑的主图(图 1),可再加最多 2 张参考图(图 2、图 3),拿回一张改好的图。输出与主图像素尺寸完全一致,不用选尺寸或画幅。通常 8–20 秒。只有主图 $0.05、加 1 张参考图 $0.06、加 2 张 $0.07,成功才计费。
认证
Authorization: Bearer YOUR_API_KEY模型与价格
| 输入 | 价格 |
|---|---|
| 只有主图 | $0.05/张 |
| 主图 + 1 张参考图 | $0.06/张 |
| 主图 + 2 张参考图 | $0.07/张 |
model 填 qwen-image-edit-spicy。价格只看参考图张数,与主图尺寸、seed 无关。计费示例:只用主图改 100 张 = $5.00;每次都带 2 张参考图改 100 张 = $7.00。失败不扣费。
代码示例
# ─── Edit one image with a text instruction ($0.05) ─────
curl -X POST https://api.apimodels.app/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen-image-edit-spicy",
"prompt": "Replace the background with a rainy neon street at night, keep the person unchanged",
"image": "https://r2.apimodels.app/assets/muse-cases/20261030-cafe-date/ref-head.jpg"
}'
# Response (async — a task is created):
# { "code": 200, "data": { "taskId": "clxxx", "state": "pending" } }
# ─── Main image + 2 reference images ($0.07) ───────────────
curl -X POST https://api.apimodels.app/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen-image-edit-spicy",
"prompt": "Put the white shirt dress from image 2 on the person in image 1, and use the coastal road from image 3 as the background",
"image": "https://r2.apimodels.app/assets/muse-cases/20261030-cafe-date/ref-head.jpg",
"reference_images": ["https://r2.apimodels.app/assets/muse-cases/20261030-sunset-beach/ref-turn.jpg", "https://apimodels.app/models/ltx-2.5-fast/action.jpg"],
"seed": 42
}'
# ─── Poll for the result ──────────────────────────────────
curl "https://api.apimodels.app/v1/images/generations?task_id=TASK_ID" \
-H "Authorization: Bearer YOUR_API_KEY"
# { "code": 200, "data": { "state": "completed", "resultUrls": ["https://r2.apimodels.app/..."] } }import requests, time
ENDPOINT = "https://api.apimodels.app/v1/images/generations"
HEADERS = {"Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json"}
# 1. Create the task: the image to edit + an instruction (+ up to 2 reference images)
create = requests.post(ENDPOINT, headers=HEADERS, json={
"model": "qwen-image-edit-spicy",
"prompt": "Put the white shirt dress from image 2 on the person in image 1",
"image": "https://r2.apimodels.app/assets/muse-cases/20261030-cafe-date/ref-head.jpg", # image 1: URL or base64
"reference_images": ["https://r2.apimodels.app/assets/muse-cases/20261030-sunset-beach/ref-turn.jpg"], # optional, up to 2 (+$0.01 each)
"seed": 42, # optional: repeatable output
})
task_id = create.json()["data"]["taskId"]
# 2. Poll until completed (typically 8-20 s)
while True:
data = requests.get(ENDPOINT, headers=HEADERS, params={"task_id": task_id}).json()["data"]
if data["state"] == "completed":
print(data["resultUrls"]); break
if data["state"] == "failed":
raise RuntimeError(data.get("failMsg") or "failed")
time.sleep(2)const ENDPOINT = "https://api.apimodels.app/v1/images/generations";
const HEADERS = { "Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json" };
// 1. Create the task: the image to edit + an instruction (+ up to 2 reference images)
const create = await fetch(ENDPOINT, {
method: "POST",
headers: HEADERS,
body: JSON.stringify({
model: "qwen-image-edit-spicy",
prompt: "Put the white shirt dress from image 2 on the person in image 1",
image: "https://r2.apimodels.app/assets/muse-cases/20261030-cafe-date/ref-head.jpg", // image 1: URL or base64
reference_images: ["https://r2.apimodels.app/assets/muse-cases/20261030-sunset-beach/ref-turn.jpg"], // optional, up to 2 (+$0.01 each)
seed: 42, // optional: repeatable output
}),
});
const taskId = (await create.json()).data.taskId;
// 2. Poll until completed (typically 8-20 s)
while (true) {
const res = await fetch(ENDPOINT + "?task_id=" + taskId, { headers: HEADERS });
const { data } = await res.json();
if (data.state === "completed") { console.log(data.resultUrls); break; }
if (data.state === "failed") throw new Error(data.failMsg || "failed");
await new Promise(r => setTimeout(r, 2000));
}请求参数
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | qwen-image-edit-spicy |
| prompt | 是 | string | 编辑指令。要编辑的图是图 1,参考图依次是图 2、图 3 |
| image | 是 | string | 要编辑的主图,URL 或 base64(也收 image_url / image_base64,或 image_urls 的第一张)。输出的构图和像素尺寸都跟它走 |
| reference_images | 否 | string[] | 最多 2 张参考图,URL 或 base64;每张 +$0.01。image_urls 里主图之后的几张也算参考图 |
| seed | 否 | number | 随机种子(0 到 2147483647),固定可复现;不传或 0 为随机 |
| callback_url | 否 | string | 任务完成后的回调 URL |
| size / aspect_ratio / resolution | 否 | string | 收下但忽略,不报错:输出尺寸固定等于主图尺寸 |
说明
- 输出与主图像素尺寸完全一致(例如 2048x1136 进、2048x1136 出)。很大的主图(如 3840x2160)尺寸会保留,但细节更接近 2K 的出图,要最清晰的结果建议主图在 2K 左右
- 一次请求最多 3 张图(主图 + 2 张参考图),超过直接 400、不扣费,不会悄悄丢掉多出来的图;只传 reference_images 不传主图也是 400
- 不支持 mask(传了 400),要改哪里请在指令里说清楚;一次请求只出一张(n 大于 1 会 400)
- 异步任务:先建单拿 taskId,再轮询 GET ?task_id= 取结果,或传 callback_url 等回调。带 OpenAI 风格 size 且不带 callback_url 时同一响应直接返回图片,size 本身不影响输出尺寸
- 结果文件保留 30 天后自动删除,请及时下载或转存
- 失败不扣费
试一试:Playground