ओलामा का वेब खोज API मॉडल को नवीनतम जानकारी से संवर्धित करने, हल्यूसिनेशन को कम करने और शुद्धता बढ़ाने के लिए उपयोग किया जा सकता है।
वेब खोज को REST API के रूप में प्रदान किया गया है, जिसमें पायथन और जावास्क्रिप्ट लाइब्रेरी में गहरे टूल इंटीग्रेशन भी शामिल हैं। यह OpenAI के gpt-oss जैसे मॉडलों को लंबे समय तक चलने वाले शोध कार्य करने में भी सक्षम बनाता है।
प्रमाणीकरण
ओलामा के वेब खोज API तक पहुंचने के लिए, एक API कुंजी बनाएं। इसके लिए एक मुफ्त ओलामा खाता आवश्यक है।
वेब खोज API
यह एकल क्वेरी के लिए वेब खोज करता है और प्रासंगिक परिणाम लौटाता है।
अनुरोध
POST https://ollama.com/api/web_search
query(string, आवश्यक): खोज क्वेरी स्ट्रिंगmax_results(integer, वैकल्पिक): लौटाए जाने वाले अधिकतम परिणाम (डिफॉल्ट 5, अधिकतम 10)
प्रतिक्रिया
यह निम्नलिखित वस्तुओं वाला ऑब्जेक्ट लौटाता है:
results(array): खोज परिणाम वस्तुओं की सरणी, जिसमें प्रत्येक में निम्नलिखित शामिल है:title(string): वेब पेज का शीर्षकurl(string): वेब पेज का URLcontent(string): वेब पेज से प्रासंगिक सामग्री का स्निपेट
उदाहरण
नोट
सुनिश्चित करें कि 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
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..."
}
]और अधिक ओलामा पायथन उदाहरण
जावास्क्रिप्ट लाइब्रेरी
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..."
}
]
}और अधिक ओलामा जावास्क्रिप्ट उदाहरण
वेब फ़ेच API
यह URL द्वारा एकल वेब पेज को फ़ेच करता है और उसकी सामग्री लौटाता है।
अनुरोध
POST https://ollama.com/api/web_fetch
url(string, आवश्यक): फ़ेच करने के लिए URL
प्रतिक्रिया
यह निम्नलिखित वस्तुओं वाला ऑब्जेक्ट लौटाता है:
title(string): वेब पेज का शीर्षकcontent(string): वेब पेज की मुख्य सामग्रीlinks(array): पेज पर मिलने वाले लिंक की सरणी
उदाहरण
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"
]पायथन 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']
)जावास्क्रिप्ट 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"
]
}सर्च एजेंट बनाना
ओलामा के वेब खोज API का उपयोग एक मिनी सर्च एजेंट बनाने के लिए टूल के रूप में करें।
यह उदाहरण 4B पैरामीटर वाले अलीबाबा के 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]+'...')
# Result is truncated for limited context lengths
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 टोकन तक बढ़ाने की सलाह दी जाती है। सर्च एजेंट पूरी संदर्भ लंबाई के साथ सबसे अच्छा काम करते हैं। ओलामा के क्लाउड मॉडल पूरी संदर्भ लंबाई पर चलते हैं।
MCP सर्वर
आप किसी भी MCP क्लाइंट में पायथन MCP सर्वर के माध्यम से वेब खोज सक्षम कर सकते हैं।
Cline
ओलामा का वेब खोज MCP सर्वर कॉन्फ़िगरेशन का उपयोग करके Cline के साथ आसानी से इंटीग्रेट किया जा सकता है।
Manage MCP Servers > Configure MCP Servers > निम्नलिखित कॉन्फ़िगरेशन जोड़ें:
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
ओलामा 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
ओलामा अपने MCP फीचर के माध्यम से Goose के साथ इंटीग्रेट हो सकता है।


अन्य इंटीग्रेशन
ओलामा को उपलब्ध अधिकांश टूलों में ओलामा के API का सीधा इंटीग्रेशन, पायथन / जावास्क्रिप्ट लाइब्रेरी, OpenAI संगत API और MCP सर्वर इंटीग्रेशन के माध्यम से इंटीग्रेट किया जा सकता है।