任务:虚拟试穿
概览
- 请求方法:
POST - 路径:
/kling/v1/images/kolors-virtual-try-on - 内容类型:
application/json
认证方式
- HTTP Bearer:
Authorization: Bearer <token>
请求参数
Body 参数(JSON)
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| callback_url | string | 否 | 回调地址,任务结果回调通知 |
| model_name | string | 否 | 模型名称,枚举:kolors-virtual-try-on-v1-5、kolors-virtual-try-on-v1,默认 kolors-virtual-try-on-v1 |
| human_image | string | 是 | 人物图(Base64或URL),支持 jpg/jpeg/png,<=10MB,分辨率>=300x300 |
| cloth_image | string | 是 | 服饰图(商品图/白底图),支持 jpg/jpeg/png,<=10MB,分辨率>=300x300 |
model kolors-virtual-try-on-v1-5支持单件或上装+下装组合,组合检测失败场景如上/上、下/下、连体/连体、上/连体、下/连体。
示例请求
curl 示例
bash
curl -X POST "https://api.gpt.ge/kling/v1/images/kolors-virtual-try-on" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxx" \
-d '{
"model_name": "kolors-virtual-try-on-v1-5",
"human_image": "https://gw.alicdn.com/imgextra/i1/1860536677/O1CN012wEzZ11zC7RDNm0Jr_!!1860536677.jpg",
"cloth_image": "https://gw.alicdn.com/imgextra/i4/3370044138/O1CN01p0Zl411gRFvj0NnwQ_!!3370044138.jpg"
}'JavaScript (fetch) 示例
javascript
fetch('https://api.gpt.ge/kling/v1/images/kolors-virtual-try-on', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer sk-xxxx'
},
body: JSON.stringify({
model_name: 'kolors-virtual-try-on-v1-5',
human_image: 'https://gw.alicdn.com/imgextra/i1/1860536677/O1CN012wEzZ11zC7RDNm0Jr_!!1860536677.jpg',
cloth_image: 'https://gw.alicdn.com/imgextra/i4/3370044138/O1CN01p0Zl411gRFvj0NnwQ_!!3370044138.jpg'
})
}).then(r => r.json()).then(console.log)Python 示例(requests)
python
import requests
resp = requests.post(
'https://api.gpt.ge/kling/v1/images/kolors-virtual-try-on',
headers={
'Content-Type': 'application/json',
'Authorization': 'Bearer sk-xxxx'
},
json={
'model_name': 'kolors-virtual-try-on-v1-5',
'human_image': 'https://gw.alicdn.com/imgextra/i1/1860536677/O1CN012wEzZ11zC7RDNm0Jr_!!1860536677.jpg',
'cloth_image': 'https://gw.alicdn.com/imgextra/i4/3370044138/O1CN01p0Zl411gRFvj0NnwQ_!!3370044138.jpg'
}
)
print(resp.json())返回字段
200 成功
| 字段 | 类型 | 描述 |
|---|---|---|
| code | integer | 返回码,0 表示成功 |
| message | string | 返回信息 |
| request_id | string | 请求唯一ID |
| data.task_id | string | 任务ID |
| data.task_status | string | 任务状态,如 submitted |
| data.created_at | integer | 任务创建时间戳(毫秒) |
| data.updated_at | integer | 任务更新时间戳(毫秒) |
返回示例
json
{
"code": 0,
"message": "SUCCEED",
"request_id": "Cji7cGctxFMAAAAAAEU5sQ",
"data": {
"task_id": "Cji7cGctxFMAAAAAAEU5sQ",
"task_status": "submitted",
"created_at": 1731172864209,
"updated_at": 1731172864209
}
}