curl --request POST \
--url https://kaienapi.com/v1/images/edits/jobs \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "qwen-image-edit",
"prompt": "把图片背景替换成白色棚拍背景,保留主体轮廓和细节。",
"image": "https://oss.example.com/source.jpg"
}
'import requests
url = "https://kaienapi.com/v1/images/edits/jobs"
payload = {
"model": "qwen-image-edit",
"prompt": "把图片背景替换成白色棚拍背景,保留主体轮廓和细节。",
"image": "https://oss.example.com/source.jpg"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'qwen-image-edit',
prompt: '把图片背景替换成白色棚拍背景,保留主体轮廓和细节。',
image: 'https://oss.example.com/source.jpg'
})
};
fetch('https://kaienapi.com/v1/images/edits/jobs', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://kaienapi.com/v1/images/edits/jobs"
payload := strings.NewReader("{\n \"model\": \"qwen-image-edit\",\n \"prompt\": \"把图片背景替换成白色棚拍背景,保留主体轮廓和细节。\",\n \"image\": \"https://oss.example.com/source.jpg\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"id": "imgtask-...",
"object": "image.edit.job",
"status": "queued",
"created": 123,
"updated": 123,
"model": "<string>",
"started_at": 123,
"completed_at": 123,
"reference_urls": [
"<string>"
],
"data": [
{}
],
"error": {
"message": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}创建异步图片编辑任务
创建异步图片编辑任务。该接口立即返回任务 ID,后台继续执行 /v1/images/edits 图片编辑链路,适合需要图片编辑任务语义、且希望用轮询方式等待结果的场景。
图片输入
只支持公网可访问的网络 URL。请传入 OSS/CDN 图片 URL,不要使用 @file 文件形式。大图建议先使用 OSS/CDN 图片处理 resize 到合适分辨率后提交。
URL 多参考图推荐
需要多张网络 URL 做参考图创作、换装、合成或改图时,推荐使用 /v1/images/generations/jobs 的 JSON image 数组。客户端保存返回的任务 ID,再轮询查询结果。
调用方式
- JSON:
image传公网 URL。 - multipart:
image作为普通表单 value 传 URL,不要使用@file文件形式。
状态流转
创建后返回 queued,后台执行时变为 running,完成后为 succeeded 并返回 data,失败后为 failed 并返回 error.message。
curl --request POST \
--url https://kaienapi.com/v1/images/edits/jobs \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "qwen-image-edit",
"prompt": "把图片背景替换成白色棚拍背景,保留主体轮廓和细节。",
"image": "https://oss.example.com/source.jpg"
}
'import requests
url = "https://kaienapi.com/v1/images/edits/jobs"
payload = {
"model": "qwen-image-edit",
"prompt": "把图片背景替换成白色棚拍背景,保留主体轮廓和细节。",
"image": "https://oss.example.com/source.jpg"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'qwen-image-edit',
prompt: '把图片背景替换成白色棚拍背景,保留主体轮廓和细节。',
image: 'https://oss.example.com/source.jpg'
})
};
fetch('https://kaienapi.com/v1/images/edits/jobs', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://kaienapi.com/v1/images/edits/jobs"
payload := strings.NewReader("{\n \"model\": \"qwen-image-edit\",\n \"prompt\": \"把图片背景替换成白色棚拍背景,保留主体轮廓和细节。\",\n \"image\": \"https://oss.example.com/source.jpg\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"id": "imgtask-...",
"object": "image.edit.job",
"status": "queued",
"created": 123,
"updated": 123,
"model": "<string>",
"started_at": 123,
"completed_at": 123,
"reference_urls": [
"<string>"
],
"data": [
{}
],
"error": {
"message": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}授权
在请求头中传入:Authorization: Bearer sk-...
请求体
- Option 1
- Option 2
异步图片编辑任务请求,支持 JSON 或 multipart/form-data。JSON 参考图可使用公网 URL、Base64 Data URL 或标准 Base64,通过 image 或 images 数组提交;Base64 会流式上传到临时图片存储,再以 URL 执行任务。multipart 参考图字段保留原有 URL 调用方式。新接入多参考图创作、换装、合成或改图仍推荐 /v1/images/generations/jobs。
图片编辑模型 ID,例如 qwen-image-edit。
编辑指令。多图参考时说明图 1、图 2、图 3 各自用途。
公网图片 URL 或 JSON 请求中的 Base64 图片,可传单个字符串或数组。Base64 支持 PNG、JPEG、WebP、GIF,推荐携带 data:image/...;base64,... 前缀。multipart/form-data 调用时使用普通 URL value,也可以重复传 image[] 字段。不要同时传 images。
输出尺寸。按模型支持范围填写。
"960x1280"
输出质量。按模型支持范围填写。
"standard"
响应
任务已创建
"imgtask-..."
"image.edit.job"
queued, running, succeeded, failed Unix 秒级时间戳。
Unix 秒级时间戳。
任务成功后返回图片结果,结构与 Images 响应 data 数组一致。
Show child attributes
Show child attributes