AI Search API
Overview
The search API of the CleverSee AI Search and Q&A Platform enables precise retrieval of images, documents, and audio/video content from your datasets. After building a search application on the platform, you can call this API to perform searches. The platform supports queries using text (in natural language), images, or a combination of both, supporting multimodal data searches at scale and helping users efficiently locate content.
API
You can use this API with two types of search applications created on the CleverSee AI Search and Q&A Platform: image search applications and audio and video search applications. Image search supports text-to-image, image-to-image, and hybrid text-and-image queries. Audio and video search supports text-to-audio/video, image-to-video, and hybrid text-and-image queries for video.
Data sources
This API supports audio and video data, which can be uploaded and updated through the CleverSee AI Search and Q&A Platform UI or by using the Add/Update Dataset Data API.
Authentication method
Use the Alibaba Cloud SDK to call the CleverSee AI Search service. For detailed instructions, see AI Search Engine API.
Request parameters
Parameters
Parameter | Type | Required | Description | Example | |
appId | String | Yes | The unique ID of the search application. |
| |
query | Object | Yes | The query conditions object. | (See nested parameters) | |
├─ | texts | Array[String] | No | An array of text queries. |
|
├─ | imageUrl | Array[String] | No | An array of image URL queries. • Currently, only one image URL is supported. The image size cannot exceed 10 MB. Supported formats: JPG, PNG, WEBP, and JPEG. |
|
├─ | pageSize | Integer | Yes | The number of results to return per page. |
|
├─ | pageNo | Integer | No | The page number, starting from 1. • Default value: |
|
└─ | excludeIds | Array[String] | No | A list of primary keys to exclude from the results. • Use case: Filter out previously viewed items. |
|
user | Object | No | The user information object for future user-centric analysis. | (See nested parameters) | |
└─ | userId | String | No | The unique ID of the user. |
|
Request example
The following is a typical request example.
JSON format
curl -X POST 'https://aisearchengine.aliyuncs.com/api/v1/platform/app/search' \
-H 'Content-Type: application/json' \
-H "Date: $(LC_ALL=C date -u +'%a, %d %b %Y %H:%M:%S GMT')" \
-H 'x-acs-apikey: ALS*****' \
-d '{
"appId": "your_app_id",
"query": {
"texts": ["a little girl"],
"imageUrls": ["https://your-image-url.com/image.jpg"],
"pageSize": 10,
"pageNo": 1
}
}'Response parameters
Top-level structure
Parameter | Type | Description | Example | |
code | Integer | The status code. A value of |
| |
message | String | The response message. |
| |
requestId | String | The unique request ID. Use this ID for troubleshooting. |
| |
data | Object | The main data object in the response. | (See nested parameters) | |
├─ | size | Integer | The number of items per page, which matches the |
|
├─ | page | Integer | The current page number. |
|
├─ | total | Integer | The actual number of items returned on the current page. |
|
├─ | traceInfo | Null | Trace information. |
|
└─ | extra | Object | Additional metadata. Note The exclude_ids field contains the list of IDs that are actually excluded, and its format is
| { "exclude_ids": ["id_1", "id_2"] } |
items | Array[Object] | An array of search result items. See the next section for details. | (See section 3.2) | |
status | String | The business-level status code, returned as a string. |
| |
errorMessage | Null | The error message. This is |
|
3.2 items Element structure details
Each object in the items array represents a search result. The content field contains different attributes depending on the media type (image, video, or audio). The following describes the common structure and the fields that are specific to video and audio:
Image searchitems
Parameter | Type | Description | Example | |
score | Float | The relevance score. |
| |
content | Object | The content details object. | (See nested parameters) | |
├─ | image_url | String | The URL of the image. • This presigned URL is valid for 24 hours from the dataset's creation time. |
|
├─ | s_name | String | The original file name. |
|
├─ | pk_id | String | The primary key of the original resource. |
|
└─ | s_dataset_id | String | The ID of the dataset containing the resource. |
|
Audio and video searchitems
Parameter | Type | Description | Example | |
score | Float | The relevance score. |
| |
content | Object | The content details object. | (See nested parameters) | |
├─ | s_raw_cover_pic | String | The URL of the full video cover image. • This presigned URL is valid for 24 hours from the dataset's creation time. • The audio/plain text result is |
|
├─ | s_segment_cover_pic | String | The URL of the video segment cover image. • This presigned URL is valid for 24 hours from the dataset's creation time. • The audio/plain text result is |
|
├─ | s_raw_file_path | String | The URL of the media file. • This presigned URL is valid for 24 hours from the dataset's creation time. • Supported formats include MP4, MP3, and JPG. |
|
├─ | s_name | String | The original file name. |
|
├─ | pk_id | String | The primary key of the original resource. |
|
├─ | s_dataset_id | String | The ID of the dataset containing the resource. |
|
├─ | s_segment_start_millisecond | Integer | The start time of the segment in milliseconds. • This value may be 0 for results that are not video or audio segments. |
|
├─ | s_segment_end_millisecond | Integer | The end time of the segment in milliseconds. • This value may be 0 for results that are not video or audio segments. |
|
├─ | s_raw_length | Integer | The duration of the file in milliseconds. |
|
├─ | s_video_type | String | Video type tag An AI-generated, video-level tag that categorizes the video. The value is one of the following:
|
|
├─ | s_video_topic | String | Video topic tag An AI-generated, video-level tag that describes the core topic of the video. The values are not from a fixed list. |
|
├─ | s_global_summary | String | Global summary tag An AI-generated, video-level tag that provides a core summary of the video content. The values are not from a fixed list. |
|
└─ | s_global_keywords | String | Global keywords tag An AI-generated, video-level tag that includes two to four keywords summarizing the video content. The values are not from a fixed list. |
|
Response examples
Image search example
JSON format
{
"code": 200,
"message": "success",
"data": {
"size": 1,
"page": 1,
"total": 1,
"traceInfo": null,
"extra": {
"exclude_ids": ["3f95b343xxxxxxxxxxxx"]
},
"items": [
{
"id": "3f95b343xxxxxxxxxxxx",
"score": 0.8029279573006508,
"content": {
"s_name": "sample_image.png",
"image_url": "https://.../image.png?Expires=...",
"pk_id": "3f95b343xxxxxxxxxxxx",
"s_dataset_id": "594"
},
"algorithm": {},
"traceInfo": null
}
],
"status": "200",
"errorMessage": null
},
"requestId": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}Video search example
JSON format
{
"code": 200,
"data": {
"total": 1,
"size": 1,
"traceInfo": null,
"extra": {
"exclude_ids": ["01XXXXXXXXXXXXXXX"]
},
"errorMessage": null,
"page": 1,
"items": [{
"score": 0.577594,
"traceInfo": null,
"id": "01XXXXXXXXXXXXXXX",
"content": {
"s_raw_file_path": "https://.../video.mp4?Expires=...",
"s_raw_length": 1036122,
"pk_id": "01XXXXXXXXXXXXXXX",
"s_global_summary": "The first half of the video focuses on the conflicts and collaborations between characters, presenting complex relationships and emotional changes through multiple plot developments, including chases, dialogues, and investigations. The second half shifts to stage performance content, showing a singer's live performance and audience interaction at a large event. The overall content combines narrative storytelling with musical performance elements.",
"s_raw_cover_pic": "https://.../frame_1.jpg?Expires=...",
"s_name": "demo_video.mp4",
"s_dataset_id": "833",
"s_global_keywords": "Plot interaction, Character relationships, Investigation and chase, Musical performance, Stage singing",
"s_video_topic": "Plot and musical performance",
"s_video_type": "Film & TV/Variety Show"
},
"algorithm": {}
}],
"status": "200"
},
"requestId": "xxxxxxxxxxxxxxxxxxxxxxxx",
"message": "success"
}Error codes
HTTP status code | Error code | Error message | Description |
500 |
|
| A system-level internal error occurred. |
403 |
|
| You do not have permission to access the specified application. |
400 |
|
| One or more request parameters are invalid. |
404 |
|
| The specified application does not exist. |
407 |
|
| An application access privilege escalation error occurred. |
405 |
|
| The input text exceeds the maximum allowed length. |
406 |
|
| The number of images in the request exceeds the limit. |
Media resource URLs
To get presigned URLs for downloading media files (images or videos) from the search results, see the Get Presigned URLs for Media Resources in Search Results API.