Vacancy Detection API
The Java SDK for the Vacancy Detection API is currently unavailable. We recommend that Java customers call the API directly by using an API Key with an HTTP client or curl. This method eliminates the need to manually calculate an AccessKey signature. To get started, create an API Key in the product console. For detailed steps, see "Create an API key (recommended)". For code examples, see "Call using an API key (recommended)". SDKs are still available for other languages. Customers already using AccessKey can continue to use the V3 signature method.
This guide explains how to use the Aidge API to submit retail display images, query asynchronous tasks, and parse Vacancy Detection results.
Vacancy Detection locates empty spaces, understocked areas, and collapsed products on retail shelves. It helps business systems discover out-of-stock items, trigger replenishment alerts, and flag areas for manual review. You submit a publicly accessible image, query the detection result by using a task ID, and map the returned coordinates onto the original image to display the findings.
First, go to the Aidge console and activate the service. Log in to the console by using the Alibaba Cloud account that will call the API. After the service is activated, configure your credentials and integrate with the API. Go to the Aidge Console
I. API overview
1. Use cases
Inspect store shelves to find empty spaces in the front row and partially understocked areas.
Check for low stock levels in display boxes, bins, floor stacks, and individual freezer compartments.
Locate areas where products have fallen over, slid down, or are part of an unstable stack.
Integrate with your business system to render bounding boxes for anomalies and drive replenishment and review workflows.
2. Features
Feature | API name | Description |
Submit detection task |
| Submits one image at a time and returns a task ID upon acceptance. |
Query result |
| Queries the task status and final result by task ID. |
The API version is 2026-04-28. It uses the POST method over HTTPS and supports authentication using either an API Key (Bearer token) or an AccessKey signature. We recommend that customers who integrate directly over HTTP use an API Key. Use the endpoint and region provided when you activate the service. The endpoint for the China (Beijing) region is aidge.cn-beijing.aliyuncs.com.
3. Call process
The detection is an asynchronous task that is queued for scheduling after submission. After a successful submission, save the Data.TaskId and then use the query API to retrieve the result.
Go to the Aidge console, activate the service by using your Alibaba Cloud account, and create an API Key in the product console. If you use an AccessKey or STS, complete the corresponding RAM authorization and credential configuration as described in the following sections.
Call the
VacancyDetectionAPI and submit a publicly accessible HTTPS image URL in theImageUrlparameter.After a successful submission, save the returned
Data.TaskId. The system then queues the task for scheduling and execution.Use the task ID to call
QueryAsyncTaskResult. If the task is not yet finished, wait at least 1 second before polling again.When the task is complete, check the task status and the business success flag or error information in
Data.Result.If the detection is successful, parse the coordinate array and display the detected anomaly areas on the original image. If the shelf is fully stocked and no anomalies are found, the API returns an empty array
[ ]. Treat this as a normal, successful result.If the detection fails, handle the error based on the error message and save the
TaskIdandRequestIdfor troubleshooting.
II. Throttling and authorization
1. Throttling
Contact the Aidge team to determine your Queries Per Second (QPS) threshold. The platform reserves a default QPS quota for each customer to ensure smooth daily operations. If you need to increase your quota or perform large-scale batch detections, contact the Aidge team in advance. Provide your expected peak QPS, call volume, and usage period so that we can assess service capacity and coordinate an expansion. We recommend a polling interval of at least 1 second. If you encounter throttling, increase the interval.
2. RAM authorization for AccessKey and STS
If you call the API by using a RAM user or a RAM role, an administrator must first grant it the AliyunAidgeFullAccess system policy. On the Add Permissions page, search for aidge, select the policy, and confirm the authorization.
Log on to the RAM Console as an administrator with the required permissions.
In the list of Users or Roles, select the RAM user or RAM role that you will use to call the Vacancy Detection API, and then go to the Add Permissions page.
Under System Policies, search for
aidge, selectAliyunAidgeFullAccess, and complete the authorization.Use the credentials of the authorized identity to run submission and query tests. Confirm that the Aidge service has been activated for the corresponding Alibaba Cloud account.
The AliyunAidgeFullAccess policy provides full access to Aidge services. If an administrator needs to restrict access to specific APIs, you can create a custom policy that includes the following actions.
Purpose | Permission action |
Submit a Vacancy Detection task |
|
Query an asynchronous task result |
|
The following is an example of a custom policy that grants permissions for the two APIs:
{
"Version": "1",
"Statement": [
{
"Effect": "Allow",
"Action": [
"aidge:VacancyDetection",
"aidge:QueryAsyncTaskResult"
],
"Resource": "*"
}
]
}3. Create an API key (recommended)
First, go to the Aidge console to activate the service, and then create an API Key from the console. The path is Quotas and API Keys > API KEY Management > Create API Key.

The creation process automatically creates and authorizes a RAM user associated with the API Key. After you complete the steps on the page, copy the returned API Key secret and save it in your server-side credential configuration. The secret is displayed in plaintext only once upon successful creation. Save it before you close the page.

An API Key is a service credential issued by RAM for a specific cloud service. In OpenAPI, it is called a ServiceCredential. It is bound to the Aidge service and is effective only within the scope of that service and the permissions of the associated RAM user. When you create an API Key from the product console, the associated user and permissions are handled automatically. If an administrator creates the key separately in RAM, they must ensure that it is bound to the Aidge service and that the associated user has submission and query permissions.
Field | Purpose |
ID ( | Used for managing the credential, not the secret for API calls. |
Name ( | Used to identify and manage the API Key, not the secret for API calls. |
API Key ( | The secret to include in the |
For more information about the concept, permission scope, validity period, and management of API Keys, see the official documentation: Manage Service Credentials (API Key).
4. Configure AccessKey or STS credentials
You configure and use an AccessKey on your server. If you use a RAM user, configure the AccessKey for that user. If you use a RAM role, call the API with a temporary STS credential and include the corresponding security token. For configuration methods, see Authentication Configuration.
If you encounter a NoPermission error or other permission-related issues, check the following, in order: that the service is activated, that you are using the correct identity for the call, and that the identity has both submission and query permissions. If you use an API Key, also check whether the key is enabled, has not expired, and is bound to the Aidge service.
III. Request parameters
Fields are case-sensitive. The following JSON examples show the structure of the business parameters. If you use an API Key, encode the business parameters into the URL query string and authenticate with a Bearer token in the request header. If you use an AccessKey, you can let an SDK or an OpenAPI tool handle the common parameters, signature, and serialization, or you can construct the HTTP request manually according to the V3 signature mechanism.
1. VacancyDetection
Parameter | Type | Description |
| string | Required. The publicly accessible HTTPS URL of a single image. |
| string | Optional. If left empty, the built-in comprehensive prompt for vacancy detection is used. Supports plain text and a text-only messages/content JSON string. |
| string | Optional. The system prompt. |
For the ImageUrl parameter, provide a string that contains the image URL. The URL must remain publicly accessible and return valid image content throughout the task's lifecycle (queuing, download, and execution).
We recommend passing only ImageUrl and leaving UserPrompt and SystemPrompt empty or omit them. The service will automatically use the vacancy detection model and its corresponding comprehensive prompt to return anomaly coordinates based on a unified detection standard.
{
"ImageUrl": "https://example.com/shelf.jpg"
}If you need to explicitly pass a prompt, we recommend using the full version below to ensure consistency in detection scope, anomaly criteria, and coordinate output format.
{
"ImageUrl": "https://example.com/shelf.jpg",
"UserPrompt": "You are a retail store display anomaly detection assistant. Your task is to inspect all visible product display areas in the image and locate any areas that are empty, understocked, or have collapsed products according to the business criteria below. Output only the bounding box coordinates for each anomaly.\nReturn only a JSON array. Do not output explanations, analysis, Markdown formatting, or any other text.\n\nI. Anomaly criteria (for detection purposes only; do not output categories)\n\n1. Understocked front row: A clear gap exists in the front-facing row of products on a conventional shelf, resulting in an incomplete display facing.\n2. Understocked display box: Products are displayed in a disposable, product-specific open-top box or tray. The overall height of the products is significantly lower than the capacity of the box.\n3. Understocked bin: Products are displayed in a fixed, reusable bin, basket, trough, or partitioned compartment that is part of the store's fixtures. The overall height of the products is significantly lower than the capacity of the container.\n4. Incomplete stack: An entire layer of products is missing from a clearly defined, multi-layered stack of similar items. This anomaly applies only when a complete layer is missing. Partial gaps, scattered empty spaces, or minor height variations do not qualify.\n5. Collapsed products: Products are visibly unstable or have fallen from their normal display position relative to similar items in the same area. This includes items that are tilted, have slid down, are crushed without support, or are part of an unstable stack.\n6. Understocked freezer compartment: In a freezer or cooler, an individual compartment defined by dividers, baskets, or the unit's structure is understocked. This means the overall height of products is significantly lower than the container's capacity, or the white grid at the bottom of an ice bin is exposed where products should be.\n\nII. Detection and bounding box requirements\n\n1. Inspect all shelves, display boxes, bins, stacks, and freezer compartments in the entire image. Output all identifiable areas that meet the preceding criteria.\n2. Apply the appropriate criteria based on the actual display format. For example, open-top boxes, trays, and fixed bins should be judged based on their container properties. Individual freezer compartments should be judged by the freezer compartment standard, not the front-row standard, just because they are at the front of a display.\n3. Draw a bounding box around the local anomaly. For a gap, enclose the visible empty space. For an understocked box, bin, stack, or freezer compartment, enclose the local area that shows it is understocked. For collapsed products, enclose the area where the products have tilted, slid, or become unstable. If necessary, you can include a small portion of the container's border to define the anomaly, but do not expand the box to the entire shelf, container, or display fixture.\n4. For a single continuous anomaly, output one bounding box. Do not split it into multiple boxes based on the imagined number of missing items. For anomalies in different locations separated by properly stocked products or fixtures, output separate boxes. Do not report multiple boxes for a single anomaly, even if it meets multiple criteria. You can report independent anomalies within the same display unit separately.\n5. Base your judgment only on visible evidence in the image. Do not mistake normal gaps between products, gaps in shelving structures, backgrounds, shadows, reflections, price tags, or obscured areas for empty spaces. Do not assume that obscured areas are out of stock. A product displayed flat or at an angle is not necessarily collapsed.\n6. The bounding box should fit the visible anomaly as closely as possible. Do not extend it to areas outside the image or behind obstructions. Do not include irrelevant areas such as properly stocked products, the floor, aisles, or advertisements.\n\nIII. Output requirements\n\n1. Output only a JSON array of coordinate arrays. Each anomaly corresponds to one array in the format `[x1, y1, x2, y2]`, which represents `[top-left-x, top-left-y, bottom-right-x, bottom-right-y]`. Do not use objects or field names. Do not output categories, confidence scores, or any other information.\n2. Coordinates are relative to the entire input image, with the width and height each normalized to a scale of 0–1000. All four values must be integers that satisfy `0 <= x1 < x2 <= 1000` and `0 <= y1 < y2 <= 1000`. Do not output pixel coordinates, percentages, or decimal coordinates between 0 and 1.\n3. Sort the boxes from top to bottom based on their top-left corner. If the y-coordinates are the same, sort them from left to right.\n4. If no identifiable anomalies are found in the entire image, including for a fully stocked display, output only an empty array `[ ]`. Do not output text like "fully stocked" or a bounding box for the entire image.\n\nThe following example illustrates the output format only. The actual coordinates must be based on the current image:\n[\n [138, 406, 230, 463],\n [353, 526, 471, 622]\n]",
"SystemPrompt": "You are a helpful assistant."
}Replace the example URL with a real, downloadable image URL.
2. QueryAsyncTaskResult
Parameter | Type | Description |
| string | Required. The task ID returned by the submission API. |
{
"TaskId": "The task ID returned by the submission API"
}IV. Response parameters
1. Top-level fields
Both APIs return the following top-level fields. The Code and Message values, and their presence, depend on the API response. In the query API definition, these fields are primarily used for error information.
Field | Type | Description |
| string | The request ID, used for troubleshooting. |
| string | The error code or status code for the call. |
| boolean | Indicates whether the API call was successful. |
| string | The returned message or a description of the call failure. |
| object | The business data. |
2. Data field for the submission API
Field path | Type | Description |
| string | The asynchronous task ID, used for subsequent queries. |
| map<string, int64> | Usage details. This is empty for an asynchronous submission and is populated after the task reaches a terminal state. |
| boolean | Indicates whether the workflow processing was successful. This can be empty for an asynchronous submission. |
| string | Present if the workflow fails. |
| string | Present if the workflow fails. |
During the submission phase, a task is considered accepted if the API call is successful and a valid TaskId is returned. You get the final detection result from the query API.
3. Data field for the query API
Field path | Type | Description |
| string | The task status. An example of a completion status is |
| string | The task result as a string. |
| string | The task ID. |
| map<string, any> | Usage information. |
| string | The business ID. Read its value from the actual response. |
During integration, handle asynchronous task statuses such as QUEUED, COMPLETED, and FAILED according to standard conventions. If the status is QUEUED, wait and then query again. If it is COMPLETED, read the result. If it is FAILED, read the error information. The API documentation provides an example only for the Status of COMPLETED. For other statuses and extended values, refer to the actual response from the service.
4. Detection business result
When the image set is complete and no anomalies are detected, an empty array[ ]is returned. This indicates a successful call. In this case, thesuccess=true, and theresultfield is the string"[ ]", which parses into an empty array. Treat this as a "no anomalies" case and handle it as a successful result.
After parsing Data.Result as JSON, read the detection service fields.
Field | Type | Description |
| boolean | Indicates whether the operation is successful. |
| string | The error code. This parameter is empty if the operation is successful. |
| string | The error message. This parameter is empty if the operation is successful. |
| string | A JSON string of the coordinate array. |
Parse result again to obtain the coordinate array.
[
[138, 406, 230, 463],
[353, 526, 471, 622]
]Each box corresponds to an anomaly and is in the format [top-left x, top-left y, bottom-right x, bottom-right y]. The coordinates are relative to the entire image, with the width and height normalized to integers from 0 to 1000, where 0 <= x1 < x2 <= 1000 and 0 <= y1 < y2 <= 1000. The horizontal pixel coordinate is x / 1000 × original image width, and the vertical pixel coordinate is y / 1000 × original image height.
If no exceptions are found, the success field is true, and the result field is the string "[ ]". If the operation fails, use the errorCode and errorMessage to handle the error. When you use custom prompts, ensure that the output still conforms to the coordinate output format specified above.
The system verifies in order that the top-level API call is successful, the task has reached a final state, and the service check is successful, before parsing the coordinates.
Response examples and call code
The following IDs, coordinates, error messages, and status codes are examples to show the response structure. The actual response from the service may differ. The coordinate structure in the result text follows the Vacancy Detection workflow contract.
Submission successful
{
"RequestId": "request-example",
"Code": "success",
"Success": true,
"Message": "Success",
"Data": {
"TaskId": "task-example",
"UsageMap": {}
}
}Detection completed
{
"RequestId": "request-example",
"Success": true,
"Data": {
"TaskId": "task-example",
"Status": "COMPLETED",
"UsageMap": {
"ProcessingCount": 1
},
"Result": "{\"result\":\"[[138,406,230,463],[353,526,471,622]]\",\"success\":true,\"errorCode\":\"\",\"errorMessage\":\"\"}"
}
}Service failure result
The following example shows a service error after parsing Data.Result.
{
"result": "",
"success": false,
"errorCode": "InvalidParameter",
"errorMessage": "The image is unreachable or is not a valid image."
}Call using an API Key (recommended)
Using an API Key does not require the Aidge Java SDK, an AccessKey ID and Secret, or an ACS3-HMAC-SHA256 signature. Send requests from Java, Python, or other languages using a standard HTTP client. Submitting a task and querying its result use the same Bearer authentication method.
The common configurations are as follows.
Configuration item | Value |
Endpoint |
|
Request method |
|
|
|
|
|
| Use |
URL query parameters | Pass |
The following example includes common request headers such as the UTC time, a request nonce, and an empty request body digest. However, you do not need to calculate a signature from them. Place service parameters in the URL query parameters and leave the request body empty. Encode special characters in the image URL.
Submit a detection task with curl
First, set the environment variables on the server. The key and image URL in the example are placeholders. Replace them with your own values.
export AIDGE_API_KEY='Replace with the API Key created in the product console'
export IMAGE_URL='https://example.com/shelf.jpg'
curl --silent --show-error --get --request POST \
'https://aidge.cn-beijing.aliyuncs.com/' \
--data-urlencode 'Format=JSON' \
--data-urlencode "ImageUrl=${IMAGE_URL}" \
--header "Authorization: Bearer ${AIDGE_API_KEY}" \
--header 'x-acs-action: VacancyDetection' \
--header 'x-acs-version: 2026-04-28' \
--header "x-acs-date: $(date -u +%Y-%m-%dT%H:%M:%SZ)" \
--header "x-acs-signature-nonce: $(uuidgen)" \
--header 'x-acs-content-sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' \
--header 'Accept: application/json'--get appends the --data-urlencode parameters to the URL. --request POST keeps the actual request method as POST. After the submission succeeds, save the Data.TaskId from the response.
Query the result with curl
Replace the task ID with the value returned in the previous step. Continue to use the AIDGE_API_KEY:
export TASK_ID='Replace with the TaskId returned by the submission API'
curl --silent --show-error --get --request POST \
'https://aidge.cn-beijing.aliyuncs.com/' \
--data-urlencode 'Format=JSON' \
--data-urlencode "TaskId=${TASK_ID}" \
--header "Authorization: Bearer ${AIDGE_API_KEY}" \
--header 'x-acs-action: QueryAsyncTaskResult' \
--header 'x-acs-version: 2026-04-28' \
--header "x-acs-date: $(date -u +%Y-%m-%dT%H:%M:%SZ)" \
--header "x-acs-signature-nonce: $(uuidgen)" \
--header 'x-acs-content-sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' \
--header 'Accept: application/json'Check the asynchronous task status as described earlier to determine if the task is complete. If the task is not complete, wait at least 1 second before querying again. Do not resubmit the image instead of querying the task status.
Java standard HTTP client example
The following example uses the HttpClient included in Java 11 and later. It does not require the Aidge Java SDK. The code uses the environment variables mentioned earlier. If TASK_ID is not set, the code submits a detection task. If TASK_ID is set, it queries the result once. Handle response parsing and polling as described previously.
import java.net.URI;
import java.net.URLEncoder;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
public class AidgeApiKeyExample {
static String call(String action, Map<String, String> params) throws Exception {
String key = System.getenv("AIDGE_API_KEY");
if (key == null || key.isBlank()) {
throw new IllegalArgumentException("Set AIDGE_API_KEY first.");
}
String query = params.entrySet().stream()
.map(e -> URLEncoder.encode(e.getKey(), StandardCharsets.UTF_8)
+ "=" + URLEncoder.encode(e.getValue(), StandardCharsets.UTF_8))
.collect(Collectors.joining("&"));
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://aidge.cn-beijing.aliyuncs.com/?Format=JSON&" + query))
.timeout(Duration.ofSeconds(60))
.header("Authorization", "Bearer " + key)
.header("x-acs-action", action)
.header("x-acs-version", "2026-04-28")
.header("x-acs-date", Instant.now().truncatedTo(ChronoUnit.SECONDS).toString())
.header("x-acs-signature-nonce", UUID.randomUUID().toString())
.header("x-acs-content-sha256",
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
.header("Accept", "application/json")
.POST(HttpRequest.BodyPublishers.noBody())
.build();
HttpClient client = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(10)).build();
HttpResponse<String> response = client.send(
request, HttpResponse.BodyHandlers.ofString(StandardCharsets.UTF_8));
if (response.statusCode() < 200 || response.statusCode() >= 300) {
throw new IllegalStateException("HTTP " + response.statusCode()
+ ": " + response.body());
}
return response.body(); // Still need to parse JSON and check the Success field, task status, and service result
}
public static void main(String[ ] args) throws Exception {
String taskId = System.getenv("TASK_ID");
if (taskId != null && !taskId.isBlank()) {
System.out.println(call("QueryAsyncTaskResult", Map.of("TaskId", taskId)));
} else {
String imageUrl = System.getenv("IMAGE_URL");
if (imageUrl == null || imageUrl.isBlank()) {
throw new IllegalArgumentException("Set IMAGE_URL first.");
}
System.out.println(call("VacancyDetection", Map.of("ImageUrl", imageUrl)));
}
}
}Even if you receive an HTTP 200 response, check the top-level Success field. Receiving a task ID only means the submission was accepted. The final outcome depends on the task status and the service result that you query.
Call with a self-signed signature using HTTP/curl (AccessKey method)
If you already use an AccessKey, you can follow the official V3 signature mechanism. Generate a signature on the server using your AccessKey ID and AccessKey Secret. Then, send requests using curl, a Java HTTP client, or another HTTP tool. The signature algorithm is ACS3-HMAC-SHA256. You can use this method to submit detection tasks and query results. New Java users should use the API Key method described in the previous section.
The official documentation provides signing steps and examples in multiple languages. You can refer to the Java example to implement the signature. For more information, see Instructions.
Follow these steps:
Set the request method to
POST, the endpoint toaidge.cn-beijing.aliyuncs.com, the request path to/, and the version to2026-04-28.When submitting, set
x-acs-actiontoVacancyDetectionand place the service parameterImageUrlin the URL query parameters. AddUserPromptandSystemPromptas needed.Sort and RFC 3986-encode the query parameters according to the official documentation. Set the UTC time, a unique nonce, and the SHA-256 digest of the request body. Then, generate the
Authorizationsignature header. The method, parameters, headers, and request body used for signature calculation must match the content actually sent.Send the request and save the returned
Data.TaskId.When querying, change
x-acs-actiontoQueryAsyncTaskResultand the query parameter toTaskId. Regenerate the time, nonce, and signature for this request. Poll for the result as described previously.
The following shows the structure of a submission request after the signature is generated. The content in angle brackets must be generated or replaced by the signing program. The image URL is encoded according to RFC 3986. The request body in this example is empty, so x-acs-content-sha256 uses the SHA-256 digest of an empty string.
curl --request POST \
'https://aidge.cn-beijing.aliyuncs.com/?ImageUrl=https%3A%2F%2Fexample.com%2Fshelf.jpg' \
--header 'host: aidge.cn-beijing.aliyuncs.com' \
--header 'x-acs-action: VacancyDetection' \
--header 'x-acs-version: 2026-04-28' \
--header 'x-acs-date: <UTC time for this request, e.g., 2026-11-13T02:00:00Z>' \
--header 'x-acs-signature-nonce: <Unique nonce for this request>' \
--header 'x-acs-content-sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' \
--header 'Authorization: ACS3-HMAC-SHA256 Credential=<AccessKeyId>,SignedHeaders=host;x-acs-action;x-acs-content-sha256;x-acs-date;x-acs-signature-nonce;x-acs-version,Signature=<Signature calculated for this request>'When using temporary STS credentials, also include the x-acs-security-token and add it to the signature according to the official rules. Generate a separate signature for each submission or query.
Python submission and polling example (AccessKey/STS method)
Install dependencies
pip install alibabacloud-tea-openapi alibabacloud-openapi-util alibabacloud-tea-util alibabacloud-credentialsConfigure your identity using the Alibaba Cloud credential chain, then run the code. Replace the image address with the actual public HTTPS URL. The example uses a generic Remote Procedure Call (RPC), and ImageUrl is passed directly as a string.
import json
import time
from alibabacloud_credentials.client import Client as CredentialClient
from alibabacloud_tea_openapi.client import Client as OpenApiClient
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_openapi_util.client import Client as OpenApiUtil
from alibabacloud_tea_util import models as util_models
config = open_api_models.Config(credential=CredentialClient())
config.endpoint = "aidge.cn-beijing.aliyuncs.com"
config.region_id = "cn-beijing"
client = OpenApiClient(config)
runtime = util_models.RuntimeOptions()
def call(action, business_params):
params = open_api_models.Params(
action=action,
version="2026-04-28",
protocol="HTTPS",
pathname="/",
method="POST",
auth_type="AK",
style="RPC",
req_body_type="formData",
body_type="json",
)
request = open_api_models.OpenApiRequest(
query=OpenApiUtil.query(business_params)
)
body = client.call_api(params, request, runtime)["body"]
if body.get("Success") is not True:
raise RuntimeError(
f"{body.get('Code')}: {body.get('Message')} "
f"RequestId={body.get('RequestId')}"
)
return body
submitted = call("VacancyDetection", {
"ImageUrl": "https://example.com/shelf.jpg"
})
task_id = submitted["Data"]["TaskId"]
print("TaskId", task_id)
deadline = time.monotonic() + 300 # Client-side waiting example, can be adjusted as needed
while time.monotonic() < deadline:
queried = call("QueryAsyncTaskResult", {"TaskId": task_id})
data = queried["Data"]
status = data.get("Status")
if status in ("COMPLETED", "FAILED"):
if status == "FAILED":
raise RuntimeError(
f"Task failed, TaskId={task_id}, Result={data.get('Result')}"
)
business = json.loads(data["Result"])
if business.get("success") is not True:
raise RuntimeError(
f"{business.get('errorCode')}: "
f"{business.get('errorMessage')}, TaskId={task_id}"
)
boxes = json.loads(business["result"])
print("Detection coordinates", boxes)
break
time.sleep(1)
else:
print("Wait timeout. Save the task ID for future queries.", task_id)Error handling
If a call fails, check the top-level Code and Message fields, and any SDK exception information. If a business detection fails, check the errorCode and errorMessage fields within Data.Result. Save the RequestId and TaskId for troubleshooting.
Scenario | Solution |
API Key authentication failed | Use the API Key returned upon creation. Send it in the |
Image URL is invalid or not publicly accessible | Fix the URL. Confirm that the URL returns a valid image, then resubmit the request. |
Required parameter is missing or has an incorrect format | Ensure that the |
Request submission timed out | Check if the request was accepted and save the task ID if one was returned. Then, decide whether to resubmit. |
Query is not yet complete | Query again after an interval. Set a total wait time on the client. |
Submission or query is rate-limited | Reduce the frequency and retry after a delay. |
Query returned a final failed state | Handle the error based on the specific error message in the task result. |
Result parsing failed | Save the original result, task ID, and request ID. Contact the service provider for troubleshooting. |
This API documentation does not list specific business error codes. The current Vacancy Detection workflow uses InvalidParameter to indicate input parameter errors and DownstreamUnavailable to indicate downstream errors. The final error returned by Aidge is based on the actual response.
Billing method
The list price for Vacancy Detection is CNY 0.03 per call.
Leave the UsageMap parameter empty during submission. The scheduler populates it after the task is complete. Usage is read from Data.UsageMap, and the processing count corresponds to ProcessingCount.
Change history
Date | Summary of changes |
2026-11-10 | Initial release |
2026-11-13 | Added information about Java SDK availability and the access method for HTTP/curl V3 with self-signed signatures. Added steps for service activation in the console and for RAM authorization. Updated the list price. |
2026-11-16 | Added steps to create an API Key in the product backend, two screenshots, and a link to the official RAM documentation. Added a recommendation for Java customers to use Bearer authentication. Added examples for curl submissions and queries, and for standard Java HTTP requests. |