全部產品
Search
文件中心

Alibaba Cloud Model Studio:AI試衣-Plus版API參考

更新時間:Oct 16, 2025

相較於AI試衣-基礎版,aitryon-plus 在映像清晰度、布料紋理和Logo還原方面表現更為出色,但產生耗時也相應更長,更適用於對產生結果品質有高要求、對即時性要求不高的情境。

重要

本文檔僅適用於“中國大陸(北京)”地區。如需使用模型,需使用“中國大陸(北京)”地區的API Key

模型能力

多種服飾試穿

  • 單件上裝試穿:模型隨機產生下裝,或保留模特原有下裝。

  • 單件下裝試穿:模型隨機產生上裝,或保留模特原有上裝。

  • 上下裝組合試穿:完整替換全身套裝。

  • 連衣裙/連體衣試穿

精細化控制

  • 人臉策略:可選擇保留模特原有人臉,或產生一張全新的隨機人臉。

  • 指定解析度:可指定輸出圖片的尺寸,或保持與原圖一致。

模型概覽

模型簡介

模型名稱

計費單價

限流(主帳號與RAM子帳號共用)

任務下發介面RPS限制

同時處理中任務數量

aitryon-plus

$0.071677/張

10

5

模型效果示意

輸入模特的全身正面照

輸入服裝平鋪圖

產生的試衣效果圖

test_client_tryon

上裝平鋪圖

image

test_client_tryon

下裝平鋪圖

image

輸入圖片要求

高品質的輸入是高品質輸出的保障。在調用API前,請務必確保您的圖片符合以下規範。

模特圖要求

要求類別

詳細說明

圖片要求

  • 檔案大小:5KB ~ 5MB之間

  • 解析度:圖片寬度和高度均需在 150px ~ 4096px 範圍內

  • 圖片格式:支援JPG、JPEG、PNG、BMP、HEIC

  • 連結要求:上傳圖片必須為公網可訪問的HTTP/HTTPS地址,不支援本地路徑

模特人物要求

  • 人群要求:支援不同性別、膚色、年齡(6歲以上)的人物圖

  • 姿勢要求:人物全身正面照,光照良好。人物手部展示完整,避免手臂交叉遮擋等情況

  • 人物要求:保持圖片中有且僅有一個完整的人

正確的人物圖樣本

image

image

image.png

image.png

錯誤的人物圖樣本

❌多人照片

❌非正面全身照

(避免上傳側身、坐姿、躺姿、半身照片)

❌人物服裝遮擋

(避免手持物、包等)

❌光線過暗/模糊不清

image.png

image

image.png

image.png

服飾圖要求

要求類別

詳細說明

圖片要求

  • 檔案大小:5KB ~ 5MB之間

  • 解析度:圖片寬度和高度均需在 150px ~ 4096px 範圍內

  • 圖片格式:支援JPG、JPEG、PNG、BMP、HEIC

  • 連結要求:上傳圖片必須為公網可訪問的HTTP/HTTPS地址,不支援本地路徑

服飾要求

  • 服飾類型:支援單件上裝、下裝、連衣裙;支援套裝、上下裝組合

  • 服裝類目:支援常見服飾品類。不支援內衣、婚紗禮服、特色民族服飾等

  • 服飾要求:

    • 單件服飾:服飾平鋪拍攝,僅含單件服裝

    • 服飾無摺疊/遮擋:衣服應舒展、平整,無褶皺或摺疊遮擋

    • 背景簡約乾淨:圖片背景簡潔乾淨、色彩統一,保持服飾主體清晰,無複雜的光照陰影

    • 服飾佔比大:服飾的畫面佔比儘可能大,四周不宜留白過多,過多的背景留白會降低試衣效果

正確的服飾圖樣本

上裝

image.jpeg

image.jpeg

image.jpeg

下裝

image.jpeg

image.jpeg

image.webp

連衣裙/連體服

image.webp

image.webp

連衣裙_2

錯誤的服飾圖樣本

多件服裝

非正面照

摺疊遮擋

服裝褶皺

image.jpeg

image.png

image.png

image.png

前提條件

AI試衣Plus API僅支援通過HTTP進行調用。

在調用前,您需要準備工作:擷取與配置 API Key,再配置API Key到環境變數(準備下線,併入配置 API Key)

HTTP調用

API提供一個非同步介面,調用分為兩步:

  1. 建立任務:建立圖片產生任務,擷取一個唯一的 task_id。

  2. 查詢結果:使用 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

  • 5KB≤影像檔≤5M

  • 150≤映像邊長≤4096

  • 格式支援:jpg、png、jpeg、bmp、heic

  • 需保持圖片中有且僅有一個完整的人

  • 僅支援HTTP/HTTPS連結,不支援本地路徑

模特圖樣本請參見模特圖要求

說明

點擊此處下載我們提供的模特圖。

http://aaa/1.jpg

input.top_garment_url

String

Body

上裝/連衣裙服飾圖的公網URL。您也可在此擷取臨時公網URL

  • 5KB≤影像檔≤5M

  • 150≤映像邊長≤4096

  • 格式支援:jpg、png、jpeg、bmp、heic

  • 需上傳服飾平拍圖,保持服飾是單一主體且完整,背景乾淨,四周不宜留白過多

  • 僅支援HTTP/HTTPS連結,不支援本地路徑

服飾圖樣本請參見服飾圖要求

說明
  • top_garment_url 和 bottom_garment_url 至少提供一個。

  • 如果不傳此欄位,模型將隨機產生上裝。

  • 對於連衣裙/連體衣,請將圖片URL填入此欄位,並將 bottom_garment_url 留空。

http://aaa/2.jpg

input.bottom_garment_url

String

Body

下裝服飾圖的公網URL。您也可在此擷取臨時公網URL

  • 5KB≤影像檔≤5M

  • 150≤映像邊長≤4096

  • 格式支援:jpg、png、jpeg、bmp、heic

  • 需上傳服飾平拍圖,保持服飾是單一主體且完整,背景乾淨,四周不宜留白過多

  • 僅支援HTTP/HTTPS連結,不支援本地路徑

服飾圖樣本請參見服飾圖要求

說明
  • top_garment_url 和 bottom_garment_url 至少提供一個。

  • 如果不傳此欄位,模型將隨機產生下裝。

http://aaa/3.jpg

parameters.resolution

Int

Body

輸出圖片的解析度。

  • -1:預設值,與原圖尺寸保持一致。

  • 1024:表示 576x1024 解析度。

  • 1280:表示 720x1280 解析度。

-1

parameters.restore_face

Bool

Body

是否還原模特圖中的人臉。

  • true:預設值,保留原圖人臉。

  • false:隨機產生一張新的人臉。

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
    }
 }'
  • 保留模特原下裝:包含兩個步驟,如下:

    1. 調用AI試衣-圖片分割API,擷取模特下裝映像URL。

    2. 調用本文的試衣 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
    }
}'
  • 保留模特原上裝:包含兩個步驟,如下:

    1. 調用AI試衣-圖片分割API,擷取模特上裝映像URL。

    2. 調用本文的試衣 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
    }
}'

響應樣本

成功響應

請儲存 task_id,用於查詢任務狀態與結果。

{
    "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

任務狀態。可能的值包括:

  • PENDING 排隊中

  • PRE-PROCESSING 前置處理中

  • RUNNING 處理中

  • POST-PROCESSING 後置處理中

  • SUCCEEDED 成功

  • FAILED 失敗

  • UNKNOWN 作業不存在或狀態未知

  • CANCELED:任務取消成功

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.

圖片下載逾時。 可能的原因及解決方案如下:

  • 網路問題:您的伺服器可能與阿里雲百鍊服務之間的網路不通。請檢查網路連結。

  • OSS內網URL:阿里雲百鍊服務無法訪問內網地址。請改用OSS公網 URL。

  • 非中國內地資源:跨境網路訪問不穩定。請使用中國內地的儲存服務。

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.

圖片尺寸或檔案大小不符合要求。請參見輸入圖片要求

常見問題

如何準備模特圖和服飾圖

  1. 為什麼必須使用服裝平鋪圖?

    平鋪圖能最清晰地展示服裝的版型、圖案和輪廓,協助AI準確理解服裝結構,從而產生更貼合、更真實的試穿效果。

  2. 如果沒有服裝平鋪圖怎麼辦?

    您可以嘗試將服裝平整地放置在乾淨的背景上(如地面或牆面)進行俯拍,或者讓真人模特/人台穿著後拍攝正面照。關鍵是確保服裝完整、平整、無遮擋。

  3. 如何選擇合適的模特圖?

    選擇正面、清晰、完整的全身照。模特穿著的衣物應盡量簡潔修身(如T恤+短褲),避免穿著長裙、寬袍大袖或有多層疊穿。同時,確保模特的雙手雙腳清晰可見,無配飾(如包、傘)遮擋。

  4. 如果沒有合適的模特圖怎麼辦?

    我們提供了一批符合規範的模特參考圖,您可以點擊此處下載使用。

模型效果不符合預期

  1. 為什麼產生的圖片效果不佳,缺少細節?

    主要原因可能是輸入的服裝圖品質不高。請確保服裝圖高清、完整,沒有因摺疊或拍攝角度問題導致細節丟失。高品質的輸入是高品質輸出的保障。

功能使用諮詢

  1. 如何為連衣裙或連體衣產生試衣圖?

    將連衣裙/連體衣的圖片URL填入input.top_garment_url欄位,並將input.bottom_garment_url欄位留空或不傳。