AI Search API

Updated at:

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.

"2048962366415007746"

query

Object

Yes

The query conditions object.

(See nested parameters)

├─

texts

Array[String]

No

An array of text queries.
• Currently, only one string is supported, with a maximum length of 256 characters.

["A girl receives a small red flower"]

├─ 

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.

["https://example.com/img.jpg"]

├─ 

pageSize

Integer

Yes

The number of results to return per page.

10

├─ 

pageNo

Integer

No

The page number, starting from 1.

• Default value: 1

1

└─ 

excludeIds

Array[String]

No

A list of primary keys to exclude from the results.

• Use case: Filter out previously viewed items.

[] or ["id_001", "id_002"]

user

Object

No

The user information object for future user-centric analysis.

(See nested parameters)

└─ 

userId

String

No

The unique ID of the user.

"asdfgnoevnor"

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 200 indicates success.

200

message

String

The response message.

"success"

requestId

String

The unique request ID. Use this ID for troubleshooting.

"566371ae...b34"

data

Object

The main data object in the response.

(See nested parameters)

├─ 

size

Integer

The number of items per page, which matches the pageSize request parameter.

4

├─ 

page

Integer

The current page number.

1

├─ 

total

Integer

The actual number of items returned on the current page.

4

├─ 

traceInfo

Null

Trace information.

null

└─

extra

Object

Additional metadata.

Note The exclude_ids field contains the list of IDs that are actually excluded, and its format is Array[String].

  • Example: ["id_1", "id_2"]

{ "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.

"200"

errorMessage

Null

The error message. This is null if the request is successful.

null

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.

0.005369

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.

"https://.../image_1.png?Expires=..."

├─ 

s_name

String

The original file name.

"image_1.png"

├─

pk_id

String

The primary key of the original resource.

"01KQ...ZX020"

└─

s_dataset_id

String

The ID of the dataset containing the resource.

"594"

Audio and video searchitems

Parameter

Type

Description

Example

score

Float

The relevance score.

0.005369

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 null

"https://.../frame_0.jpg?Expires=..."

├─

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 null

"https://.../frame_1.jpg?Expires=..."

├─

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.

"https://.../video.mp4?Expires=..."

├─ 

s_name

String

The original file name.

"video_001.mp4"

├─

pk_id

String

The primary key of the original resource.

"01KQ...ZX020"

├─

s_dataset_id

String

The ID of the dataset containing the resource.

"594"

├─ 

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.

10000

├─ 

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.

20000

├─ 

s_raw_length

Integer

The duration of the file in milliseconds.

146046

├─ 

s_video_type

String

Video type tag

An AI-generated, video-level tag that categorizes the video. The value is one of the following:

Recorded Classroom Lecture, Micro-course/MOOC, Science Popularization, Skill Tutorial, News Broadcast, Interview/Speech, Documentary, Live Report, Promotional Film/Advertisement, Press Conference, Product Demonstration, Vlog/Daily Life, Film & TV/Variety Show, Game Live Streaming, Short Skit/Comedy, Food/Travel, Music & Dance, Sports Event, Gala/Performance, or Other.

Recorded Classroom Lecture

├─

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.

Single-player game live stream

├─ 

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.

This video provides a detailed review of the performance of the latest smartphone from Brand XX, focusing on its night photography capabilities and gaming heat dissipation.

└─  

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.

Smartphone review, Performance test

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

SYSTEM_ERROR

system inner error

A system-level internal error occurred.

403

APP_FORBIDDEN

no permission to access this app

You do not have permission to access the specified application.

400

INVALID_PARAM

invalid parameter

One or more request parameters are invalid.

404

APP_NOT_FOUND

app not found

The specified application does not exist.

407

APP_ACCESS_UNAVAILABLE

app access privilege escalation

An application access privilege escalation error occurred.

405

INPUT_TOO_LONG

input text exceeds maximum length

The input text exceeds the maximum allowed length.

406

IMAGE_LIMIT_EXCEEDED

image count exceeds maximum limit

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.