Qwen with real-time web search using SerpApi SerpApi published a tutorial showing how to give locally run Qwen models real-time web search through tool calling, after a local Qwen model answered that the latest Next.js version was 15 when the actual release was 16.4.6 as of November 2026 and admitted it could not search the web. The setup runs Qwen through Ollama and routes searches through SerpApi, whose free plan includes 250 searches per month, with results returned in markdown format; the post notes Qwen-Agent ships built-in web_search and web_extractor tools while Qwen Code requires an MCP server such as SerpApi MCP. The tutorial lists memory requirements of 6 GB for qwen3.5:4b, 8 GB for qwen3.5:9b, and 24 GB for both qwen3.8:27b and qwen3-coder:30b. I asked a Qwen model, running locally, for the latest version of Next.js. It answered 15. The latest release was 16.4.6 as of November 2026 . When I asked how it determined this answer, it admitted that it can't search the web and answers from its training data. A local model is limited to its training data. This post shows how Qwen can use web search, with multiple search engines such as Google, Baidu and Naver, and compares the performance of different models. Does Qwen have web search? Qwen offers open-weight local models, Qwen Code and the Qwen-Agent framework. All of them can be given access to web search. Qwen local model Open-weight models such as qwen3.8:27b , qwen3.5:9b or qwen3-coder running on your own device through Ollama, vLLM or LM Studio. - Built-in search : Not available. The model can request search through a tool call, but it can't run one on its own. - Add web search : Through tool calling in your application, or by connecting an MCP server https://serpapi.com/integrations/mcp through an MCP-capable client. Qwen Code A terminal coding agent that works with Qwen models and other providers through compatible APIs, including local models served through Ollama. - Built-in search : Not available for local models or third-party providers such as OpenRouter and DeepSeek. - Add web search : Through MCP servers such as SerpApi MCP https://serpapi.com/integrations/mcp . Qwen-Agent A framework for building LLM applications and agents using Qwen models, with built-in support for function calling, MCP, a code interpreter and RAG. - Built-in search : Yes. web search and web extractor tools are present. - Add web search : Add a custom tool or connect an MCP server https://serpapi.com/integrations/mcp . This post covers the Qwen local model with tool calling. I'll cover connecting Qwen Code and Qwen-Agent with SerpApi's MCP server https://serpapi.com/integrations/mcp in a follow-up post. How do Qwen and SerpApi work together? Local models can use tools to perform actions not natively available to them. We can provide web search as a tool to our Qwen model, and the model uses it when necessary to answer a question. Below is a flow diagram of how this works. Suppose we ask the model about the latest PHP critical vulnerability. Below is the sequence of actions performed. 1. Our question, along with the prompt and the available tools, is sent to Qwen. 2. Qwen understands that the latest vulnerabilities won't be in its training data, so it requests a web search. 3. A real-time web search is performed through SerpApi, and the results are returned in token-efficient markdown format https://serpapi.com/blog/introducing-serpapi-markdown-output/ . 4. Qwen checks whether the search results are enough to answer the question. If not, it requests another search. 5. Once Qwen has enough information, it answers the question. How to set this up? Let's begin with what's required to build this. - Ollama to run Qwen locally on your machine. vLLM and LM Studio should also work. Only base url in the sample code changes. - Qwen model with tool support that fits your machine see Step 1 step-1-pick-a-qwen-model-and-start-ollama . - SerpApi API key : Get it here https://serpapi.com/manage-api-key . Free plan includes 250 searches per month. Note: The commands below are for macOS and Linux. Step 1: Pick a Qwen model and start Ollama Choose a model based on the available memory on your device. A model needs memory for its weights download size plus additional memory for the context conversation and search results . | Model | Download size | Memory needed | |---|---|---| | qwen3.5:4b | 3.4 GB | 6 GB | | qwen3.5:9b | 6.6 GB | 8 GB | | qwen3.8:27b | 18 GB | 24 GB | | qwen3-coder:30b | 19 GB | 24 GB | Any Qwen model with the tools tag on Ollama https://ollama.com/search?c=tools&q=qwen works. Download your pick using the command below. For example, for qwen3.8:27b : To keep memory in check, start Ollama with a 32k context and an 8-bit KV cache. This allows Qwen to perform several rounds of searches. Keep this terminal tab open. Step 2: Set up Python environment In a new terminal, create a project, install three packages and add your API key. mkdir qwen-search && cd qwen-search python3 -m venv .venv && source .venv/bin/activate pip install openai serpapi python-dotenv echo "SERPAPI API KEY=your api key" .env Replace your api key with the key from your SerpApi dashboard https://serpapi.com/manage-api-key . Step 3: Add the code Create qwen search.py in the same folder and paste the code below. The script uses qwen3.8:27b by default. If you pulled a different model in Step 1, add LOCAL MODEL=