All Products
Search
Document Center

SuperApp:Submit an AIGC task

Last Updated:Mar 12, 2025

1. API operation description

This is an asynchronous operation. After a request is sent, the system returns a task ID and runs the task in the background. You can use the task ID to query the result of the artificial intelligence generated content (AIGC) task.

2. Endpoint

https://industrysolutions.alibabacloud.com

3. Operation URI

/openapi/v1/aigc/submitTask

4. Request method

POST(application/json)

5. Request parameters

Parameter

Type

Required

Description

workflow

string

yes

The identifier of the AIGC algorithm. For example, "CATVTON" specifies clothes swapping;

"TEXT2IMAGE" represents text-to-image.

version

string

yes

The version of the AIGC algorithm, such as 1.0.0.

algoInput

object

yes

The input of the AIGC algorithm. The input varies based on the algorithm. For more information about the input for clothes swapping, see the following section.

6. algoInput Parameters

6.1. Text-to-Image Algorithm

Parameter

Type

Required

Description

prompt

string

yes

Prompt, string length ≤ 500

seed

int

yes

Valid values: 0 to 2147483647. A random seed, which is used to control the randomness during the image generation process. You can adjust the seed value to change the image style or details. The same input conditions and seed value generate the same image.

6.2. Clothes Swapping Algorithm

Parameter

Type

Required

Description

modelImage

string

yes

The model image. The image address must be accessible over the Internet.

  • 5 KB ≤ Image file size ≤ 5 MB

  • 150 ≤ Image width and height ≤ 4,096

  • Supported formats: JPG, PNG, JPEG, and BMP

garmentImage

string

yes

The clothes image. The image address must be accessible over the Internet.

  • 5 KB ≤ Image file size ≤ 5 MB

  • 150 ≤ Image width and height ≤ 4,096

  • Supported formats: JPG, PNG, JPEG, and BMP

category

string

yes

The clothes swapping type. Valid values:

upper: swaps the clothes above the waist. lower: swaps the clothes below the waist. overall: swaps the clothes on the whole body

seed

int

yes

Valid values: 0 to 2147483647. A random seed, which is used to control the randomness during the image generation process. You can adjust the seed value to change the image style or details. The same input conditions and seed value generate the same image.

7. Response parameters

Parameter

Type

Description

success

boolean

Indicates whether the request is successful. true: The request is successful. false: The request fails.

model

string

The task ID, which can be used to query the result of the task.

errorCode

string

The error code. An error code is returned if the request fails. For more information about the error codes and messages, see the table in the "8. Common error messages" section of this topic.

errorMsg

string

The error message. An error message is returned if the operation fails.

8. Common error messages

Error message

Description

INTCNN_COMMON_AUTH_CHECK_ERROR

A signature verification error.

INTCNN_COMMON_NOT_FOUND

The API operation does not exist.

INTCNN_COMMON_PARAM_VALID_ERROR

A parameter verification error.

INTCNN_COMMON_SYS_ERROR

An unknown error on the server.

9. Sample request

9.1. Text-to-Image

curl --location 'https://industrysolutions.alibabacloud.com/openapi/v1/aigc/submitTask' \
--header 'X-Access-Key: 55404223068*****' \
--header 'X-Request-Sign: MDI5OGZhYTNi*****TFjNGNlNDQzN2Q1NTUxNjQ4NzA0M2FhN2Q3Yg==' \
--header 'X-Request-Timestamp: 1741761084565' \
--header 'x-acs-request-id: 468db2bb-da55-48ff-86ef-b70272b1770c' \
--header 'Content-Type: application/json' \
--data '{
    "workflow": "TEXT2IMAGE", 
    "version": "1.0.0", 
    "algoInput":{ 
        "prompt": "a dog",
        "seed": 43
    }
}'

9.2. Clothes Swapping

curl --location 'https://industrysolutions.alibabacloud.com/openapi/v1/aigc/submitTask' \
--header 'x-acs-request-id: 51843d00-ef53-47f8-ac03-6bfc219ba1eb' \
--header 'X-Access-Key: 5017114*******' \
--header 'X-Request-Sign: NjcxNTQy**************wMjZjZWU1YjQxZTcwYQ==' \
--header 'X-Request-Timestamp: 1739518571992' \
--header 'Content-Type: application/json' \
--data '{
    "workflow": "CATVTON", 
    "version": "1.0.0", 
    "algoInput":{ 
        "modelImage": "https://gw.alicdn.com/imgextra/i4/O1CN0162LlIZ1HJ8VZPst5A_!!6000000000736-2-tps-789-987.png",
        "garmentImage": "https://gw.alicdn.com/imgextra/i1/O1CN01M2oIt71KIAWJhtK8f_!!6000000001140-2-tps-789-987.png",
        "category": "overall",
        "seed": 43
    }
}'

1.10. 响应示例:

10. Sample response

{
 "success": true,
 "model": "28fdf560-249a-4712-adcc-906c0346602b",
 "errorCode": null,
 "errorMsg": null
}

11. Request signature

To prevent data tampering, the API caller must sign the request and the server must use the signature to verify the identity of the API caller. The use of signatures ensures the security for interaction between developers and SuperApp Business Application Platform.

11.1 Signature elements

11.1.1. Request URI

Assume that the request URL is https://{domainName}/openapi/v1/a/b.

In this case, the request URI is /openapi/v1/a/b.

11.1.2. Request Method

The HTTP request method.

11.1.3. Request Header

The following table describes the fields in the request header. The fields are case-sensitive.

Header

Required

Description

Code sample

X-Request-Sign

Yes

The signature string calculated for this request. The default encryption method of the signature string is HMAC-SHA1.

X-Request-Sign: ****

X-Access-Key

Yes

The AccessKey pair that represents the identity of the API caller.

X-Access-Key: The AccessKey pair provided to the API caller by Alibaba Cloud. To obtain your AccessKey ID and AccessKey secret, contact the operations engineers of SuperApp Business Application Platform.

X-Request-Timestamp

Yes

The timestamp of the request. Unit: milliseconds.

X-Timestamp: timestamp. Example: 1740471900061.

x-acs-request-id

Yes

Request ID

x-acs-request-id: Request ID, a randomly generated UUID. Example: 51843d00-ef53-47f8-ac03-6bfc219ba1eb

11.1.4. Request Body

The request body is in the JSON format. The fields in the request body vary based on the API operation.

11.2 Signature method

  1. Compose and encode a string-to-sign. Include the following parameters in the request:

    • HTTP_URI: such as /openapi/v1/a/b

    • X-Access-Key: such as 46b1cac78ed94ca4b99ad6de550a****

    • X-Request-Timestamp: such as 1676904384074

    • HTTP_BODY : The following code block shows a sample body:

{
	"appId": "223232323****",
	"authClientId": "7230000****,
	"grantType": "authorization_code",
	"authCode": "1cc19911172e4f8aaa509c8fb5d1****"
}
  1. Configure {Content_To_Be_Signed} in the following format to compose the string-to-sign: <HTTP_METHOD> <HTTP_URI> <Client-Id>.<Request-Time>.<Access-Key>

POST /openapi/v1/a/b
{
	"appId": "223232323****",
	"authClientId": "7230000****",
	"grantType": "authorization_code",
	"authCode": "1cc19911172e4f8aaa509c8fb5d1****"
}.1676904384074.46b1cac78ed94ca4b99ad6de550afb68
  1. The following code example demonstrates how to generate a signature for the string-to-sign using the HmacSHA1 algorithm.


public String sign(String accessKey,String secretKey,String timestamp,String uri,byte[] bodyBytes) {
    String content = String.format("POST %s\n%s.%s.%s", uri, new String(bodyBytes), timestamp, accessKey);
    String signed = generateSign(content, secretKey, "HmacSHA1");
    return Base64.getEncoder().encodeToString(signed.getBytes(StandardCharsets.UTF_8));
}


public static String generateSign(String content, String key, String algorithm) {
    if (!StringUtils.isEmpty(algorithm) && !StringUtils.isEmpty(content) && null != key) {
        try {
            SecretKeySpec signinKey = new SecretKeySpec(key.getBytes(), algorithm);
            Mac mac = Mac.getInstance(algorithm);
            mac.init(signinKey);
            byte[] rawHmac = mac.doFinal(content.getBytes());
            return convertToHex(rawHmac);
        } catch (InvalidKeyException | NoSuchAlgorithmException var6) {
            return "";
        }
    } else {
        return "";
    }
}


public static String convertToHex(byte[] bytes) {
    int len = bytes.length;
    StringBuilder buf = new StringBuilder(len * 2);

    for(int j = 0; j < len; ++j) {
        buf.append(HEX[bytes[j] >> 4 & 15]);
        buf.append(HEX[bytes[j] & 15]);
    }

    return buf.toString();
}

11.3 Send the request

Add the Client-Id, Request-Time, and Signature fields to the request header to compose the following request:

curl -X POST \
  https://example.com/openapi/v1/a/b \
  -H 'Content-Type: application/json' \
  -H 'X-Access-Key: 46b1cac78ed94ca4b99ad6de550afb68' \
  -H 'X-Request-Timestamp: 1676904384074' \
  -H 'Signature: KrwDE9tAPJYBb4cUZU6ALJxGIZgwDXn5UkFPMip09n%2FkYKPhEIII%2Fki2rYY2lPtuKVgMNz%2BtuCU%2FjzRpohDbrOd8zYriiukpGAxBQDIVbatGI7WYOcc9YVQwdCR6ROuRQvr%2FD1AfdhHd6waAASu5Xugow9w1OW7Ti93LTd0tcyEWQYd2S7c3A73sHOJNYl8DC1PjasiBozZ%2FADgb7ONsqHo%2B8fKHsLygX9cuMkQYTGIRBQsvfgICnJhh%2BzXV8AQoecJBTrv6p%xxxx' \
  -d '{
	"appId": "223232323****",
	"authClientId": "7230000****",
	"grantType": "authorization_code",
	"authCode": "1cc19911172e4f8aaa509c8fb5d1****"
}'