Skip to main content
Tool calling

Web search

Ground model responses in real-time web data

Web search lets a model query the internet before responding, so answers can include up-to-date facts such as stock prices, weather, or recent news. Enable it by adding a single parameter to any text-generation call. Get an API key and set it as an environment variable.
  • OpenAI compatible
  • Responses API
  • DashScope
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)

Supported models

Web search supports two search strategies: agent (standard search) and agent_max (search + full-page reading).
Model familyThinking modeNon-thinking modeNotes
Qwen3.6 Plus (qwen3.6-plus and later snapshots)agent, agent_maxagent, agent_max
Qwen3.5 Plus (qwen3.5-plus and later snapshots)agent, agent_maxagent, agent_max
Qwen3.5 Flash (qwen3.5-flash and later snapshots)agent, agent_maxagent, agent_max
Qwen3 Max (qwen3-max, qwen3-max-2026-01-23)agent, agent_maxagentagent_max requires thinking mode
Qwen3 Max (qwen3-max-2025-09-23)agentagentagent only

Search strategies

Control how aggressively the model searches via the search_strategy field inside search_options:
  • agent -- The model decides when and how often to search. Suitable for most queries. One search call is billed per invocation.
  • agent_max -- The model may search multiple times and, when supported, use the web extractor tool to read full pages. Best for research-heavy prompts that need deep or cross-referenced information. Requires thinking mode on Qwen3 Max.
If you omit search_strategy, the default is agent.

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]").

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):
    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.
Web search | Qwen Cloud