Ollama 推出 Web Search API 与网页抓取接口
Web search · Ollama Blog
Ollama 上线新的 Web Search API,个人用户可使用免费额度,更高速率限制通过 Ollama 云提供。该能力以 REST API 形式提供,并在 Ollama 的 Python 和 JavaScript 库中做了更深的工具集成,可让 gpt-oss 等模型执行长时间研究任务。官方建议将模型上下文长度提高到约 32000 tokens,并推荐 qwen3、gpt-oss 等模型;同时新增 web fetch API 用于抓取单个页面,可通过 Python MCP server 在 Cline、Codex、Goose 等 MCP 客户端中启用。
推荐理由
精选AI 评分 60
Ollama 把联网搜索做成 REST API 并接入 Python、JavaScript 库与 MCP 客户端,读者可据此判断自建搜索智能体的接入成本。
主题
正文
当前显示原文,中文全文译文尚未就绪。
September 24, 2025
A new web search API is now available in Ollama. Ollama provides a generous free tier of web searches for individuals to use, and higher rate limits are available via Ollama’s cloud.
This web search capability can augment models with the latest information from the web to reduce hallucinations and improve accuracy.
Web search is provided as a REST API with deeper tool integrations in Ollama’s Python and JavaScript libraries. This also enables models such as OpenAI’s gpt-oss models to conduct long-running research tasks.
Create an API key from your Ollama account.
Install and run Ollama’s Python library
Then make a request using ollama.web_search:
Example output
JavaScript
Install and run Ollama’s JavaScript library
Example output
Building a search agent
Use Ollama’s web search as a tool to build a mini search agent.
The example uses Alibaba’s Qwen 3 model with 4B parameters.
Result
Recommended models:
These models have great tool-use capabilities and are able to have multi-turn interactions with the user and tools to get to a final result.
qwen3; gpt-oss
Recommended cloud models:
qwen3:480b-cloud; gpt-oss:120b-cloud; deepseek-v3.1-cloud
The web_search and web_fetch tools can return thousands of tokens. It is recommended to increase the context length of the model to ~32000 tokens for reasonable performance. Search agents work best with full context length.
Fetching page results
To fetch individual pages (e.g. when a user provides a url in the prompt), use the new web fetch API.
Python library
Result
Example Python code is available on GitHub.
JavaScript library
Result
Example JavaScript code is available on GitHub.
You can enable web search in any MCP client through the Python MCP server.
Cline
To integrate with Cline, configure MCP servers in its settings.
Codex
Add the following configuration to ~/.codex/config.toml
Goose
You can integrate with Ollama via Goose’s extensions.
Web search is included with a free Ollama account, with much higher rate limits available by upgrading your Ollama subscription.