Ollama의 웹 검색 API는 최신 정보로 모델을 강화하여 환각을 줄이고 정확도를 높이는 데 사용할 수 있습니다.
웹 검색은 REST API로 제공되며, Python 및 JavaScript 라이브러리에서 더 깊은 도구 통합을 지원합니다. 이를 통해 OpenAI의 gpt-oss 모델과 같은 모델이 장기 실행 연구 작업을 수행할 수 있습니다.
인증
Ollama의 웹 검색 API에 접근하려면 API 키를 생성하세요. 무료 Ollama 계정이 필요합니다.
웹 검색 API
단일 쿼리에 대한 웹 검색을 수행하고 관련 결과를 반환합니다.
요청
POST https://ollama.com/api/web_search
query(문자열, 필수): 검색 쿼리 문자열max_results(정수, 선택): 반환할 최대 결과 수 (기본값 5, 최대 10)
응답
다음을 포함하는 객체를 반환합니다:
results(배열): 검색 결과 객체 배열로, 각 객체는 다음을 포함합니다:title(문자열): 웹 페이지의 제목url(문자열): 웹 페이지의 URLcontent(문자열): 웹 페이지의 관련 콘텐츠 스니펫
예시
Note
OLLAMA_API_KEY가 설정되어 있지 않으면 Authorization 헤더에 전달해야 합니다.
cURL 요청
bash
curl https://ollama.com/api/web_search \
--header "Authorization: Bearer $OLLAMA_API_KEY" \
-d '{
"query":"what is ollama?"
}'응답
json
{
"results": [
{
"title": "Ollama",
"url": "https://ollama.com/",
"content": "Cloud models are now available..."
},
{
"title": "What is Ollama? Introduction to the AI model management tool",
"url": "https://www.hostinger.com/tutorials/what-is-ollama",
"content": "Ariffud M. 6min Read..."
},
{
"title": "Ollama Explained: Transforming AI Accessibility and Language ...",
"url": "https://www.geeksforgeeks.org/artificial-intelligence/ollama-explained-transforming-ai-accessibility-and-language-processing/",
"content": "Data Science Data Science Projects Data Analysis..."
}
]
}Python 라이브러리
python
response = ollama.web_search("What is Ollama?")
print(response)예제 출력
python
results = [
{
"title": "Ollama",
"url": "https://ollama.com/",
"content": "Cloud models are now available in Ollama..."
},
{
"title": "What is Ollama? Features, Pricing, and Use Cases - Walturn",
"url": "https://www.walturn.com/insights/what-is-ollama-features-pricing-and-use-cases",
"content": "Our services..."
},
{
"title": "Complete Ollama Guide: Installation, Usage & Code Examples",
"url": "https://collabnix.com/complete-ollama-guide-installation-usage-code-examples",
"content": "Join our Discord Server..."
}
]더 많은 Ollama Python 예제
JavaScript 라이브러리
tsx
const client = new Ollama();
const results = await client.webSearch("what is ollama?");
console.log(JSON.stringify(results, null, 2));예제 출력
json
{
"results": [
{
"title": "Ollama",
"url": "https://ollama.com/",
"content": "Cloud models are now available..."
},
{
"title": "What is Ollama? Introduction to the AI model management tool",
"url": "https://www.hostinger.com/tutorials/what-is-ollama",
"content": "Ollama is an open-source tool..."
},
{
"title": "Ollama Explained: Transforming AI Accessibility and Language Processing",
"url": "https://www.geeksforgeeks.org/artificial-intelligence/ollama-explained-transforming-ai-accessibility-and-language-processing/",
"content": "Ollama is a groundbreaking..."
}
]
}더 많은 Ollama JavaScript 예제
웹 가져오기 API
URL로 단일 웹 페이지를 가져와서 콘텐츠를 반환합니다.
요청
POST https://ollama.com/api/web_fetch
url(문자열, 필수): 가져올 URL
응답
다음을 포함하는 객체를 반환합니다:
title(문자열): 웹 페이지의 제목content(문자열): 웹 페이지의 주요 콘텐츠links(배열): 페이지에서 찾은 링크 배열
예시
cURL 요청
python
curl --request POST \
--url https://ollama.com/api/web_fetch \
--header "Authorization: Bearer $OLLAMA_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"url": "ollama.com"
}'응답
json
{
"title": "Ollama",
"content": "[Cloud models](https://ollama.com/blog/cloud-models) are now available in Ollama...",
"links": [
"http://ollama.com/",
"http://ollama.com/models",
"https://github.com/ollama/ollama"
]Python SDK
python
from ollama import web_fetch
result = web_fetch('https://ollama.com')
print(result)결과
python
WebFetchResponse(
title='Ollama',
content='[Cloud models](https://ollama.com/blog/cloud-models) are now available in Ollama\n\n**Chat & build
with open models**\n\n[Download](https://ollama.com/download) [Explore
models](https://ollama.com/models)\n\nAvailable for macOS, Windows, and Linux',
links=['https://ollama.com/', 'https://ollama.com/models', 'https://github.com/ollama/ollama']
)JavaScript SDK
tsx
const client = new Ollama();
const fetchResult = await client.webFetch("https://ollama.com");
console.log(JSON.stringify(fetchResult, null, 2));결과
json
{
"title": "Ollama",
"content": "[Cloud models](https://ollama.com/blog/cloud-models) are now available in Ollama...",
"links": [
"https://ollama.com/",
"https://ollama.com/models",
"https://github.com/ollama/ollama"
]
}검색 에이전트 구축
Ollama의 웹 검색 API를 도구로 사용하여 미니 검색 에이전트를 구축하세요.
이 예제는 4B 매개변수를 가진 Alibaba의 Qwen 3 모델을 사용합니다.
bash
ollama pull qwen3:4bpython
from ollama import chat, web_fetch, web_search
available_tools = {'web_search': web_search, 'web_fetch': web_fetch}
messages = [{'role': 'user', 'content': "what is ollama's new engine"}]
while True:
response = chat(
model='qwen3:4b',
messages=messages,
tools=[web_search, web_fetch],
think=True
)
if response.message.thinking:
print('Thinking: ', response.message.thinking)
if response.message.content:
print('Content: ', response.message.content)
messages.append(response.message)
if response.message.tool_calls:
print('Tool calls: ', response.message.tool_calls)
for tool_call in response.message.tool_calls:
function_to_call = available_tools.get(tool_call.function.name)
if function_to_call:
args = tool_call.function.arguments
result = function_to_call(**args)
print('Result: ', str(result)[:200]+'...')
# 결과는 제한된 컨텍스트 길이로 인해 잘렸습니다.
messages.append({'role': 'tool', 'content': str(result)[:2000 * 4], 'tool_name': tool_call.function.name})
else:
messages.append({'role': 'tool', 'content': f'Tool {tool_call.function.name} not found', 'tool_name': tool_call.function.name})
else:
break결과
Thinking: Okay, the user is asking about Ollama's new engine. I need to figure out what they're referring to. Ollama is a company that develops large language models, so maybe they've released a new model or an updated version of their existing engine....
Tool calls: [ToolCall(function=Function(name='web_search', arguments={'max_results': 3, 'query': 'Ollama new engine'}))]
Result: results=[WebSearchResult(content='# New model scheduling\n\n## September 23, 2025\n\nOllama now includes a significantly improved model scheduling system. Ahead of running a model, Ollama’s new engine
Thinking: Okay, the user asked about Ollama's new engine. Let me look at the search results.
First result is from September 23, 2025, talking about new model scheduling. It mentions improved memory management, reduced crashes, better GPU utilization, and multi-GPU performance. Examples show speed improvements and accurate memory reporting. Supported models include gemma3, llama4, qwen3, etc...
Content: Ollama has introduced two key updates to its engine, both released in 2025:
1. **Enhanced Model Scheduling (September 23, 2025)**
- **Precision Memory Management**: Exact memory allocation reduces out-of-memory crashes and optimizes GPU utilization.
- **Performance Gains**: Examples show significant speed improvements (e.g., 85.54 tokens/s vs 52.02 tokens/s) and full GPU layer utilization.
- **Multi-GPU Support**: Improved efficiency across multiple GPUs, with accurate memory reporting via tools like `nvidia-smi`.
- **Supported Models**: Includes `gemma3`, `llama4`, `qwen3`, `mistral-small3.2`, and more.
2. **Multimodal Engine (May 15, 2025)**
- **Vision Support**: First-class support for vision models, including `llama4:scout` (109B parameters), `gemma3`, `qwen2.5vl`, and `mistral-small3.1`.
- **Multimodal Tasks**: Examples include identifying animals in multiple images, answering location-based questions from videos, and document scanning.
These updates highlight Ollama's focus on efficiency, performance, and expanded capabilities for both text and vision tasks.컨텍스트 길이와 에이전트
웹 검색 결과는 수천 개의 토큰을 반환할 수 있습니다. 모델의 컨텍스트 길이를 최소 ~32000 토큰 이상으로 늘리는 것이 권장됩니다. 검색 에이전트는 전체 컨텍스트 길이에서 가장 잘 작동합니다. Ollama의 클라우드 모델은 전체 컨텍스트 길이에서 실행됩니다.
MCP 서버
Python MCP 서버를 통해 모든 MCP 클라이언트에서 웹 검색을 활성화할 수 있습니다.
Cline
Ollama의 웹 검색은 MCP 서버 구성을 사용하여 Cline과 쉽게 통합할 수 있습니다.
MCP 서버 관리 > MCP 서버 구성 > 다음 구성을 추가하세요:
json
{
"mcpServers": {
"web_search_and_fetch": {
"type": "stdio",
"command": "uv",
"args": ["run", "path/to/web-search-mcp.py"],
"env": { "OLLAMA_API_KEY": "your_api_key_here" }
}
}
}
Codex
Ollama는 OpenAI의 Codex 도구와 잘 호환됩니다.
~/.codex/config.toml에 다음 구성을 추가하세요
python
[mcp_servers.web_search]
command = "uv"
args = ["run", "path/to/web-search-mcp.py"]
env = { "OLLAMA_API_KEY" = "your_api_key_here" }
Goose
Ollama는 MCP 기능을 통해 Goose와 통합할 수 있습니다.


기타 통합
Ollama는 Ollama API, Python/JavaScript 라이브러리, OpenAI 호환 API 및 MCP 서버 통합을 통한 직접 통합으로 대부분의 사용 가능한 도구와 통합할 수 있습니다.