1. API operation description
You can call this API operation to query the result of an artificial intelligence generated content (AIGC) task by specifying the task ID returned from the API operation which submits an AIGC task.
2. Endpoint
https://industrysolutions.alibabacloud.com
3. Operation URI
/openapi/v1/aigc/queryTask
4. Request method
GET
5. Request parameters
Parameter | Type | Required | Description |
taskId | string | yes | The task ID that is returned from the operation used to submit the AIGC task. |
6. Response parameters
Parameter | Sub-parameter | Type | Description |
success | boolean | Indicates whether the request is successful. true: The request is successful. false: The request fails. | |
model | object | The task ID, which can be used to query the result of the task. | |
taskId | string | The task ID. | |
status | string | WAITING: The task is pending and needs to be scheduled. RUNNING: The task is running. SUCCESS: The task is successful. AIGC_ERROR: The task encounters an algorithm error. LW_REQUEST_ERROR: The task encounters a request error. LW_RESULT_ERROR: The task result is abnormal. TIMEOUT: The task times out. FC_ERROR: The task encounters a function error. UNKNOWN_ERROR: The task encounters an unknown error. SUBMIT_ERROR: The operation encounters an error. | |
ossPath | string | The public URL of the image is returned when the value of the status parameter is SUCCESS. | |
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 "7. Common error messages" section of this topic. | |
errorMsg | string | The error message. An error message is returned if the operation fails. |
7. 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. |
8. Sample request
curl --location 'https://industrysolutions.alibabacloud.com/openapi/v1/aigc/queryTask?taskId=65111151-ac20-4f90-8ea7-263ef42db5e5' \
--header 'X-Request-Id: db160925-0b58-4609-bc6e-08cdf12bf2e6' \
--header 'X-Access-Key: 5017114*******' \
--header 'X-Request-Sign: 7894db2a4*******c23976d6d42c93e' \
--header 'X-Request-Timestamp: 1736162679922'9. Sample response
{
"success": true,
"model": {
"taskId": "28fdf560-249a-4712-adcc-906c0346602b",
"status": "SUCCESS",
"ossPath": "http://superapp.oss-ap-southeast-1.aliyuncs.com/%5B%5D?Expires=1738915150&OSSAccessKeyId=LTfdfaFPkwJtb&Signature=ju0HvkN8nhr%2Fqv3JYyfdfxK1B%2Bk%3D"
},
"errorCode": null,
"errorMsg": null
}
Note: The link to access the generated content is valid for 24 hours. Please save the content promptly, as it will be deleted after 24 hours.
10. 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.
10.1 Signature elements
10.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.
10.1.2. Request method
The HTTP request method.
10.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. |
10.1.4. Request query string
The query string that follows the question mark (?) in the GET request. Assume that the request is https://{domainName}/openapi/v1/a/b?param1=xx¶m2=yy.
In this case, the query string is param1=xx¶m2=yy.
10.2 Signature method
Compose and encode the string-to-sign. Include the following parameters in the request:
HTTP_URI: such as /openapi/v1/a/b
HTTP_QUERY_STRING : param1=xx¶m2=yy
X-Access-Key: such as 46b1cac78ed94ca4b99ad6de550a****
X-Request-Timestamp: such as 1676904384074
Configure
{Content_To_Be_Signed}in the following format to compose the string-to-sign:<HTTP_URI> ?<HTTP_QUERY_STRING><Request-Time><Access-Key>
/openapi/v1/a/b?param1=xx¶m2=yy167690438407446b1cac78ed94ca4b99ad6de550a****
The following code example demonstrates how to generate a signature for the string-to-sign using the HMAC-SHA1 algorithm.
public String computeGetSign(String accessKey,String secretKey,String timestamp,String uri,String queryString) {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(uri);
if (StringUtils.isNotBlank(queryString)) {
stringBuilder.append("?");
stringBuilder.append(queryString);
}
if (StringUtils.isNotBlank(timestamp)) {
stringBuilder.append(timestamp);
}
if (StringUtils.isNotBlank(ak)) {
stringBuilder.append(accessKey);
}
return generateSign(stringBuilder.toString(), secretKey, SIGN_ALGORITHM);
}
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();
}
10.3 Send the request
Add the Client-Id, Request-Time, and Signature fields to the request header to compose the following request:
curl --location 'https://example.com/openapi/v1/a/b?param1=xx¶m2=yy' \
--header 'X-Request-Id: db160925-0b58-4609-bc6e-08cdf12bf2e6' \
--header 'X-Access-Key: 5017114*******' \
--header 'X-Request-Sign: 7894db2a4*******c23976d6d42c93e' \
--header 'X-Request-Timestamp: 1736162679922'