创建异步图片编辑任务
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。
POST
/
v1
/
images
/
edits
/
jobs
创建异步图片编辑任务
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>"
}
}Authorizations
在请求头中传入:Authorization: Bearer sk-...
Body
application/jsonmultipart/form-data
异步 multipart 图片编辑任务请求。需要用 OSS/CDN 网络 URL 做多参考图创作、换装、合成或改图时,推荐使用 /v1/images/generations/jobs 的 JSON image 数组;本接口保留给需要图片编辑任务语义的客户端。不要在该接口使用 @file 文件形式。
Response
任务已创建
Example:
"imgtask-..."
Example:
"image.edit.job"
Available options:
queued, running, succeeded, failed Unix 秒级时间戳。
Unix 秒级时间戳。
任务成功后返回图片结果,结构与 Images 响应 data 数组一致。
Show child attributes
Show child attributes