Skip to main content
Tool calling

Web search

Ground model responses in real-time web data

The training data for large language models has a knowledge cutoff date, preventing them from answering real-time questions. Enabling web search lets a model retrieve real-time data from the internet and accurately answer time-sensitive questions, such as stock prices, weather forecasts, and breaking news. Get an API key and set it as an environment variable.
  • OpenAI compatible
  • Responses API
  • DashScope
  • Anthropic-compatible
Set enable_search: true and optionally pass search_options to choose a strategy.
The OpenAI compatible Chat Completions endpoint does not return search sources. Use the Responses API or DashScope if you need citations.
import os
from openai import OpenAI

client = OpenAI(
  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": "How is Alibaba's stock price?"},
  ],
  extra_body={
    "enable_search": True,
    "search_options": {
      "search_strategy": "agent"
    }
  }
)
print(completion.choices[0].message.content)

Web search with multimodal models

The Qwen3.8 series, Qwen3.7-Flash, Qwen3.7-Plus, the Qwen3.6 series, and the Qwen3.5 series (including qwen3.5-plus, qwen3.5-flash, the qwen3.5-omni series, and Qwen open-source models) accept multimodal input (images, video) and are multimodal models. Search strategy support varies by series: the qwen3.5-omni series supports only the agent strategy; the Qwen3.8 series does not support the agent strategy (use the default turbo or max); other models support the turbo, max, and agent strategies. Call these models through the multimodal API (the multimodal-generation endpoint): use MultiModalConversation in both Python and Java, not Generation (the text-generation endpoint), which is for text-only models. For the basics of calling multimodal models, see the Visual reasoning and Image and video understanding topics.
  • Calling the multimodal models above with Generation (the text-generation endpoint) returns 400 url error, please check url. Use MultiModalConversation (the multimodal-generation endpoint) instead.
  • In the Java SDK, MultiModalConversationParam provides enableSearch(true) to enable web search, but does not provide a searchOptions() method. Inject the search strategy and other options through the generic parameter("search_options", ...) method. In Python, MultiModalConversation.call accepts search_options directly.
  • Web search on multimodal models requires streaming calls (use streamCall in Java, or set stream=True in Python); otherwise the request returns a Non-streaming mode does not support Web Search error.
import os
import dashscope
from dashscope import MultiModalConversation
dashscope.base_http_api_url = "https://dashscope-intl.aliyuncs.com/api/v1"
responses = MultiModalConversation.call(
  api_key=os.getenv("DASHSCOPE_API_KEY"),
  model="qwen3.5-plus",
  messages=[{"role": "user", "content": [{"text": "What is the weather in Hangzhou today?"}]}],
  enable_search=True,
  search_options={
    # The qwen3.5-omni series requires agent. The Qwen3.8 series does not support agent; keep the default.
    "search_strategy": "agent",
    "enable_source": True,
  },
  stream=True,
  incremental_output=True,
)
for response in responses:
  print(response.output.choices[0].message.content)

Supported models

The following models support web search. Models with multimodal input (the Qwen3.8 series, Qwen3.7-Flash/Plus, the Qwen3.6 series, the Qwen3.5 series, and Qwen open-source models) must be called through the multimodal API. See Web search with multimodal models. Qwen
Model seriesAvailable models
Qwen3.8 seriesqwen3.8-max, qwen3.8-max-0902, qwen3.8-flash, qwen3.8-2.4t-a95b, qwen3.8-27b (the agent strategy is not supported)
Qwen3.7 seriesqwen3.7-max, qwen3.7-max-preview, qwen3.7-max-2026-05-17 and later snapshots, qwen3.7-plus, qwen3.7-plus-2026-05-26 and later snapshots, qwen3.7-flash, qwen3.7-flash-2026-07-15 and later snapshots
Qwen3.6 seriesqwen3.6-max-preview, qwen3.6-plus, qwen3.6-plus-2026-04-02 and later snapshots, qwen3.6-flash, qwen3.6-flash-2026-04-16 and later snapshots, qwen3.6-27b, qwen3.6-35b-a3b
Qwen3.5 seriesqwen3.5-plus, qwen3.5-plus-2026-02-15 and later snapshots, qwen3.5-flash, qwen3.5-flash-2026-02-23 and later snapshots, qwen3.5-27b, qwen3.5-35b-a3b, qwen3.5-122b-a10b, qwen3.5-397b-a17b
Qwen3-Maxqwen3-max, qwen3-max-2025-09-23 and later snapshots
Qwen-Maxqwen-max and later snapshots
Qwen-Plusqwen-plus, qwen-plus-latest, qwen-plus-2025-07-14 and later snapshots
Qwen-Flashqwen-flash, qwen-flash-2025-07-28 and later snapshots
Qwen-Turboqwen-turbo
QwQqwq-plus (supports only the default search strategy; search_strategy cannot be set)
Qwen-Omniqwen3.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-Realtimeqwen3.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-playingqwen-plus-character, qwen-flash-character (the agent strategy is not supported)
Qwen-Max, Qwen-Plus, and Qwen-Flash models released after July 2025 automatically support web search. Third-party models
ProviderAvailable models
DeepSeekdeepseek-v4-pro, deepseek-v4-pro-0813, deepseek-v4-flash, deepseek-v4-flash-0731, deepseek-v3.2 (the deepseek-v4 series also supports the Responses API)
GLMglm-5.2 (supported only by the Responses API)
Kimikimi-k3 (supported only by the Responses API)

Search strategies

Use the search_strategy field in search_options to balance cost, quality, and response speed:
  • turbo (default) -- Balances response speed and search quality. Suitable for most scenarios.
  • max -- Uses a more comprehensive search strategy and may call multiple search engines for more thorough results, but the response time may be longer.
  • agent -- Calls the web search tool and the model multiple times for multi-round information retrieval and integration. Suitable for complex queries and English scenarios. Applies to the Qwen3-Max series (qwen3-max, qwen3-max-2025-09-23 and later snapshots), the Qwen3.5 series (including open-source models and the Omni series), the Qwen3.6 series, and the Qwen3.7 series. Streaming calls are required when calling through the text endpoint. The Qwen3.8 series does not support the agent strategy. When enabled, only enable_source: true (returning search sources) is supported; other web search features are unavailable. Each invocation is billed additionally, see Billing.
  • agent_max -- Supports reading full web pages with the web extractor tool on top of the agent strategy. Only available on qwen3-max and qwen3-max-2026-01-23 in thinking mode. When enabled, only enable_source: true is supported; other web search features are unavailable. Each invocation is billed additionally, see Billing.
Use the default turbo strategy for everyday queries. For research or report generation that requires high accuracy and multi-source cross-validation, choose max or agent. agent is recommended for English scenarios.

Read search results

When you set enable_source: true (DashScope only), the response includes a search_info.search_results array. Each entry contains:
FieldDescription
indexCitation number referenced in the response text
titlePage title of the source
urlURL of the source
Use these fields to render inline citations or a references list in your application. The model's response text may reference sources by index (e.g., "according to source [1]").

Get search sources

After a web search runs, the search sources are returned in the response. They appear in the element whose type is web_search_call within the output array, and its action.sources field is the list of source links. You can extract them from the response in the example above as follows:
The Responses API does not support the enable_source, enable_citation, or citation_format parameters, and does not insert [1] citation markers into the response content. To use citation markers, use the DashScope API.
# Extract search sources from the response above
print("=" * 20 + "Search sources" + "=" * 20)
for item in response.output:
    if item.type == "web_search_call":
        for i, source in enumerate(item.action.sources, start=1):
            print(f"[{i}] {source.url}")

Billing

Billing involves two aspects:
  • Model call fees: The web content from the web search is added to the prompt, which increases the number of input tokens for the model. You are charged based on the standard pricing of the model. For more information about pricing, see Pricing.
  • Search call fees (per 1,000 calls):
    When using the Responses API, the web search tool is billed at the same rate as the agent strategy.
    The prices listed below are list prices. For current promotions and discounted pricing, visit the Model Marketplace.
    Strategy (search_strategy)What it doesFee
    agent (default)Model searches the web as needed$10.00
    agent_maxSearches + reads full pages via web extractor$10.00 for search; web extractor is free for a limited time

Error codes

If a call fails, see Error messages.