1. API operation description
Asynchronously submits an AIGC task. The operation returns a task ID that you can use to query the task result.
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 AIGC algorithm identifier. Valid values: "IMAGE2VIDEO": image-to-video. "CATVTON": clothes swapping. "TEXT2IMAGE": text-to-image. |
|
version |
string |
yes |
The AIGC algorithm version. Example: 1.0.0. |
|
algoInput |
object |
yes |
The AIGC algorithm input. Parameters vary by algorithm. Refer to the algoInput parameter tables below. |
6. algoInput Parameters
6.1. Image-to-Video Algorithm
|
Parameter |
Type |
Required |
Description |
|
inputText |
string |
yes |
Prompt text. Maximum length: 500 characters. |
|
inputImage |
string |
yes |
Input image URL. Must be publicly accessible.
|
6.2. Text-to-Image Algorithm
|
Parameter |
Type |
Required |
Description |
|
inputText |
string |
yes |
Prompt text. Maximum length: 500 characters. |
|
width |
int |
yes |
Image width |
|
height |
int |
yes |
Image height |
6.3. Clothes Swapping Algorithm
|
Parameter |
Type |
Required |
Description |
|
modelImage |
string |
yes |
Model image URL. Must be publicly accessible.
|
|
garmentImage |
string |
yes |
Garment image URL. Must be publicly accessible.
|
|
category |
string |
yes |
The clothes swapping type. Valid values: upper: above the waist. lower: below the waist. overall: full body. |
|
seed |
int |
yes |
Random seed for image generation. Valid values: 0 to 2147483647. The same seed with the same input produces the same output. |
7. Response parameters
|
Parameter |
Type |
Description |
|
success |
boolean |
Whether the request succeeded. Valid values: true, false. |
|
model |
string |
The task ID. Use this ID to query the task result. |
|
errorCode |
string |
The error code returned when the request fails. Valid error codes are listed in the "8. Common error messages" section. |
|
errorMsg |
string |
The error message returned when the request 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. Image-to-Video
curl --location 'https://industrysolutions.alibabacloud.com/openapi/v1/aigc/submitTask' \
--header 'X-Access-Key: 501711*****45218' \
--header 'X-Request-Sign: YmM4Yzg4ZTc3Z****************FkODdlYTRmMWFiOTBmYTMwMw==' \
--header 'X-Request-Timestamp: 1741855077857' \
--header 'x-acs-request-id: 893e87bb-6083-4249-aedd-a376cac24bee' \
--header 'Content-Type: application/json' \
--data '{
"workflow": "IMAGE2VIDEO",
"version": "1.0.0",
"algoInput": {
"inputText": "A person is walking along a narrow path, surrounded by nature.",
"inputImage": "https://img.alicdn.com/imgextra/i2/O1CN01DspKG11ZLZjy0JKAf_!!6000000003178-0-tps-999-750.jpg"
}
}'
9.2. Text-to-Image
curl --location 'https://industrysolutions.alibabacloud.com/openapi/v1/aigc/submitTask' \
--header 'X-Access-Key: 501711*****45218' \
--header 'X-Request-Sign: YmM4Yzg4ZTc3Z****************kODdlYTRmMWFiOTBmYTMwMw==' \
--header 'X-Request-Timestamp: 1741855077857' \
--header 'x-acs-request-id: 893e87bb-6083-4249-aedd-a376cac24bee' \
--header 'Content-Type: application/json' \
--data '{
"workflow": "TEXT2IMAGE",
"version": "1.0.0",
"algoInput": {
"inputText": "a cat",
"width": 1024,
"height": 1024
}
}'
9.3. 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
}
}'
10. Sample response
{
"success": true,
"model": "28fdf560-249a-4712-adcc-906c0346602b",
"errorCode": null,
"errorMsg": null
}
11. Request signature
Request signatures prevent data tampering and verify the identity of the API caller.
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 request header fields are case-sensitive.
|
Header |
Required |
Description |
Code sample |
|
X-Request-Sign |
Yes |
The request signature. Default algorithm: HMAC-SHA1. |
X-Request-Sign: **** |
|
X-Access-Key |
Yes |
The AccessKey ID of the API caller. |
X-Access-Key: Your AccessKey ID. Contact SuperApp Business Application Platform operations to obtain your AccessKey pair. |
|
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: A randomly generated UUID. Example: 51843d00-ef53-47f8-ac03-6bfc219ba1eb |
11.1.4. Request Body
The request body is JSON-formatted. Fields vary by API operation.
11.2 Signature method
-
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****"
}
-
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
-
Generate a signature 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 Client-Id, Request-Time, and Signature to the request header:
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****"
}'