All Products
Search
Document Center

OpenSearch:Internet search

Last Updated:Aug 05, 2025

AI Search Open Platform provides Internet search functionality, supporting direct calls to the Internet search API or enabling Internet search when calling content generation services.

Services

Service name

Service ID

Service description

Internet search service

ops-web-search-001

Provides general Internet search services that can be used with large models to expand responses in private knowledge base scenarios.

  • The authentication information is obtained.

    When you call an AI Search Open Platform service by using an API, you need to authenticate the caller's identity.

  • The service access address is obtained.

    You can call a service over the Internet or a virtual private cloud (VPC). For more information, see Get service registration address.

Request method

POST

URL

{host}/v3/openapi/workspaces/{workspace_name}/web-search/{service_id}
  • host: The address for calling the service. You can call API services through the internet or VPC. For more information, see Obtain service access address.

  • workspace_name: The workspace name, such as default.

  • service_id: The built-in service ID, such as ops-web-search-001.

Request parameters

Header parameters

API-KEY authentication

Parameter

Type

Required

Description

Example value

Content-Type

String

Yes

Request type: application/json

application/json

Authorization

String

Yes

API-Key

Bearer OS-d1**2a

Body parameters

Parameter

Type

Required

Description

Default value

query

String

Yes

The search keyword.

query_rewrite

Boolean

No

Specifies whether to enable LLM to rewrite the query. The default value is true.

true

top_k

Integer

No

The number of search results to return.

5

history

List

No

The conversation history between the user and the model. Each element in the list is in the form of {"role": role, "content": content}, where the role can be system, user, or assistant.

  • system: Represents system-level messages, which can only be used for the first message in the conversation history (messages[0]). Using the system role is optional. If it exists, it must be at the beginning of the list.

  • user and assistant: Represent the dialogue between the user and the model. They should appear alternately in the conversation to simulate the actual conversation flow.

null

content_type

String

No

The content type of search results.

  • snippet: A brief description of the webpage content.

  • summary: A text summary of the webpage content, which takes more time compared to snippet.

snippet

Curl request example

curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer Your-API-KEY" \
"http://xxxx-hangzhou.opensearch.aliyuncs.com/v3/openapi/workspaces/default/web-search/ops-web-search-001" \
-d '{
      "history": [
        {"role": "system", "content": "You are a robot assistant"},
        {"role": "user", "content": "What is the capital of Zhejiang Province"},
        {"role": "assistant", "content": "Hangzhou"}
        ],
      "query":"What is the weather like in Hangzhou today",
      "query_rewrite":true,
      "top_k":5,
      "content_type":"snippet"
}'

Response parameters

Parameter

Type

Description

Example value

result.search_result

List<search_result>

The results returned from this Internet search.

result.search_result[].tilte

String

The webpage title.

Hangzhou Weather

result.search_result[].link

String

The webpage link.

https://www.xxx.com

result.search_result[].snippet

String

The webpage summary.

Cloudy tonight; sunny to partly cloudy tomorrow; partly cloudy to cloudy the day after tomorrow

result.search_result[].content

String

The webpage content.

Hangzhou Weather\nCloudy tonight; sunny to partly cloudy tomorrow;

result.search_result[].position

Integer

The position of the webpage in the retrieval results.

3

usage.search_count

Integer

The number of Internet searches.

1

usage.rewrite_model.input_tokens

Integer

The input tokens for query rewriting.

100

usage.rewrite_model.output_tokens

Integer

The output tokens after query rewriting.

100

usage.rewrite_model.total_tokens

Integer

The total number of tokens after query rewriting.

200

usage.filter_model.input_tokens

Integer

The input tokens for filtering search results using the large model.

100

usage.filter_model.output_tokens

Integer

The output tokens after filtering search results using the large model.

100

usage.filter_model.total_tokens

Integer

The total number of tokens for filtering search results using the large model.

200

Response examples

Sample success response

{
  "result":{
    "search_result": [
        {
          "title": "Hangzhou Weather",
          "link": "https://www.hzqx.com/pc/hztq/",
          "snippet": "Cloudy tonight; sunny to partly cloudy tomorrow; partly cloudy to cloudy the day after tomorrow. North wind 2-3 level tonight, east wind 2 level tomorrow. Maximum temperature tomorrow during the day is 10 degrees, minimum temperature tomorrow morning is 3 degrees, average relative humidity tomorrow is 65%.",
          "position": 3,
          "content": "Hangzhou Weather\nCloudy tonight; sunny to partly cloudy tomorrow; partly cloudy to cloudy the day after tomorrow. North wind 2-3 level tonight, east wind 2 level tomorrow. Maximum temperature tomorrow during the day is 10 degrees, minimum temperature tomorrow morning is 3 degrees, average relative humidity tomorrow is 65%."
        },
        {
          "title": "Hangzhou Weather Forecast_Weather Query - Moji Weather",
          "link": "https://tianqi.moji.com/weather/china/zhejiang/hangzhou",
          "snippet": "Hangzhou current conditions: 3 degrees sunny, humidity: 66%, northwest wind: level 3. Daytime: 10 degrees, sunny. Night: cloudy, 3 degrees, it's getting cool, Moji Weather suggests you wear a thick coat over your wool sweater, and elderly or frail individuals can wear a wool overcoat to increase warmth.",
          "position": 4,
          "content": "Hangzhou Weather Forecast_Weather Query - Moji Weather\nHangzhou current conditions: 3 degrees sunny, humidity: 66%, northwest wind: level 3. Daytime: 10 degrees, sunny. Night: cloudy, 3 degrees, it's getting cool, Moji Weather suggests you wear a thick coat over your wool sweater, and elderly or frail individuals can wear a wool overcoat to increase warmth."
        }
    ]
  },
    "usage": {
            "search_count": 1,
            "rewrite_model.input_tokens": 249,
            "rewrite_model.output_tokens": 1,
            "rewrite_model.total_tokens": 250,
            "filter_model.input_tokens": 1804,
            "filter_model.output_tokens": 216,
            "filter_model.total_tokens": 2020
    }
}

Sample error response

When an access request fails, the output result indicates the error cause through the code and message fields.

{
    "request_id": "6F33AFB6-A35C-****-AFD2-9EA16CCF4383",
    "latency": 2.0,
    "code": "InvalidParameter",
    "http_code": 400,
    "message": "JSON parse error: Cannot deserialize value of type `ImageStorage` from String \\"xxx\\"
}

Status codes

HTTP status code

Error message

Description

200

-

Request successful, including task failure scenarios. The actual task status needs to be determined from result.status

404

BadRequest.TaskNotExist

Task does not exist

400

InvalidParameter

Invalid request

500

InternalServerError

Internal error

For more information, see AI Search Open Platform Status codes.