AI试衣-基础版模型支持使用服饰平拍图片以及人物正面全身照,生成逼真的试衣效果图。
快速入口: 在线体验 | AI试衣模型总览 | 计费与限流 | 免费额度 | 新手API调用入门指南 |
相关API: |
模型能力
多种服饰试穿
| 精细化控制
|
模型概览
模型简介
模型名称 | 计费单价 | 限流(主账号与RAM子账号共用) | 免费额度 | |
任务下发接口RPS限制 | 同时处理中任务数量 | |||
aitryon | 0.20元/张 | 10 | 5 | 免费额度:400张 有效期:阿里云百炼开通后180天内 |
模型选型建议:若使用场景对试衣结果图片清晰度、服饰纹理细节和logo还原效果等方面有更高要求,且可接受一定时间的等待,推荐使用aitryon-plus模型。
计费与限流:aitryon-plus 与 aitryon 模型的计费标准和调用频率限制不同,详情请参见计量计费。
模型效果示意
输入模特的全身正面照 | 输入服装平铺图 | 生成的试衣效果图 |
上装平铺图 | ||
下装平铺图 |
输入图片要求
高质量的输入是高质量输出的保障。在调用API前,请务必确保您的图片符合以下规范。
模特图要求
要求类别 | 详细说明 |
图片要求 |
|
模特人物要求 |
|
正确的人物图示例
错误的人物图示例
❌多人照片 | ❌非正面全身照 (避免上传侧身、坐姿、躺姿、半身照片) | ❌人物服装遮挡 (避免手持物、包等) | ❌光线过暗/模糊不清 |
服饰图要求
要求类别 | 详细说明 |
图片要求 |
|
服饰要求 |
|
正确的服饰图示例
上装 | |||
下装 | |||
连衣裙/连体服 |
错误的服饰图示例
❌多件服装 | ❌非正面照 | ❌折叠遮挡 | ❌服装褶皱 |
前提条件
AI试衣Plus API仅支持通过HTTP进行调用。
在调用前,您需要获取API Key,再配置API Key到环境变量。
HTTP调用
API提供一个异步接口,获取结果分为两步:
创建任务:创建图片生成任务,获取一个唯一的 task_id。
查询结果:使用 task_id 轮询任务状态,直到任务完成并获取结果。
步骤1:创建任务
发送 POST 请求创建试衣任务。
POST https://dashscope.aliyuncs.com/api/v1/services/aigc/image2image/image-synthesis
因该模型调用耗时较长,故采用异步调用的方式创建任务。
任务创建后,系统会立即返回一个
task_id
。在下一步中,需要使用此 task_id 在24小时内查询任务结果。
入参描述
字段 | 类型 | 传参方式 | 必选 | 描述 | 示例值 |
Content-Type | String | Header | 是 | 请求类型:application/json。 | application/json |
Authorization | String | Header | 是 | API-Key,例如:Bearer sk-xxxx。 | Bearer sk-xxxx |
X-DashScope-Async | String | Header | 是 | 固定值为 enable,表示使用异步调用方式。 | enable |
model | String | Body | 是 | 指明需要调用的模型。 | aitryon-plus |
input.person_image_url | String | Body | 是 | 模特人物图片的公网URL。您也可在此获取临时公网URL。
模特图示例请参见模特图要求。 说明 请点击此处下载我们提供的模特图。 | http://aaa/3.jpg |
input.top_garment_url | String | Body | 否 | 上装/连衣裙服饰图的公网URL。您也可在此获取临时公网URL。
服饰图示例请参见服饰图要求。 说明
| http://aaa/1.jpg |
input.bottom_garment_url | String | Body | 否 | 下装服饰图的公网URL。您也可在此获取临时公网URL。
服饰图示例请参见服饰图要求。 说明
| http://aaa/2.jpg |
parameters.resolution | Int | Body | 否 | 输出图片的分辨率。
说明 若后续还需调用AI试衣-图片精修API,此值必须设为 -1。 | -1 |
parameters.restore_face | Bool | Body | 否 | 是否还原模特图中的人脸。
说明 若后续还需调用AI试衣-图片精修API,此值必须设为true。 | true |
出参描述
字段 | 类型 | 描述 | 示例值 |
output.task_id | String | 异步任务的唯一ID。 | a8532587-fa8c-4ef8-82be-0c46b17950d1 |
output.task_status | String | 任务提交后的状态。 | PENDING |
request_id | String | 本次请求的唯一ID。 | 7574ee8f-38a3-4b1e-9280-11c33ab46e51 |
请求示例
试穿上装
试穿上装:传入top_garment_url(待试穿的上装),模型将随机生成下装。
curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/image2image/image-synthesis/' \
--header 'X-DashScope-Async: enable' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"model": "aitryon-plus",
"input": {
"person_image_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250626/ubznva/model_person.png",
"top_garment_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250626/epousa/short_sleeve.jpeg"
},
"parameters": {
"resolution": -1,
"restore_face": true
}
}'
保留模特原下装:包含两个步骤,如下:
调用AI试衣-图片分割API,获取模特下装图像URL。
调用本文的试衣 API,传入 top_garment_url(待试穿的上装)和 bottom_garment_url(分割获取的下装URL)。
curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/image2image/image-synthesis/' \
--header 'X-DashScope-Async: enable' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"model": "aitryon-plus",
"input": {
"person_image_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250626/ubznva/model_person.png",
"top_garment_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250626/epousa/short_sleeve.jpeg",
"bottom_garment_url": "图片分割API输出的图像URL"
},
"parameters": {
"resolution": -1,
"restore_face": true
}
}'
试穿下装
试穿下装:传入 bottom_garment_url(待试穿的下装),模型将随机生成上装。
curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/image2image/image-synthesis/' \
--header 'X-DashScope-Async: enable' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"model": "aitryon-plus",
"input": {
"person_image_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250626/ubznva/model_person.png",
"bottom_garment_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250626/rchumi/pants.jpeg"
},
"parameters": {
"resolution": -1,
"restore_face": true
}
}'
保留模特原上装:包含两个步骤,如下:
调用AI试衣-图片分割API,获取模特上装图像URL。
调用本文的试衣 API,传入 top_garment_url(分割获取的上装URL) 和 bottom_garment_url(待试穿的下装)。
curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/image2image/image-synthesis/' \
--header 'X-DashScope-Async: enable' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"model": "aitryon-plus",
"input": {
"person_image_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250626/ubznva/model_person.png",
"top_garment_url": "图片分割API输出的图像URL",
"bottom_garment_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250626/rchumi/pants.jpeg"
},
"parameters": {
"resolution": -1,
"restore_face": true
}
}'
试穿上下装
传入top_garment_url(待试穿的上装)和 bottom_garment_url(待试穿的下装)。
curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/image2image/image-synthesis/' \
--header 'X-DashScope-Async: enable' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"model": "aitryon-plus",
"input": {
"person_image_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250626/ubznva/model_person.png",
"top_garment_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250626/epousa/short_sleeve.jpeg",
"bottom_garment_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250626/rchumi/pants.jpeg"
},
"parameters": {
"resolution": -1,
"restore_face": true
}
}'
试穿连衣裙/连体服
对于连衣裙或连体服,传入 top_garment_url 即可。
curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/image2image/image-synthesis/' \
--header 'X-DashScope-Async: enable' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"model": "aitryon-plus",
"input": {
"person_image_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250626/ubznva/model_person.png",
"top_garment_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250626/odngby/dress.jpg"
},
"parameters": {
"resolution": -1,
"restore_face": true
}
}'
响应示例
成功响应
{
"output": {
"task_status": "PENDING",
"task_id": "0385dc79-5ff8-4d82-bcb6-xxxxxx"
},
"request_id": "4909100c-7b5a-9f92-bfe5-xxxxxx"
}
异常响应
模型调用失败,请参见错误信息进行解决。
{
"code":"InvalidApiKey",
"message":"Invalid API-key provided.",
"request_id":"fb53c4ec-1c12-4fc4-a580-xxxxxx"
}
步骤2:根据任务ID查询结果
使用上一步获取的 task_id
,发送 GET 请求查询任务状态和结果。请将 URL 中的{task_id}
替换为您的实际任务ID。
GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}
入参描述
字段 | 类型 | 传参方式 | 必选 | 描述 | 示例值 |
Authorization | String | Header | 是 | API-Key,例如:Bearer sk-xxx。 | Bearer sk-xxx |
task_id | String | Url Path | 是 | 需要查询任务的ID。 | a8532587-fa8c-4ef8-82be-0c46b17950d1 |
出参描述
字段 | 类型 | 描述 | 示例值 |
output.task_id | String | 查询的任务ID。 | a8532587-fa8c-4ef8-82be-0c46b17950d1 |
output.task_status | String | 任务状态。可能的值包括:
| SUCCEEDED |
output.image_url | String | 生成的试衣效果图地址。 image_url有效期为24小时,请及时下载。 | https://.../result.jpg?Expires=xxx |
output.submit_time | String | 任务提交时间。 | 2024-07-30 15:39:39.918 |
output.scheduled_time | String | 任务执行时间。 | 2024-07-30 15:39:39.941 |
output.end_time | String | 任务完成时间。 | 2024-07-30 15:39:55.080 |
output.code | String | 错误码。任务失败时返回此参数。 | InvalidParameter |
output.message | String | 错误详情。任务失败时返回此参数。 | The request is missing required parameters or in a wrong format |
usage.image_count | Int | 本次请求生成的图片张数。 | 1 |
request_id | String | 本次请求的唯一ID。 | 7574ee8f-38a3-4b1e-9280-11c33ab46e51 |
请求示例
将86ecf553-d340-4e21-xxxxxxxxx
替换为真实的task_id。
curl -X GET https://dashscope.aliyuncs.com/api/v1/tasks/86ecf553-d340-4e21-xxxxxxxxx \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"
task_id 仅支持在24小时内查询任务结果,超时会被系统自动清除。
响应示例
成功响应
任务数据(如任务状态、图像URL等)仅保留24小时,超时后会被自动清除。请及时保存生成的图片。
{
"request_id": "98d46cd0-1f90-9231-9a6c-xxxxxx",
"output": {
"task_id": "15991992-1487-40d4-ae66-xxxxxx",
"task_status": "SUCCEEDED",
"submit_time": "2025-06-30 14:37:53.838",
"scheduled_time": "2025-06-30 14:37:53.858",
"end_time": "2025-06-30 14:38:11.472",
"image_url": "http://dashscope-result-hz.oss-cn-hangzhou.aliyuncs.com/tryon.jpg?Expires=xxx"
},
"usage": {
"image_count": 1
}
}
失败响应
{
"request_id": "6bf4693b-c6d0-933a-b7b7-xxxxxx",
"output": {
"task_id": "e32bd911-5a3d-4687-bf53-xxxxxx",
"task_status": "FAILED",
"code": "InvalidParameter",
"message": "The request is missing required parameters xxxxx"
}
}
错误码
大模型服务通用状态码请查阅:错误信息。
AI试衣模型特定错误码如下:
HTTP返回码 | 错误码(code) | 错误信息(message) | 含义说明 |
400 | InvalidParameter | The request is missing required parameters or in a wrong format, please check the parameters that you send. | 请求参数缺失或格式错误。请检查您的请求体是否符合API规范。 |
400 | InvalidParameter | Download the media resource timed out during the data inspection process. | 图片下载超时。 可能的原因及解决方法如下:
|
400 | InvalidURL | The request URL is invalid, please check the request URL is available and the request image format is one of the following types: JPEG, JPG, PNG, BMP, and WEBP. | 图片URL无效。请检查URL是否为公网地址或者图片格式是否符合要求。 |
400 | InvalidPerson | The input image has no human body or multi human bodies. Please upload other image with single person. | 模特图不合规。请确保输入图片中有且仅有一个完整的人。 |
400 | InvalidGarment | Missing clothing image.Please input at least one top garment or bottom garment image. | 缺少服饰图片。请至少提供一张上装 (top_garment_url) 或下装 (bottom_garment_url) 的图片。 |
400 | InvalidInputLength | The image resolution is invalid, please make sure that the largest length of image is smaller than 4096, and the smallest length of image is larger than 150. and the size of image ranges from 5KB to 5MB. | 图片尺寸或文件大小不符合要求。请参见输入图片要求。 |
常见问题
如何准备模特图和服饰图
为什么必须使用服装平铺图?
平铺图能最清晰地展示服装的版型、图案和轮廓,帮助AI准确理解服装结构,从而生成更贴合、更真实的试穿效果。
如果没有服装平铺图怎么办?
您可以尝试将服装平整地放置在干净的背景上(如地面或墙面)进行俯拍,或者让真人模特/人台穿着后拍摄正面照。关键是确保服装完整、平整、无遮挡。
如何选择合适的模特图?
选择正面、清晰、完整的全身照。模特穿着的衣物应尽量简洁修身(如T恤+短裤),避免穿着长裙、宽袍大袖或有多层叠穿。同时,确保模特的双手双脚清晰可见,无配饰(如包、伞)遮挡。
如果没有合适的模特图怎么办?
我们提供了一批符合规范的模特参考图,您可以点击此处下载使用。
模型效果不符合预期
为什么生成的图片效果不佳,缺少细节?
主要原因可能是输入的服装图质量不高。请确保服装图高清、完整,没有因折叠或拍摄角度问题导致细节丢失。高质量的输入是高质量输出的保障。
功能使用咨询
如何为连衣裙或连体衣生成试衣图?
将连衣裙/连体衣的图片URL填入
input.top_garment_url
字段,并将input.bottom_garment_url
字段留空或不传。
计费与限流
AI试衣的计费与限流问题请参见常见问题。