Appearance
Web search
Large language models (LLMs) rely on training data that has a knowledge cutoff date. Web search extends the model with real-time data from the web, enabling accurate answers about current stock prices, weather, news, and more.
How to use
Enable web search through any of the following APIs. Each uses different parameters.
OpenAI-compatible - Responses API
Add the web_search tool to the tools parameter to enable web search.
The Responses API only supports Qwen3.6, Qwen3.5, qwen3-max, qwen3-max-2026-01-23 . For best results, enable the
web_search,web_extractor, andcode_interpretertools at the same time.
HELPCODEESCAPE-python
response = client.responses.create(
model="qwen3-max-2026-01-23",
input="Hangzhou weather",
tools=[
{"type": "web_search"},
{"type": "web_extractor"},
{"type": "code_interpreter"}
],
extra_body={"enable_thinking": True}
)OpenAI-compatible - Chat Completions API
Set enable_search: true to enable web search.
HELPCODEESCAPE-python
# Import dependencies and create a client...
completion = client.chat.completions.create(
# Use a model that supports web search
model="qwen3-max",
messages=[{"role": "user", "content": "What is the weather in Hangzhou tomorrow"}],
# Because enable_search is not a standard OpenAI parameter, you must pass it through extra_body when using the Python SDK. When using the Node.js SDK, pass it as a top-level parameter.
extra_body={"enable_search": True}
)DashScope
Set enable_search: true to enable web search.
HELPCODEESCAPE-python
# Import dependencies...
response = dashscope.Generation.call(
# If the environment variable is not set, replace the following line with your Model Studio API key: api_key="sk-xxx",
api_key=os.getenv("DASHSCOPE_API_KEY"),
# Use a model that supports web search
model="qwen3-max",
messages=[{"role": "user", "content": "What is the weather in Hangzhou tomorrow"}],
# Enable web search using the enable_search parameter
enable_search=True,
result_format="message"
)Supported models
International
Qwen-Plus
qwen3.6-plus, qwen3.6-plus-2026-04-02 and later snapshot versions (Supported only by the Responses API)
qwen3.5-plus, qwen3.5-plus-2026-02-15 and later snapshot versions
Qwen-Flash
Qwen3.6-Flash: qwen3.6-flash, qwen3.6-flash-2026-04-16 and later snapshot versions (Supported only by the Responses API)
Qwen3.5-Flash: qwen3.5-flash, qwen3.5-flash-2026-02-23 and later snapshot versions
Qwen-max:
Qwen3.6-Max: qwen3.6-max-preview
qwen3-max and qwen3-max-2026-01-23:
Non-thinking mode: The search strategy must be set to
agent.Thinking mode: The search strategy must be set to
agentoragent_max(supports web extractor in addition to the agent strategy).
qwen3-max-2025-09-23 : The search strategy must be set to
agent.
Qwen-Omni: qwen3.5-omni-plus, qwen3.5-omni-plus-2026-03-15, qwen3.5-omni-flash, qwen3.5-omni-flash-2026-03-15
The search strategy must be set to
agent.Qwen-Omni-Realtime: qwen3.5-omni-plus-realtime, qwen3.5-omni-plus-realtime-2026-03-15, qwen3.5-omni-flash-realtime, qwen3.5-omni-flash-realtime-2026-03-15
The search strategy must be set to
agent.Role Assumption: qwen-plus-character, qwen-flash-character
Global
Qwen-Plus
qwen3.6-plus, qwen3.6-plus-2026-04-02 and later snapshot versions (Supported only by the Responses API)
qwen3.5-plus, qwen3.5-plus-2026-02-15 and later snapshot versions
Qwen-Flash
Qwen3.6-Flash: qwen3.6-flash, qwen3.6-flash-2026-04-16 and later snapshot versions (Supported only by the Responses API)
Qwen3.5-Flash: qwen3.5-flash, qwen3.5-flash-2026-02-23 and later snapshot versions
The models above support the agent and agent_max search strategies in both thinking and non-thinking modes.
Chinese mainland
Qwen-max:
qwen3-max and qwen3-max-2026-01-23:
Non-thinking mode: The search strategy must be set to
agent.Thinking mode: The search strategy must be set to
agentoragent_max(supports web extractor in addition to the agent strategy).
qwen3-max-2025-09-23 : The search strategy must be set to
agent.
Qwen-Plus:
qwen3.6-plus, qwen3.6-plus-2026-04-02 and later snapshot versions (Supported only by the Responses API)
qwen3.5-plus, qwen3.5-plus-2026-02-15 and later snapshot versions
Both the thinking model and non-thinking mode support the
agentandagent_maxsearch policies.
Qwen-Flash
Qwen3.6-Flash: qwen3.6-flash, qwen3.6-flash-2026-04-16 and later snapshot versions (Supported only by the Responses API)
Qwen3.5-Flash: qwen3.5-flash, qwen3.5-flash-2026-02-23 and later snapshot versions
Qwen-Omni: qwen3.5-omni-plus, qwen3.5-omni-plus-2026-03-15, qwen3.5-omni-flash, qwen3.5-omni-flash-2026-03-15
The search strategy must be set to
agent.Qwen-Omni-Realtime: qwen3.5-omni-plus-realtime, qwen3.5-omni-plus-realtime-2026-03-15, qwen3.5-omni-flash-realtime, qwen3.5-omni-flash-realtime-2026-03-15
The search strategy must be set to
agent.Assumed Role: qwen-plus-character
Getting started
The following example uses web search to query stock information.
OpenAI compatible
The OpenAI-compatible protocol does not return search sources in the response.
Python
HELPCODEESCAPE-python
import os
from openai import OpenAI
client = OpenAI(
# If the environment variable is not set, replace the following line with your Model Studio API key: api_key="sk-xxx",
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://dashscope-intl.aliyuncs.com/compatible-mode/v1",
)
completion = client.chat.completions.create(
model="qwen3-max",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the stock price of Alibaba?"},
],
extra_body={
"enable_search": True,
"search_options": {
# Web search strategy, only supports 'agent'
"search_strategy": "agent"
}
}
)
print(completion.choices[0].message.content)Sample response
HELPCODEESCAPE-plaintext
According to the latest market data, Alibaba's stock price in different markets is as follows:
* **US Stock (BABA)**: The latest price is approximately **159.84 USD**.
* **Hong Kong Stock (09988.HK)**: The latest price is approximately **158.00 HKD**.
Note that stock prices fluctuate in real-time, and the information above is for reference only. According to the latest market data, Alibaba's stock price in different markets is as follows:
* **US Stock (BABA)**: The latest price is approximately **159.84 USD**.
* **Hong Kong Stock (09988.HK)**: The latest price is approximately **158.00 HKD**.
Note that stock prices fluctuate in real-time, and the information above is for reference only.Node.js
HELPCODEESCAPE-nodejs
import OpenAI from "openai";
const openai = new OpenAI({
apiKey: process.env.DASHSCOPE_API_KEY,
baseURL: "https://dashscope-intl.aliyuncs.com/compatible-mode/v1"
});
async function main() {
const completion = await openai.chat.completions.create({
model: "qwen3-max",
messages: [
{ role: "user", content: "What is the stock price of Alibaba?" }
],
enable_search: true,
search_options: {
// Web search strategy, only supports 'agent'
search_strategy: "agent"
}
});
console.log(completion.choices[0].message.content);
}
main();Sample response
HELPCODEESCAPE-plaintext
According to the latest market data, Alibaba's stock price in different markets is as follows:
* **US Stock (BABA)**: The latest price is approximately **159.84 USD**.
* **Hong Kong Stock (09988.HK)**: The latest price is approximately **158.00 HKD**.
Note that stock prices fluctuate in real-time, and the information above is for reference only. According to the latest market data, Alibaba's stock price in different markets is as follows:
* **US Stock (BABA)**: The latest price is approximately **159.84 USD**.
* **Hong Kong Stock (09988.HK)**: The latest price is approximately **158.00 HKD**.
Note that stock prices fluctuate in real-time, and the information above is for reference only.curl
HELPCODEESCAPE-curl
curl -X POST https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3-max",
"messages": [
{
"role": "user",
"content": "What is the stock price of Alibaba?"
}
],
"enable_search": true,
"search_options": {
"search_strategy": "agent"
}
}'DashScope
The DashScope protocol supports
enable_sourcetotrueto return search sources in the response.
Python
HELPCODEESCAPE-python
import os
import dashscope
dashscope.base_http_api_url = "https://dashscope-intl.aliyuncs.com/api/v1"
response = dashscope.Generation.call(
api_key=os.getenv("DASHSCOPE_API_KEY"),
model="qwen3-max",
messages=[{"role": "user", "content": "Alibaba stock price"}],
enable_search=True,
search_options={
# Web search strategy, currently only supports the agent strategy: allows multiple calls to the web search tool and LLM for multi-round information retrieval and content integration
"search_strategy": "agent",
"enable_source": True # Whether to return search sources
},
result_format="message",
)
print("="*20 + "Search results" + "="*20)
for web in response.output.search_info["search_results"]:
print(f"[{web['index']}]: [{web['title']}]({web['url']})")
print("="*20 + "Response content" + "="*20)
print(response.output.choices[0].message.content)Sample response
HELPCODEESCAPE-plaintext
====================Search results====================
[1]: Alibaba (BABA) Stock Price_Quotes_Chart - East Money
[2]: Alibaba (BABA)_US Stock Quotes_Today's Price & Chart_Sina Finance
[3]: Alibaba (BABA) Stock Latest Price, Real-time Chart, Price Analysis and Prediction
[4]: Alibaba-W (9988.HK) Stock Price, News, Quote & History - Yahoo Finance
[5]: Alibaba (BABA) Stock Price_Quotes_Discussion - Xueqiu
[6]: Alibaba (BABA) Stock Price, Market Cap, Real-time Quotes, Chart, Financials - Moomoo
[7]: Alibaba Group Holding Limited (BABA) Stock Price, News, Quote ...
[8]: Alibaba - Tencent Securities
[9]: W(09988) Stock Price, Market Cap, Real-time Quotes, Chart, Financials - Alibaba - Moomoo
====================Response content====================
According to the latest market data, Alibaba's stock price information is as follows:
* **US Stock (BABA)**:
* Today's opening price: 160.98 USD
* Yesterday's closing price: 160.80 USD
* Today's high: 161.19 USD
* Today's low: 156.20 USD
* **Hong Kong Stock (09988.HK)**:
* Latest quote is approximately: 158.00 - 158.10 HKD
* Today's opening price: 156.50 HKD
* Previous trading day's closing price: 162.00 HKD
* Today's trading range: 156.30 - 158.40 HKDJava
HELPCODEESCAPE-java
import com.alibaba.dashscope.aigc.generation.Generation;
import com.alibaba.dashscope.aigc.generation.GenerationParam;
import com.alibaba.dashscope.aigc.generation.GenerationResult;
import com.alibaba.dashscope.aigc.generation.SearchOptions;
import com.alibaba.dashscope.common.Message;
import com.alibaba.dashscope.utils.Constants;
import com.alibaba.dashscope.common.Role;
import java.util.Arrays;
public class Main {
static {Constants.baseHttpApiUrl="https://dashscope-intl.aliyuncs.com/api/v1";}
public static void main(String[] args) {
Generation gen = new Generation();
Message userMsg = Message.builder()
.role(Role.USER.getValue())
.content("Alibaba's stock price")
.build();
SearchOptions searchOptions = SearchOptions.builder()
// Web search strategy, only supports 'agent'
.searchStrategy("agent")
// Return search sources
.enableSource(true)
.build();
GenerationParam param = GenerationParam.builder()
.apiKey(System.getenv("DASHSCOPE_API_KEY"))
.model("qwen3-max")
.messages(Arrays.asList(userMsg))
.resultFormat(GenerationParam.ResultFormat.MESSAGE)
.enableSearch(true)
.searchOptions(searchOptions)
.build();
try {
GenerationResult result = gen.call(param);
System.out.println("=".repeat(20)+"Search results"+"=".repeat(20));
System.out.println(result.getOutput().getSearchInfo().getSearchResults());
System.out.println("=".repeat(20)+"Response content"+"=".repeat(20));
System.out.println(result.getOutput().getChoices().get(0).getMessage().getContent());
} catch (Exception e) {
System.out.println("Error: " + e.getMessage());
}
}
}Sample response
HELPCODEESCAPE-plaintext
====================Search results====================
[SearchInfo.SearchResult(siteName=null, icon=null, index=1, title=Alibaba (BABA) Stock Price_Quotes_Chart - East Money, url=https://wap.eastmoney.com/quote/stock/106.BABA.html), SearchInfo.SearchResult(siteName=null, icon=null, index=2, title=Alibaba (BABA)_US Stock Quotes_Today's Price & Chart_Sina Finance, url=https://gu.sina.cn/quotes/us/BABA), SearchInfo.SearchResult(siteName=null, icon=null, index=3, title=Alibaba (BABA) Stock Latest Price, Real-time Chart, Price Analysis and Prediction, url=https://cn.investing.com/equities/alibaba), SearchInfo.SearchResult(siteName=null, icon=null, index=4, title=Alibaba (BABA) Stock Price_Quotes_Discussion - Xueqiu, url=https://xueqiu.com/S/BABA), SearchInfo.SearchResult(siteName=null, icon=null, index=5, title=Alibaba-W (9988.HK) Stock Price, News, Quote & History - Yahoo Finance, url=https://hk.finance.yahoo.com/quote/9988.HK/), SearchInfo.SearchResult(siteName=null, icon=null, index=6, title=Alibaba (BABA) Stock Price, Market Cap, Real-time Quotes, Chart, Financials - Moomoo, url=https://www.moomoo.com/hans/stock/BABA-US), SearchInfo.SearchResult(siteName=null, icon=null, index=7, title=Alibaba Group Holding Limited (BABA) - Yahoo Finance, url=https://finance.yahoo.com/quote/BABA/), SearchInfo.SearchResult(siteName=null, icon=null, index=8, title=Alibaba - Tencent Securities, url=https://gu.qq.com/usBABA.N), SearchInfo.SearchResult(siteName=null, icon=null, index=9, title=W(09988) Stock Price, Market Cap, Real-time Quotes, Chart, Financials - Alibaba - Moomoo, url=https://www.moomoo.com/hans/stock/09988-HK)]
====================Response content====================
According to the latest market data, Alibaba's stock price is as follows:
* **US Stock (BABA)**: The latest price is approximately **159.84 USD**.
* **Hong Kong Stock (09988.HK)**: The latest price is approximately **158.00 HKD**.
Note that stock prices fluctuate in real-time with market trading, and the information above is for reference only.curl
HELPCODEESCAPE-curl
curl -X POST https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/text-generation/generation \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3-max",
"input":{
"messages":[
{
"role": "user",
"content": "Alibaba's stock price"
}
]
},
"parameters": {
"enable_search": true,
"search_options": {
"search_strategy": "agent",
"enable_source": true
},
"result_format": "message"
}
}'Sample response
HELPCODEESCAPE-json
{
"output": {
"choices": [
{
"finish_reason": "stop",
"message": {
"content": "According to the latest market data, Alibaba's stock price varies because it is listed on both the US and Hong Kong stock exchanges:\n\n* **US Stock (BABA)**: The latest price is approximately **160.40 USD**.\n * Today's opening price: 160.98 USD\n * Today's trading range: 156.20 - 161.19 USD\n\n* **Hong Kong Stock (09988.HK)**: The latest price is approximately **158.10 HKD**.\n * Today's opening price: 156.50 HKD\n * Today's trading range: 156.30 - 158.40 HKD\n\nPlease note that stock prices change in real-time with market trading, and the above information is for reference only.",
"role": "assistant"
}
}
],
"search_info": {
"search_results": [
{
"index": 1,
"title": "Alibaba (BABA) Stock Price_Quotes_Chart - East Money",
"url": "https://wap.eastmoney.com/quote/stock/106.BABA.html"
},
{
"index": 2,
"title": "Alibaba (BABA)_US Stock Quotes_Today's Price & Chart_Sina Finance",
"url": "https://gu.sina.cn/quotes/us/BABA"
},
{
"index": 3,
"title": "Alibaba-W (9988.HK) Stock Price, News, Quote & History - Yahoo Finance",
"url": "https://hk.finance.yahoo.com/quote/9988.HK/"
},
{
"index": 4,
"title": "Alibaba (BABA) Stock Latest Price, Real-time Chart, Price Analysis and Prediction",
"url": "https://cn.investing.com/equities/alibaba"
},
{
"index": 5,
"title": "Alibaba (BABA) Stock Price_Quotes_Discussion - Xueqiu",
"url": "https://xueqiu.com/S/BABA"
},
{
"index": 6,
"title": "Alibaba (BABA) Stock Price, Market Cap, Real-time Quotes, Chart, Financials - Moomoo",
"url": "https://www.moomoo.com/hans/stock/BABA-US"
},
{
"index": 7,
"title": "W(09988) Stock Price, Market Cap, Real-time Quotes, Chart, Financials - Alibaba - Moomoo",
"url": "https://www.moomoo.com/hans/stock/09988-HK"
},
{
"index": 8,
"title": "Alibaba Group Holding Limited (BABA) Stock Price, News, Quote & History",
"url": "https://hk.finance.yahoo.com/quote/BABA/"
},
{
"index": 9,
"title": "Alibaba - Tencent Securities",
"url": "https://gu.qq.com/usBABA.N"
}
]
}
},
"usage": {
"input_tokens": 2004,
"output_tokens": 203,
"plugins": {
"search": {
"count": 1,
"strategy": "agent"
}
},
"prompt_tokens_details": {
"cached_tokens": 0
},
"total_tokens": 2207
},
"request_id": "45c231d2-811e-4e04-a361-f2c1909f1dd9"
}For Responses API
To enable web search with the tools parameter, the tools array must include the web_search tool.
This feature is supported only for qwen3.6-plus, qwen3.6-plus-2026-04-02, qwen3.5-plus, qwen3.5-plus-2026-02-15, qwen3.6-flash, qwen3.6-flash-2026-04-16, qwen3.5-flash, qwen3.5-flash-2026-02-23 , and for qwen3-max and qwen3-max-2026-01-23 in thinking mode. For best results, enable the
web_search,web_extractor, andcode_interpretertools at the same time. For usage instructions, code examples, and migration guides for the Responses API, see OpenAI-compatible - Responses . Python
HELPCODEESCAPE-python
from openai import OpenAI
import os
client = OpenAI(
# If the environment variable is not set, replace the following line with your Model Studio API key: api_key="sk-xxx",
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://dashscope-intl.aliyuncs.com/compatible-mode/v1"
)
response = client.responses.create(
model="qwen3-max-2026-01-23",
input="Singapore weather",
tools=[
{"type": "web_search"},
{"type": "web_extractor"},
{"type": "code_interpreter"}
],
extra_body={"enable_thinking": True}
)
print("="*20 + "Response Content" + "="*20)
print(response.output_text)
print("="*20 + "Tool Calling Count" + "="*20)
usage = response.usage
if hasattr(usage, 'x_tools') and usage.x_tools:
print(f"Web search count: {usage.x_tools.get('web_search', {}).get('count', 0)}")
# Uncomment the following lines to view the intermediate process output
# for r in response.output:
# print(r.model_dump_json())Node.js
HELPCODEESCAPE-nodejs
import OpenAI from "openai";
const openai = new OpenAI({
// If the environment variable is not set, replace the following line with your Model Studio API key: apiKey: "sk-xxx",
apiKey: process.env.DASHSCOPE_API_KEY,
baseURL: "https://dashscope-intl.aliyuncs.com/compatible-mode/v1"
});
async function main() {
const response = await openai.responses.create({
model: "qwen3-max-2026-01-23",
input: "Singapore weather",
tools: [
{ type: "web_search" },
{ type: "web_extractor" },
{ type: "code_interpreter" }
],
enable_thinking: true
});
console.log("====================Response Content====================");
console.log(response.output_text);
console.log("====================Tool Calling Count====================");
console.log(`Web search count: ${response.usage.x_tools.web_search?.count || 0}`);
// console.log(JSON.stringify(response.output[0], null, 2));
}
main();curl
HELPCODEESCAPE-curl
curl -X POST https://dashscope-intl.aliyuncs.com/compatible-mode/v1/responses \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3-max-2026-01-23",
"input": "Singapore weather",
"tools": [
{"type": "web_search"},
{"type": "web_extractor"},
{"type": "code_interpreter"}
],
"enable_thinking": true
}'Billing
Web search billing has two components:
Model call fees: Web search appends retrieved web content to the prompt, increasing input tokens. These tokens are billed at the standard model rate. See the Model Studio console for pricing. The Responses API bills web search at the agent policy rate.
Search policy fees:
agent policy:
The fee per 1,000 calls is as follows:
For the Chinese mainland and global deployment scopes: $0.573411.
For the international deployment scope: $10.00.
agent_max policy (Limited-time offer):
This policy includes fees for web search and web extractor.
Fee per 1,000 calls for the web search tool:
For the Chinese mainland deployment scope: $0.573411.
For the international deployment scope: $10.00.
The web extractor tool is free for a limited time.
Error messages
For error resolution, see Error messages.