This document describes the web_search tool for performing web searches using multiple providers.
Use web_search to perform a web search and get information from the internet. The tool supports multiple search providers and returns a concise answer with source citations when available.
- DashScope (Official) - Available when explicitly configured in settings (Qwen OAuth free tier auto-injection discontinued 2026-04-15)
- Tavily - High-quality search API with built-in answer generation
- Google Custom Search - Google's Custom Search JSON API
web_search takes two arguments:
query(string, required): The search queryprovider(string, optional): Specific provider to use ("dashscope", "tavily", "google")- If not specified, uses the default provider from configuration
Add to your settings.json:
{
"webSearch": {
"provider": [
{ "type": "dashscope" },
{ "type": "tavily", "apiKey": "tvly-xxxxx" },
{
"type": "google",
"apiKey": "your-google-api-key",
"searchEngineId": "your-search-engine-id"
}
],
"default": "dashscope"
}
}Notes:
- DashScope doesn't require an API key (official, free service)
- Qwen OAuth users: DashScope is automatically added to your provider list, even if not explicitly configured
- Configure additional providers (Tavily, Google) if you want to use them alongside DashScope
- Set
defaultto specify which provider to use by default (if not set, priority order: Tavily > Google > DashScope)
Set environment variables in your shell or .env file:
# Tavily
export TAVILY_API_KEY="tvly-xxxxx"
# Google
export GOOGLE_API_KEY="your-api-key"
export GOOGLE_SEARCH_ENGINE_ID="your-engine-id"Pass API keys when running Qwen Code:
# Tavily
qwen --tavily-api-key tvly-xxxxx
# Google
qwen --google-api-key your-key --google-search-engine-id your-id
# Specify default provider
qwen --web-search-default tavilytavilyApiKey configuration is still supported for backward compatibility but is deprecated:
{
"advanced": {
"tavilyApiKey": "tvly-xxxxx" // ⚠️ Deprecated
}
}Important: This configuration is deprecated and will be removed in a future version. Please migrate to the new webSearch configuration format shown above. The old configuration will automatically configure Tavily as a provider, but we strongly recommend updating your configuration.
If you want to disable the web search functionality, you can exclude the web_search tool in your settings.json:
{
"tools": {
"exclude": ["web_search"]
}
}Note: This setting requires a restart of Qwen Code to take effect. Once disabled, the web_search tool will not be available to the model, even if web search providers are configured.
web_search(query="latest advancements in AI")
web_search(query="latest advancements in AI", provider="tavily")
web_search(query="weather in San Francisco today")
web_search(query="latest Node.js LTS version", provider="google")
web_search(query="best practices for React 19", provider="dashscope")
- Cost: Free (requires Qwen OAuth credentials)
- Authentication: Requires Qwen OAuth credentials
- Configuration: Must be explicitly configured in
settings.jsonweb search providers (auto-injection for Qwen OAuth users was removed when the free tier was discontinued on 2026-04-15) - Quota: 200 requests/minute, 100 requests/day
- Best for: General queries when you have Qwen OAuth credentials
- Cost: Requires API key (paid service with free tier)
- Sign up: https://tavily.com
- Features: High-quality results with AI-generated answers
- Best for: Research, comprehensive answers with citations
- Cost: Free tier available (100 queries/day)
- Setup:
- Enable Custom Search API in Google Cloud Console
- Create a Custom Search Engine at https://programmablesearchengine.google.com
- Features: Google's search quality
- Best for: Specific, factual queries
- Response format: Returns a concise answer with numbered source citations
- Citations: Source links are appended as a numbered list: [1], [2], etc.
- Multiple providers: If one provider fails, manually specify another using the
providerparameter - DashScope availability: Automatically available for Qwen OAuth users, no configuration needed
- Default provider selection: The system automatically selects a default provider based on availability:
- Your explicit
defaultconfiguration (highest priority) - CLI argument
--web-search-default - First available provider by priority: Tavily > Google > DashScope
- Your explicit
Tool not available?
- For Qwen OAuth users: The tool is automatically registered with DashScope provider, no configuration needed
- For other authentication types: Ensure at least one provider (Tavily or Google) is configured
- For Tavily/Google: Verify your API keys are correct
Provider-specific errors?
- Use the
providerparameter to try a different search provider - Check your API quotas and rate limits
- Verify API keys are properly set in configuration
Need help?
- Check your configuration: Run
qwenand use the settings dialog - View your current settings in
~/.qwen-code/settings.json(macOS/Linux) or%USERPROFILE%\.qwen-code\settings.json(Windows)