Multimodal Search API

Updated at:

This API returns images and information about their source webpages based on a text query.

1. API

API name: MultimodalSearch

The MultimodalSearch API is optimized for retrieval quality, cost, and latency. It currently supports searching for image-related information based on text queries. The response provides image URLs, source webpage URLs, titles, publication times, and image dimensions, which can be directly used by multimodal models or intelligent agents.

Use the engineType request parameter to select the engine type. Different engines use different data sources and have different pricing.

Important

This API currently supports only text-to-image search, which retrieves images by using a text query. The engineType parameter accepts only two values: MultimodalSpeed and MultimodalSpeedAdvanced. An invalid value returns an HTTP 400 error.

Note

The server-side timeout is 5 seconds. The two engines have significantly different response latencies: MultimodalSpeed typically responds within 300 ms, while MultimodalSpeedAdvanced requires more resources and usually takes around 3 seconds. When using MultimodalSpeedAdvanced, set the client-side read timeout to at least 6 seconds to prevent client-side timeouts.

2. API definition

Request parameters

Parameter

Type

Required

Default

Description

Example

query

string

Yes

-

The search query. The value must be 1 to 50 characters long. For optimal results, we recommend keeping the query under 30 characters. You can use a model on the client side to rewrite the query before calling the API. Queries longer than 50 characters do not cause an error, but retrieval quality is not guaranteed.

lion

engineType

string

No

MultimodalSpeed

The search engine type. Valid values: MultimodalSpeed (for fast search) and MultimodalSpeedAdvanced (for enhanced search with multiple data sources and higher quality). Passing any other value returns an HTTP 400 error.

MultimodalSpeedAdvanced

advancedParams

map<string, string>

No

-

Advanced search parameters, where both the key and value are strings. The following keys are supported: excludeSites specifies a comma-separated list of domain names to exclude. numResults specifies the maximum number of results to return (valid range: 1 to 30).

{"excludeSites": "www.360doc.com,weibo.com", "numResults": "20"}

Parameter usage

  • The numResults parameter specifies the maximum number of results to return, not the exact number. The actual number of results depends on the availability of relevant images for the query and is often less than numResults. For example, a request with numResults=30 might return 28 results, while a request with numResults=5 might return 3. Your application should not assume that the number of returned results will equal numResults.

  • If you do not specify numResults, the number of results is not fixed and is determined by the server. If your business requires a stable number of results, you must explicitly set the numResults parameter.

  • If advancedParams.numResults is outside the range of 1 to 30, the API returns an HTTP 400 error with the error code Retrieval.InvalidSitesSize.

  • The excludeSites value must be bare domain names, without protocol prefixes such as http:// or https://, and without any paths. If a protocol prefix is included, the exclusion rule for that domain silently fails: the API returns an HTTP 200 response, but the specified site still appears in the results. This is a common integration error.

  • The excludeSites parameter supports parent domain matching. For example, if you enter baidu.com, subdomains such as mbd.baidu.com and quanmin.baidu.com are also excluded.

  • Excluding sites can significantly reduce the number of available results. When excludeSites and numResults are used together, the actual number of returned results may be less than numResults.

Response parameters

Field

Type

Nullable

Description

Example

requestId

string

No

The request ID. You can provide this ID for troubleshooting.

35E5608A-A737-2038-****-D9D34C6BFD9E

imageItems[]

array

No

A list of image results, sorted by relevance in descending order. If no matching results are found, an empty array [] is returned. This field is never omitted.

-

imageItems[].title

string

No

The title of the image's source webpage.

A lion's life of battle conceals countless legendary struggles

imageItems[].hostPageUrl

string

No

The URL of the source webpage.

https://www.example.com/news/12345.html

imageItems[].imageUrl

string

No

The direct image link from a third-party site.

https://pic.example.com/2025/lion.jpeg

imageItems[].publishedTime

string

Not nullable for MultimodalSpeed; nullable for MultimodalSpeedAdvanced

The publication time of the webpage in ISO 8601 format. When engineType is MultimodalSpeedAdvanced, this field may return JSON null for some results. This is a literal null value, not an empty string or an omitted field. Ensure that you use a nullable type for deserialization.

2024-12-18T22:24:24+08:00

imageItems[].height

int32

No

The height of the image in pixels.

1330

imageItems[].width

int32

No

The width of the image in pixels.

1000

searchInformation.searchTime

int64

No

The search duration in milliseconds.

1048

queryContext.originalQuery.query

string

No

The original query from the request.

lion

Consuming results

  • No results found: If a query does not match any images, the API returns an HTTP 200 status code with an empty imageItems array. The requestId, searchInformation, and queryContext fields are returned as usual. Your application should handle an empty list and not treat it as a failed call.

  • The imageUrl is a direct image link to a third-party website. The service does not proxy or cache the images. Some sites may have hotlink protection enabled, or the image may no longer exist, which can result in a 403 or 404 error when you try to access the URL. For reliable image display, cache the images or implement a fallback for failed image loads.

  • Some imageUrl and hostPageUrl values are returned as http links, which will trigger mixed content blocking if used directly on an HTTPS page. You must upgrade the protocol or use a proxy on the client side.

  • A single response may contain multiple images from the same webpage, which have the same title and hostPageUrl but different imageUrl values. If you need to deduplicate results by webpage, you must handle this client-side.

  • Log all requestId values. You will need to provide the request ID when you seek support for troubleshooting.

3. Examples

Request body

{
  "query": "lion",
  "advancedParams": {
    "excludeSites": "www.360doc.com,weibo.com"
  }
}

Response body

{
  "requestId": "35E5608A-A737-2038-****-D9D34C6BFD9E",
  "imageItems": [
    {
      "title": "A lion's life of battle conceals countless legendary struggles",
      "publishedTime": "2025-04-12T12:47:54+08:00",
      "imageUrl": "http://pic.example.com/bjh/250412/cb5ab496c1b690c6514da34db1ecabb6.jpeg",
      "hostPageUrl": "https://example.com/sv?vid=4798422598618199036",
      "height": 1280,
      "width": 720
    },
    {
      "title": "Lion Subspecies: Differences and Conservation Status",
      "publishedTime": "2025-12-13T11:52:08+08:00",
      "imageUrl": "http://pic.example.com/bjh/other/7e5c29616163c88db19504ea7dffba39.png",
      "hostPageUrl": "https://example.com/sv?vid=18144687723668657466",
      "height": 1664,
      "width": 928
    }
  ],
  "searchInformation": {
    "searchTime": 808
  },
  "queryContext": {
    "originalQuery": {
      "query": "lion"
    }
  }
}
Note

The example response above is abridged. The actual number of results is determined by the server based on availability. The numResults parameter only sets the upper limit.

Response with null publishedTime

When engineType is set to MultimodalSpeedAdvanced, the publishedTime field for some results may be JSON null:

{
  "requestId": "35E5608A-A737-2038-****-D9D34C6BFD9E",
  "imageItems": [
    {
      "title": "Lion Subspecies: Differences and Conservation Status",
      "publishedTime": null,
      "imageUrl": "https://pic.example.com/2025/lion-subspecies.png",
      "hostPageUrl": "https://www.example.com/wildlife/lion.html",
      "height": 522,
      "width": 770
    }
  ],
  "searchInformation": {
    "searchTime": 3424
  },
  "queryContext": {
    "originalQuery": {
      "query": "lion"
    }
  }
}

Response for no results

If the query matches no images, the API returns an HTTP 200 status code with an empty imageItems array:

{
  "requestId": "92d9fb66-382b-4a4d-9f6b-97fe2479ef31",

  "imageItems": [ ],

  "searchInformation": {
    "searchTime": 504
  },
  "queryContext": {
    "originalQuery": {
      "query": "a query with no matching results"
    }
  }
}

4. API call

HTTP call

Use your product credentials (API-KEY) to authenticate requests. You can create an API-KEY in the console under "Create/View Credential Key". After creation, the new key can take up to 5 minutes to become active.

  • Request Method: POST

  • Request URL: https://cloud-iqs.aliyuncs.com/search/multimodal

  • Authentication: Use the request header Authorization: Bearer $API_KEY.

  • Request Body: Content-Type: application/json

Basic call:

curl -X POST https://cloud-iqs.aliyuncs.com/search/multimodal \
  --header "Authorization: Bearer $API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "query": "lion"
  }'

Call with all optional parameters:

curl -X POST https://cloud-iqs.aliyuncs.com/search/multimodal \
  --header "Authorization: Bearer $API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "query": "lion",
    "engineType": "MultimodalSpeedAdvanced",
    "advancedParams": {
      "numResults": "20",
      "excludeSites": "www.360doc.com,weibo.com"
    }
  }'

HTTP error response

If a call fails, the API returns a non-200 status code. The response body is a JSON object. The errorCode and code fields are identical, as are the errorMessage and message fields. They are duplicated for compatibility with different client versions.

{
  "errorCode": "Retrieval.InvalidAPIKey",
  "errorMessage": "Incorrect APIKey provided. You can find your api key at https://ipaas.console.aliyun.com/api-key",
  "code": "Retrieval.InvalidAPIKey",
  "message": "Incorrect APIKey provided. You can find your api key at https://ipaas.console.aliyun.com/api-key"
}
Note

If the request body JSON is malformed or an invalid value is provided for engineType, the API returns an HTTP 400 error. The response body in this case may be plain text instead of JSON. Your application should always check the HTTP status code before attempting to deserialize the response body to avoid exceptions on non-200 responses.

SDK call

To make API calls with an Alibaba Cloud SDK, authenticate by using your AccessKey/Secret. The service endpoint is as follows:

Region name

Region ID

Public endpoint

China (Zhangjiakou)

cn-zhangjiakou

iqs.cn-zhangjiakou.aliyuncs.com

Python SDK

Prerequisites: Python 3.8 or later. Install the SDK:

pip3 install alibabacloud_iqs20241111==1.10.2

Synchronous call:

from Tea.exceptions import TeaException
from alibabacloud_iqs20241111 import models
from alibabacloud_iqs20241111.client import Client
from alibabacloud_tea_openapi import models as open_api_models

def create_client() -> Client:
    # We recommend loading your AccessKey/Secret from environment variables to avoid hard-coding them.
    config = open_api_models.Config(
        access_key_id='$YOUR_ACCESS_KEY',
        access_key_secret='$YOUR_ACCESS_SECRET'
    )
    config.endpoint = 'iqs.cn-zhangjiakou.aliyuncs.com'
    return Client(config)

def main() -> None:
    client = create_client()
    request = models.MultimodalSearchRequest(
        body=models.MultimodalSearchBody(
            query='lion',
            advanced_params={
                "numResults": "20",
                "excludeSites": "www.360doc.com,weibo.com"
            }
        )
    )
    try:
        response = client.multimodal_search(request)
        print(f"request_id:{response.body.request_id}, "
              f"size:{len(response.body.image_items)}, "
              f"server_cost:{response.body.search_information.search_time}")
        for index, item in enumerate(response.body.image_items):
            print(f"{index}. {'-' * 20}")
            print(f"title:{item.title}")
            print(f"image_url:{item.image_url}")
            print(f"host_page_url:{item.host_page_url}")
            print(f"published_time:{item.published_time}")
            print(f"width:{item.width}, height:{item.height}")
    except TeaException as e:
        print(f"api exception, requestId:{e.data.get('requestId')}, "
              f"code:{e.code}, message:{e.data.get('message')}")

if __name__ == '__main__':
    main()

Asynchronous call: Replace client.multimodal_search(request) with await client.multimodal_search_async(request) and execute the calling function in asyncio.run(). The rest of the code is the same.

SDK Field Naming Mapping

The field names used in the SDKs differ from the camelCase JSON field names in the HTTP request body. When migrating from HTTP to an SDK, use the following mapping table:

HTTP JSON field

Python SDK

Java / Go SDK

query

query

query / Query

engineType

engine_type

engineType / EngineType

advancedParams

advanced_params

advancedParams / AdvancedParams

imageItems

image_items

imageItems / ImageItems

hostPageUrl

host_page_url

hostPageUrl / HostPageUrl

publishedTime

published_time

publishedTime / PublishedTime

searchInformation.searchTime

search_information.search_time

searchInformation.searchTime

The keys within advancedParams (excludeSites, numResults) retain their original camelCase format in all languages and are not converted.

Java SDK

Prerequisites: Java 8 or later. Maven dependency:

<dependency>
    <groupId>com.aliyun</groupId>
    <artifactId>iqs20241111</artifactId>
    <version>1.10.2</version>
</dependency>

Sample code:

package com.aliyun.iqs.example;

import com.aliyun.iqs20241111.Client;
import com.aliyun.iqs20241111.models.*;
import com.aliyun.teaopenapi.models.Config;

import java.util.HashMap;
import java.util.Map;

public class MultimodalSearchExample {

    public static void main(String[ ] args) throws Exception {

        Client client = initClient();
        invoke(client, "lion", "www.360doc.com,weibo.com");
    }

    private static Client initClient() throws Exception {
        // We recommend loading your AccessKey/Secret from environment variables to avoid hard-coding them.
        String accessKeyId = System.getenv("ACCESS_KEY");
        String accessKeySecret = System.getenv("ACCESS_SECRET");

        Config config = new Config()
            .setAccessKeyId(accessKeyId)
            .setAccessKeySecret(accessKeySecret);
        config.setEndpoint("iqs.cn-zhangjiakou.aliyuncs.com");
        return new Client(config);
    }

    private static void invoke(Client client, String query, String excludeSites) {
        MultimodalSearchBody input = new MultimodalSearchBody();
        input.setQuery(query);

        Map<String, String> advancedParams = new HashMap<>();
        advancedParams.put("excludeSites", excludeSites);
        advancedParams.put("numResults", "20");
        input.setAdvancedParams(advancedParams);

        MultimodalSearchRequest request = new MultimodalSearchRequest().setBody(input);

        try {
            MultimodalSearchResponse response = client.multimodalSearch(request);
            MultimodalSearchOutput result = response.getBody();
            System.out.println("requestId:" + result.getRequestId());
            result.getImageItems().forEach(item -> System.out.println(
                item.getTitle() + " | " + item.getImageUrl() + " | " + item.getHostPageUrl()));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Go SDK

Prerequisites: Go 1.10.x or later. Install the SDK:

require (
  github.com/alibabacloud-go/iqs-20241111 v1.10.2
  github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.10
)

Sample code:

package main

import (
  "fmt"
  "log"

  openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
  iqs20241111 "github.com/alibabacloud-go/iqs-20241111/client"
  util "github.com/alibabacloud-go/tea-utils/v2/service"
  "github.com/alibabacloud-go/tea/tea"
)

const endpointURL = "iqs.cn-zhangjiakou.aliyuncs.com"

func createClient() (*iqs20241111.Client, error) {
  // We recommend loading your AccessKey/Secret from environment variables to avoid hard-coding them.
  accessKeyID := "YOUR_ACCESS_KEY"
  accessKeySecret := "YOUR_ACCESS_SECRET"

  config := &openapi.Config{
    AccessKeyId:     tea.String(accessKeyID),
    AccessKeySecret: tea.String(accessKeySecret),
    Endpoint:        tea.String(endpointURL),
  }
  return iqs20241111.NewClient(config)
}

func runMultimodalSearch(client *iqs20241111.Client) error {
  body := &iqs20241111.MultimodalSearchBody{
    Query: tea.String("lion"),
    AdvancedParams: map[string]interface{}{
      "numResults":   "20",
      "excludeSites": "www.360doc.com,weibo.com",
    },
  }
  request := &iqs20241111.MultimodalSearchRequest{Body: body}
  runtime := &util.RuntimeOptions{}

  resp, err := client.MultimodalSearchWithOptions(request, nil, runtime)
  if err != nil {
    return fmt.Errorf("multimodal search failed: %w", err)
  }

  fmt.Printf("[%s] items: %d\n", *resp.Body.RequestId, len(resp.Body.ImageItems))
  return nil
}

func main() {
  client, err := createClient()
  if err != nil {
    log.Fatalf("Failed to create client: %v", err)
  }
  if err := runMultimodalSearch(client); err != nil {
    log.Fatalf("Error running multimodal search: %v", err)
  }
}
Note
  • In the Go SDK, the AdvancedParams parameter is of type map[string]interface{}. However, the server parses the value as a string, so you must pass the value as a string, such as "numResults": "20".

  • See the Access Methods chapter for other access methods, such as MCP and Skill.

5. Error codes

Parameter errors

The following errors can occur with either authentication method. Check your request parameters.

Status

Error code

Error message

Solution

400

MissingParameter

Required parameter 'query' is not found.

The query parameter is missing or an empty string. Pass a query that is 1 to 50 characters long.

400

Retrieval.InvalidSitesSize

The specified parameter numResults's size is not in range [1, 30]

The advancedParams.numResults value is outside the valid range of 1 to 30. Adjust the value.

400

-

The response body is plain text, not JSON.

The value for engineType is invalid or the request body JSON is malformed. The engineType parameter only supports MultimodalSpeed and MultimodalSpeedAdvanced.

Authentication and account errors

Status

Error code

Error message

Authentication method

Solution

403

Retrieval.InvalidAPIKey

Incorrect APIKey provided. You can find your api key at https://ipaas.console.aliyun.com/api-key

HTTP (API-KEY)

Check that the Authorization request header is in the Bearer $API_KEY format and that the API-KEY is correct. A new API-KEY takes about 5 minutes to take effect.

403

-

-

HTTP (API-KEY)

The Authorization request header is missing. Provide the required authentication information.

404

InvalidAccessKeyId.NotFound

Specified access key is not found.

SDK (AccessKey/Secret)

Check and ensure that your AccessKey/Secret is correct.

403

Retrieval.NotActivate

Please activate AI search service

Both

Place an order to activate the service or contact your account manager.

403

Retrieval.Arrears

Please recharge first.

Both

Your account has an insufficient balance. Please top up your account.

403

Retrieval.NotAuthorised

Please authorize the AliyunIQSFullAccess privilege to the sub-account.

SDK (AccessKey/Secret)

The sub-account is not authorized. See "Create a RAM user and grant permissions".

403

Retrieval.TestUserPeriodExpired

The test period has expired.

Both

Your trial period has expired (valid for 15 days after you place an order). Contact your Alibaba Cloud account manager to upgrade to a paid plan.

429

Retrieval.Throttling.User

Request was denied due to user flow control.

Both

The request was denied due to throttling. Contact your Alibaba Cloud account manager to upgrade your plan.

429

Retrieval.TestUserQueryPerDayExceeded

The query per day exceed the limit.

Both

You have exceeded the daily query limit for your trial (1,000 queries/day). Contact your Alibaba Cloud account manager to upgrade to a paid plan.

Note

If an HTTP call returns a 404 error and the response body is empty, check the request method and path. This API only supports POST requests to https://cloud-iqs.aliyuncs.com/search/multimodal. Using GET or other methods will return a 404 error.