web_search)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.
web_search takes two arguments:
query (string, required): The search queryprovider (string, optional): Specific provider to use (“dashscope”, “tavily”, “google”)
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:
default to 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 Ollama 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 tavily
⚠️ DEPRECATED: The legacy tavilyApiKey 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 Ollama 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")
provider parameterdefault configuration (highest priority)--web-search-defaultTool not available?
Provider-specific errors?
provider parameter to try a different search providerNeed help?
qwen and use the settings dialog~/.ollama-code/settings.json (macOS/Linux) or %USERPROFILE%\.ollama-code\settings.json (Windows)