AI Search Open Platform provides a web search feature. You can call the web search API directly, or enable web search when you call the content generation service.
Service list
Service name | Service ID | Description | API call QPS limit (includes the Alibaba Cloud account and its RAM users) |
Web search service | ops-web-search-001 | A general-purpose web search service that you can combine with a large language model (LLM) to extend answers in private knowledge base scenarios. | 3 Note To increase the QPS limit, submit a ticket to contact technical support. |
Get authentication credentials
The AI Search open platform requires an API key for authentication. For instructions, see Get an API key.
Get the service endpoint
You can call the service via the public network or a VPC. For details, see Get the service endpoint.
Request method
POST
URL
{host}/v3/openapi/workspaces/{workspace_name}/web-search/{service_id}host: The address used to call the service. You can call the API over the public network or through a VPC. For more information, see Obtain a service endpoint.
At the top of the API Keys page, select the target workspace, such as default (default workspace). In the Access Endpoints section, switch between the Public API Endpoint and Private API Endpoint tabs to view the corresponding service endpoint.
workspace_name: The name of the workspace. For example, default.
service_id: The built-in service ID. For example, ops-web-search-001.
Request parameters
Header parameters
API key authentication
Parameter | Type | Required | Description | Example |
Content-Type | String | Yes | The request type: application/json. | application/json |
Authorization | String | Yes | The API key. | Bearer OS-d1**2a |
Body parameters
Parameter | Type | Required | Description | Default |
query | String | Yes | The search query. | |
query_rewrite | Boolean | No | Specifies whether to enable an LLM to rewrite the query. Default value: 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 format
| null |
content_type | String | No | The content type of the search results.
| snippet |
way | String | No | Search only, without a web page body parsing strategy. This takes effect when
If you do not specify this parameter or specify an empty value, Search with a web page body parsing strategy. This takes effect when
If you do not specify this parameter or specify an empty value, | pro |
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?"},
{"role": "assistant", "content": "Hangzhou"}
],
"query":"What is the weather like in Hangzhou today?",
"query_rewrite":true,
"top_k":5,
"content_type":"snippet"
}'Specify the search and content extraction strategy
Use way to specify a more effective search and content extraction strategy, and combine it with content_type set to mainText to retrieve the main text of web pages.
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 '{
"query":"What is the weather like in Hangzhou today?",
"top_k":5,
"content_type":"mainText",
"way":"pro-fetch"
}'Response parameters
Parameter | Type | Description | Example |
result.search_result | List<search_result> | The results returned by this web search. | |
result.search_result[].title | String | The title of the web page. | Hangzhou Weather Weibo |
result.search_result[].link | String | The URL of the web page. | https://www.xxx.com |
result.search_result[].snippet | String | The summary of the web page. | Cloudy tonight; sunny to partly cloudy tomorrow; partly cloudy to overcast the day after tomorrow |
result.search_result[].content | String | The content of the web page. When content_type is set to snippet, the web page summary is returned. When content_type is set to mainText, the main text of the web page is returned. The main text is typically much longer than the summary. | Hangzhou Weather Weibo\nSame as the same period yesterday\nRelative humidity: -- % Wind: -- |
result.search_result[].position | Integer | The position of the web page in the retrieval results. In the current version, this field always returns null. | null |
result.search_result[].meta_info.publishedTime | String | The time when the web page was published. | 2026-07-03T04:25:40Z |
usage | Object | The billable items and the corresponding number of calls. Each key is in the When | "ops-web-search-001/pro": 1 |
Response example
Successful response example
{
"request_id": "5B9F5A24-8F1D-****-B7E2-3C6A1D9E4F02",
"latency": 2.3,
"usage": {
"ops-web-search-001/pro-fetch": 1,
"ops-web-search-001/pro": 1
},
"result": {
"search_result": [
{
"title": "Hangzhou Weather Weibo",
"link": "https://www.hzqx.cn/pc/hztq/",
"snippet": "Same as the same period yesterday Relative humidity: -% Wind: - Pressure: - hPa Precipitation in the past hour: - mm Visibility: - m Real-time data, not manually reviewed 10:55 on August 26, 2026 ...Updated at 08:00 on August 26, 2026 Air quality forecast Hangzhou Environmental Monitoring Station and Hangzhou M ...",
"position": null,
"meta_info": {
"publishedTime": "2026-08-26T10:55:00+08:00"
},
"content": "Hangzhou Weather Weibo\nSame as the same period yesterday\nRelative humidity: -- % Wind: --\nPressure: -- hPa Precipitation in the past hour: -- mm\nVisibility: -- m\n\n# \\*Real-time data, not manually reviewed\n\n10:55 on August 26, 2026 | Past 24 hours | Next 24 hours | Next 7 days\n\n# Objective 7-day weather forecast for the main urban area (the forecast data is\n...(truncated here; the actual response contains the full main text of the web page)"
},
{
"title": "Hangzhou 7-Day Weather",
"link": "https://www.ip.cn/tianqi/zhejiang/hangzhou/7day.html",
"snippet": "Hangzhou weather: 2026-08-20 to 2026-08-26 Weather forecast Mon Tue Wed Thu Fri Sat Sun August 20: moderate rain turning cloudy, 25°C to 31°C, sunrise 05:29, sunset 18:36 August 21: light rain turning overcast, 25°C to 32°C, sunrise 05:29, sunset 18:35 0 ...",
"position": null,
"meta_info": {
"publishedTime": "2026-08-21T00:00:00+08:00"
},
"content": "Hangzhou 7-Day Weather\n27° Cloudy 20 Excellent\nEast wind <force 3 Humidity 96% Pressure 1001 Pa\nThe latest 7-day weather for Hangzhou, Zhejiang, including the daily maximum temperature, minimum temperature, weather conditions, and wind direction\nToday 7 days 10 days 15 days Last 30 days\nHangzhou weather: 2026-08-20 to 2026-08-26 Weather forecast\n\n| Mon | Tue | Wed |\n...(truncated here; the actual response contains the full main text of the web page)"
}
]
}
}Error response example
If an error occurs in a request, the returned result indicates the cause of the error through code and message.
{
"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 code | Description |
200 | - | The request succeeded. This status is returned even if the task failed. Check the |
404 | BadRequest.TaskNotExist | The task does not exist. |
400 | InvalidParameter | The request was invalid. |
500 | InternalServerError | An internal error occurred. |
For more information, see AI Search Open Platform Status codes.