वेब सर्च कैसे चालू करें: OpenAI, Gemini और Claude API

तीनों API में वेब सर्च tools array में सिर्फ़ एक entry जोड़कर चालू होता है: OpenAI में web_search, Gemini में google_search, और Claude में web_search_20250305 या उससे नया वर्ज़न। यहाँ हर एक का सटीक कोड है, हर 1,000 सर्च का खर्च, domains और models से जुड़ी सीमाएँ, और यह भी कि कब एक अलग search API बेहतर विकल्प है।
TL;DR
- •OpenAI: Responses API में tools में {"type": "web_search"} जोड़ें। हर 1,000 कॉल पर $10, साथ में search content tokens मॉडल की दरों पर।
- •Gemini: {"type": "google_search"} (Interactions API) या {"google_search": {}} (generateContent) जोड़ें। Gemini 3 और नए मॉडल पर हर महीने 5,000 search queries मुफ़्त हैं, उसके बाद हर 1,000 queries पर $14।
- •Claude: tools में {"type": "web_search_20250305", "name": "web_search"} (या dynamic filtering वाले नए वर्ज़न 20260209 / 20260318) जोड़ें। हर 1,000 सर्च पर $10, और result tokens input के तौर पर गिने जाते हैं।
- •तीनों में मॉडल ख़ुद तय करता है कि सर्च करना है या नहीं और कितनी बार; पैसा हर सर्च का लगता है, हर सवाल का नहीं। 2026-11-24 को हमारे Gemini टेस्ट में एक सवाल पर दो billed queries चलीं।
- •अलग search API तब लें जब आपको कई models में एक जैसा सर्च, हर सवाल पर एक तय कॉल, या अपनी pipeline के लिए raw results चाहिए। apipick की कीमत हर 1,000 कॉल पर $15 है और सिर्फ़ HTTP 200 responses पर ही चार्ज लगता है।
OpenAI, Gemini और Claude API में वेब सर्च कैसे चालू करें?
Request के tools array में एक built-in tool जोड़ दें: OpenAI Responses API में {"type": "web_search"}, Gemini Interactions API में {"type": "google_search"} (generateContent में {"google_search": {}}), और Claude Messages API में {"type": "web_search_20250305", "name": "web_search"} या उससे नया वर्ज़न। इसके बाद provider ख़ुद सर्च चलाता है, results मॉडल को देता है और citations के साथ जवाब लौटाता है। मॉडल tokens के ऊपर हर सर्च की अलग फ़ीस लगती है।
नीचे दी गई हर जानकारी 2026-11-24 को हर provider के official documentation से मिलाई गई है, और Gemini के उदाहरण उसी दिन चलाए गए।
| OpenAI | Gemini | Claude | apipick search API | |
|---|---|---|---|---|
| क्या जोड़ना है | {"type": "web_search"} | {"type": "google_search"} | {"type": "web_search_20250305", "name": "web_search"} | POST /api/search/web |
| Endpoint | Responses API | Interactions API या generateContent | Messages API | कोई भी मॉडल, आपका कोड |
| हर 1,000 की कीमत | $10 प्रति कॉल | हर महीने 5,000 मुफ़्त के बाद $14 प्रति query | $10 प्रति सर्च | $15 प्रति कॉल |
| Search tokens | मॉडल की दरों पर बिल | Input में बिल नहीं होते | Input tokens के तौर पर बिल | आप तय करते हैं क्या भेजना है |
| Domain filter | Allow या block, दोनों 100 तक | सिर्फ़ block, सिर्फ़ Vertex AI में | Allow या block, दोनों साथ नहीं | आपका कोड results filter करता है |
| Citations | url_citation annotations | Grounding metadata | हमेशा चालू | हर result में title, URL, snippet |
| सर्च का फ़ैसला कौन करता है | मॉडल | मॉडल | मॉडल | आप |
OpenAI API में वेब सर्च कैसे चालू करें?
Responses API इस्तेमाल करें और tools में {"type": "web_search"} जोड़ें। सर्च करना है या नहीं, यह मॉडल तय करता है, और जवाब inline url_citation annotations के साथ आता है जिनमें URL, title और वह character range होती है जिसे वह source support करता है।
from openai import OpenAI
client = OpenAI()
response = client.responses.create(
model="gpt-6.2-astra",
tools=[{"type": "web_search"}],
input="What was a positive news story from today?",
)
print(response.output_text)curl "https://api.openai.com/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-6.2-astra",
"tools": [{"type": "web_search"}],
"input": "What was a positive news story from today?"
}'ये उदाहरण OpenAI के अपने web search guide से लिए गए हैं। Practice में काम आने वाले options:
| Option | क्या करता है |
|---|---|
filters.allowed_domains / blocked_domains | 100-100 domains तक सीमित या बाहर करता है, https:// के बिना; subdomains भी शामिल रहते हैं |
user_location | अनुमानित country (ISO code), city, region, timezone |
search_context_size | low, medium (default) या high |
external_web_access | false करने पर offline, सिर्फ़ cache वाला mode चालू होता है |
include: ["web_search_call.action.sources"] | सिर्फ़ cite किए गए नहीं, बल्कि देखे गए सभी URLs लौटाता है |
tool_choice: "required" | सर्च को ज़रूरी बना देता है; "auto" पर यह वैकल्पिक रहता है |
ध्यान रखने लायक सीमाएँ। Search context window 128k tokens पर सीमित है, भले ही मॉडल इससे ज़्यादा सपोर्ट करता हो। gpt-5 के साथ वेब सर्च के लिए reasoning effort minimal से ऊपर होना चाहिए। पुराना web_search_preview tool legacy integrations में अब भी चलता है, लेकिन filters सपोर्ट नहीं करता। Chat Completions में जोड़ने के लिए कोई tool नहीं है: वहाँ आपको gpt-5-search-api जैसे search model पर switch करना होता है।
कीमत। हर 1,000 web search calls पर $10, साथ में search content tokens मॉडल की अपनी दरों पर। Non-reasoning models पर पुराना preview tool हर 1,000 कॉल पर $25 का है, और उसमें search content tokens मुफ़्त हैं (OpenAI pricing page, 2026-11-24)।
Gemini API में Grounding with Google Search कैसे चालू करें?
google_search tool जोड़ें: Interactions API में {"type": "google_search"}, या generateContent request में {"google_search": {}}। Google के मौजूदा docs Interactions API पर आधारित हैं; generateContent अब भी यह tool स्वीकार करता है और groundingMetadata लौटाता है।
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-4-hydrogen",
input="Who won the euro 2024?",
tools=[{"type": "google_search"}],
)
print(interaction.output_text)curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Api-Revision: 2026-05-20" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-4-hydrogen",
"input": "Who won the euro 2024?",
"tools": [{"type": "google_search"}]
}'अगर आपका कोड अब भी generateContent कॉल करता है, तो tool उसी जगह जाता है:
{"contents": [{"role": "user", "parts": [{"text": "Which team won the 2026 World Series?"}]}],
"tools": [{"google_search": {}}]}हमने 2026-11-24 को यही request gemini-3.8-flash को भेजी। मॉडल ने जवाब दिया "The Milwaukee Brewers won the 2026 World Series", और response में webSearchQueries के अंदर दो search queries थीं, यानी एक सवाल पर दो billable queries लगीं। groundingChunks में sources vertexaisearch.cloud.google.com/grounding-api-redirect/… links के रूप में आए, title में सिर्फ़ domain था और page का कोई text नहीं था।
और क्या जानना ज़रूरी है:
- Response fields. generateContent
groundingMetadataलौटाता है, जिसमेंwebSearchQueries,groundingChunks,groundingSupports(कौन-सा source text के किस हिस्से को support करता है) औरsearchEntryPoint(search suggestions के लिए तैयार HTML) होते हैं। Interactions API इसकी जगहgoogle_search_call,google_search_resultऔरurl_citationannotations लौटाता है। आपके UI में search suggestions दिखाने के नियम Google की Terms of Service तय करती हैं। - Filters. Gemini Developer API tool पर
timeRangeFilterसपोर्ट करता है। Domains को बाहर करना (exclude_domains) Vertex AI के लिए documented है; 2026-11-24 को हमने वहाँ टेस्ट किया तो यह काम किया। कोई allow-list नहीं है। - Models. Gemini 4, Gemini 3.x और Gemini 2.5 / 2.0 models यह tool सपोर्ट करते हैं। पुराने models
google_search_retrievalइस्तेमाल करते थे। - कीमत. Gemini 3 और नए models का बिल हर search query पर बनता है: हर महीने 5,000 मुफ़्त (इन models में साझा), फिर हर 1,000 पर $14, और Developer API के paid tier पर default सीमा रोज़ 1,500 grounding requests की है। Gemini 2.5 का बिल हर grounded prompt पर बनता है: रोज़ 1,500 मुफ़्त के बाद हर 1,000 पर $35।
Gemini कितनी बार सर्च करता है, और grounding के साथ और बिना वह कितना सटीक है, यह हमने Google Search grounding बनाम search API के 40 सवालों वाले टेस्ट में देखा है। यह पेज सिर्फ़ setup पर केंद्रित है।
Claude API में web search tool कैसे चालू करें?
Messages API में tools में {"type": "web_search_20250305", "name": "web_search"} जोड़ें, या dynamic filtering के लिए Claude 4.6 और नए models पर web_search_20260209 / web_search_20260318 इस्तेमाल करें। Claude सर्च Anthropic की तरफ़ चलाता है, और response में queries, results और cited text एक ही reply में आते हैं।
import anthropic
client = anthropic.Anthropic()
response = client.messages.create(
model="claude-opus-5-5",
max_tokens=4096,
messages=[{"role": "user", "content": "What's the weather in NYC?"}],
tools=[{"type": "web_search_20250305", "name": "web_search", "max_uses": 5}],
)
for block in response.content:
if block.type == "text":
print(block.text)curl https://api.anthropic.com/v1/messages \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2026-10-21" \
-H "content-type: application/json" \
-d '{
"model": "claude-opus-5-5",
"max_tokens": 4096,
"messages": [{"role": "user", "content": "What is the weather in NYC?"}],
"tools": [{"type": "web_search_20250305", "name": "web_search", "max_uses": 5}]
}'दोनों उदाहरण Anthropic के web search tool documentation के मुताबिक़ हैं। Tool के वर्ज़न और options:
| Setting | विवरण |
|---|---|
web_search_20250305 | Basic सर्च, हर सपोर्टेड मॉडल और platform पर |
web_search_20260209 | Dynamic filtering जोड़ता है: results context तक पहुँचने से पहले Claude उन्हें कोड से filter करता है |
web_search_20260318 | response_inclusion जोड़ता है, ताकि filter किए गए result blocks response से हटाए जा सकें |
max_uses | हर turn में सर्च की सीमा तय करता है; fail हुए सर्च भी गिने जाते हैं |
allowed_domains / blocked_domains | इनमें से एक ही, दोनों कभी नहीं (400 error) |
user_location | type: "approximate" के साथ city, region, country, timezone |
ध्यान रखने लायक सीमाएँ। Citations हमेशा चालू रहते हैं; हर citation में url, title और cited_text के 150 characters तक होते हैं। पूरा result text encrypted_content के रूप में आता है, जिसे आपको अगले turns में बिना बदले वापस भेजना होता है, लेकिन आप उसे पढ़ नहीं सकते। max_uses_exceeded जैसे errors HTTP 200 के साथ web_search_tool_result block के अंदर error object के रूप में आते हैं। Organization admin Claude Console में वेब सर्च बंद कर सकता है, तब request 400 के साथ fail होती है। Google Cloud पर Google-managed Claude और Azure पर होस्ट किए गए Microsoft Foundry deployments में सिर्फ़ basic वर्ज़न उपलब्ध है।
कीमत। हर 1,000 सर्च पर $10, साथ में सामान्य token खर्च; search results उस turn में और आगे के turns में भी input tokens में गिने जाते हैं। Error वाले सर्च का बिल नहीं बनता।
असल में हर सवाल पर वेब सर्च का खर्च कितना आता है?
हर सवाल का खर्च = search fee × मॉडल ने जितने सर्च चलाए, साथ में results से जुड़े tokens, और built-in tools में ये दोनों चीज़ें मॉडल के हाथ में होती हैं। इसी वजह से ऊपर दी गई प्रति-1,000 कीमतों की सीधी तुलना नहीं की जा सकती।
- सर्च की संख्या. हर tool मॉडल को एक सवाल पर कई सर्च चलाने देता है। ऊपर हमारी Gemini request ने दो चलाए। हमारे 14 नवंबर के grounding टेस्ट में Gemini ने औसतन हर सवाल पर 1.9 से 2.85 queries चलाईं, और एक सवाल पर 16। Claude में
max_usesहर turn में इसकी सीमा तय करता है; OpenAI और Gemini के जिन पेजों को हमने देखा, उनमें ऐसी कोई सीमा नहीं बताई गई है। - Result tokens. OpenAI search content tokens का बिल मॉडल की दरों पर बनाता है, और Claude results को input tokens में गिनता है, इसलिए मॉडल जितना महँगा, हर सर्च उतना महँगा। Gemini grounding text को input tokens में बिल नहीं करता।
- मुफ़्त कोटा. Gemini 3 और नए models पर Gemini हर महीने 5,000 queries देता है। Amazon Bedrock AgentCore का Web Search, जो AWS पर agents के लिए एक अलग विकल्प है, हर 1,000 queries पर $7 का है और 2026-11-17 से हर महीने 5,000 मुफ़्त queries देता है (AWS announcement)।
अलग search API में यह उल्टा हो जाता है: एक सवाल पर कितने कॉल होंगे (आमतौर पर एक) और prompt में कितने results जाएँगे, यह आप तय करते हैं। हमारे पिछले टेस्ट में apipick के पाँच results ने हर सवाल पर लगभग 1,400 input tokens जोड़े।
Built-in search tool कब काफ़ी नहीं होता?
Built-in सर्च किसी एक provider के मॉडल को ground करने का सबसे तेज़ तरीका है, लेकिन यह सर्च को उसी provider से बाँध देता है और नियंत्रण मॉडल के हाथ में छोड़ देता है। पाँच स्थितियाँ जिनमें teams सर्च को अपने कोड में ले आती हैं:
- आप एक से ज़्यादा models इस्तेमाल करते हैं। Google Search grounding सिर्फ़ Gemini के साथ चलता है, और Claude का tool सिर्फ़ Claude के साथ। जो router कुछ सवाल GPT को और कुछ Claude को भेजता है, उसे तीन अलग search engines, कीमतें और citation formats झेलने पड़ेंगे।
- आपको हर सवाल पर एक तय खर्च चाहिए। Built-in tools में कितने सर्च चलेंगे, यह मॉडल चुनता है। अगर आप पहले सर्च करके results पास करें, तो हर सवाल पर ठीक एक कॉल का खर्च आएगा।
- आपको sources पर नियंत्रण चाहिए। Domain filters हर provider में अलग हैं, और Gemini Developer API में allow-list नहीं है। Results आपके कोड में हों तो मॉडल के देखने से पहले ही आप उन्हें हटा, re-rank, log या cache कर सकते हैं।
- आपको raw results चाहिए। Claude result text encrypted लौटाता है, और Gemini redirect links और domain names। अपनी RAG pipeline, evaluation set या audit log के लिए आपको पढ़ने लायक titles, URLs और snippets चाहिए।
- आप models की निष्पक्ष तुलना करना चाहते हैं। Models की तुलना तभी निष्पक्ष है जब हर एक को एक जैसे सबूत मिलें। अलग search कॉल हर मॉडल को बिल्कुल एक जैसा input देता है।
Trade-off असली है: search API का मतलब है एक और कॉल और कुछ लाइनों का glue code, और हमारे Gemini टेस्ट में Google का grounding, results fetch करके पास करने से तेज़ था।
किसी भी मॉडल में एक जैसा वेब सर्च कैसे जोड़ें?
मॉडल से पहले search API कॉल करें, फिर results को prompt में डालें, या सर्च को function tool के रूप में register करें जिसे मॉडल कॉल कर सके। apipick के साथ यह एक POST request है:
curl -X POST https://www.apipick.com/api/search/web \
-H "x-api-key: $APIPICK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "2026 World Series winner", "max_num_results": 5}'2026-11-25 का असली रिस्पॉन्स, सिर्फ़ पहले दो नतीजे, स्निपेट छोटे किए गए:
{
"query": "2026 World Series winner",
"results": [
{
"title": "2026 World Series: Brewers vs. Rays Results, MVP & Recap",
"url": "https://swipesports.com/encyclopedia/2026-world-series/",
"snippet": "The Milwaukee Brewers won the 2026 World Series. They beat the Tampa Bay Rays four games to one and clinched with a 4-1 win in Game 5 at Tropicana Field on October 28, 2026.…",
"source_type": "website",
"published_at": null,
"score": 0.97,
"data_type": "unstructured"
},
{
"title": "World Series 2026: Milwaukee Brewers beat Tampa Bay Rays to become MLB champions - BBC Sport",
"url": "https://www.bbc.co.uk/sport/baseball/articles/c5x2v991l0lvo",
"snippet": "# Brewers win first World Series in 57-year history…",
"source_type": "website",
"published_at": null,
"score": 0.9550247754091665,
"data_type": "unstructured"
}
],
"result_count": 5,
"credits_used": 15
}हर result में title, url, snippet, published_at और relevance score होता है; आप country_code, start_date और end_date भी पास कर सकते हैं। फिर वही results आप जिस भी मॉडल को कॉल करें, उसे जाते हैं:
import os, requests
def search(query: str) -> str:
r = requests.post(
"https://www.apipick.com/api/search/web",
headers={"x-api-key": os.environ["APIPICK_API_KEY"]},
json={"query": query, "max_num_results": 5},
timeout=60,
)
r.raise_for_status()
return "\n\n".join(
f"[{i + 1}] {x['title']} ({x['url']})\n{x['snippet']}"
for i, x in enumerate(r.json()["results"])
)
question = "Who won the 2026 World Series?"
prompt = f"Search results:\n{search(question)}\n\nAnswer with citations: {question}"
# `prompt` को OpenAI, Gemini, Claude या किसी local model को भेजें; सबूत बिल्कुल एक जैसे रहेंगे।एक वेब सर्च पर 15 credits लगते हैं, यानी $1 प्रति 1,000 credits के हिसाब से हर 1,000 कॉल पर $15, और सिर्फ़ HTTP 200 responses पर चार्ज लगता है (pricing)। नए accounts को 100 मुफ़्त credits मिलते हैं, जो छह सर्च के लिए काफ़ी हैं। अगर आप चाहते हैं कि कब सर्च करना है यह मॉडल तय करे, तो OpenAI या Claude agent में web search tool जोड़ने वाला हमारा tutorial इसी endpoint को function tool के रूप में जोड़ता है, और web search API पेज पर tool schema मौजूद है।
आपको कौन-सा विकल्प चुनना चाहिए?
max_uses सेट करें और ऐसे prompts से बचें जो मॉडल को सर्च छोड़ने के लिए उकसाएँ।यह गाइड किन चीज़ों को कवर नहीं करती?
- कीमतें और model names जल्दी बदलते हैं। यहाँ की हर कीमत और parameter 2026-11-24 को जाँचा गया था; budget बनाने से पहले provider pages दोबारा देख लें।
- Deep research agents. OpenAI, Google और Anthropic multi-step research products और agents भी देते हैं, जिनकी अपनी pricing है। यह पेज सिर्फ़ एक API request के अंदर search tool को कवर करता है।
- Azure OpenAI, Vertex AI और Bedrock. Cloud platforms में कौन-से tool versions और filters सपोर्ट होते हैं, यह first-party APIs से अलग हो सकता है, जैसा कि कुछ platforms पर Claude के सिर्फ़ basic सर्च से दिखता है।
- सर्च की quality. यहाँ हमने OpenAI और Claude के search results की आपस में benchmark तुलना नहीं की; grounding के साथ और बिना Gemini की सटीकता के लिए 40 सवालों वाला टेस्ट देखें।
स्रोत (2026-11-24 को जाँचे गए): OpenAI web search guide, OpenAI pricing, Grounding with Google Search, Gemini API pricing, Vertex AI grounding, Claude web search tool, AgentCore pricing।
अक्सर पूछे जाने वाले प्रश्न
क्या OpenAI API में built-in वेब सर्च है?
हाँ। Responses API में tools array में {"type": "web_search"} जोड़ दें, फिर मॉडल वेब पर सर्च करके अपने sources cite कर सकता है। इसकी कीमत हर 1,000 search calls पर $10 है, साथ में search content tokens मॉडल की दरों पर (2026-11-24 को जाँचा गया)। Chat Completions में वेब सर्च सिर्फ़ gpt-5-search-api जैसे ख़ास search models के ज़रिए मिलता है।
क्या Gemini API में Grounding with Google Search मुफ़्त है?
आंशिक रूप से। Gemini 3 और नए models पर हर महीने पहली 5,000 search queries मुफ़्त हैं, और यह कोटा इन सभी models में साझा होता है। उसके बाद Google हर 1,000 search queries पर $14 लेता है, और मॉडल जो भी query चलाता है उसका बिल बनता है, इसलिए एक सवाल पर दो या ज़्यादा queries का खर्च आ सकता है। Gemini 2.5 models का बिल हर grounded prompt पर बनता है: रोज़ 1,500 मुफ़्त के बाद हर 1,000 पर $35।
Claude API में वेब सर्च का खर्च कितना है?
हर 1,000 सर्च पर $10, साथ में सामान्य token खर्च, क्योंकि Claude जो search results पढ़ता है वे input tokens में गिने जाते हैं। जो सर्च error के साथ fail हो जाए, उसका बिल नहीं बनता। कीमतें 2026-11-24 को Anthropic के documentation से जाँची गईं।
क्या मैं वेब सर्च को कुछ ख़ास websites तक सीमित कर सकता हूँ?
OpenAI में हाँ: filters.allowed_domains या blocked_domains, दोनों में 100-100 domains तक। Claude में भी हाँ: allowed_domains या blocked_domains, लेकिन एक request में दोनों एक साथ नहीं। Gemini में Developer API में कोई domain allow-list नहीं है; Vertex AI में domains ब्लॉक करने के लिए exclude_domains चलता है।
क्या मैं Google Search grounding को Claude या GPT के साथ इस्तेमाल कर सकता हूँ?
नहीं। हर provider का built-in सर्च सिर्फ़ उसी के models को ground करता है। Claude, GPT, Gemini या किसी local model को एक जैसे live results देने हों, तो search API को ख़ुद कॉल करें और results को prompt में डालें या किसी tool call से लौटाएँ।
Tool चालू करने के बाद भी मॉडल ने सर्च क्यों नहीं किया?
क्योंकि तीनों built-in tools में मॉडल ख़ुद तय करता है कि कब सर्च करना है। स्थिर तथ्यों वाले सवालों का जवाब वह अक्सर बिना सर्च के दे देता है। साफ़ तौर पर ताज़ा जानकारी माँगें, OpenAI में tool_choice को "required" पर सेट करें, या मॉडल को कॉल करने से पहले अपने कोड में ही सर्च चला लें।
Sarah Choy, apipick की CEO हैं। वे AI एजेंट्स और LLM वर्कफ़्लो के लिए प्रोडक्शन-रेडी APIs बनाने के बारे में लिखती हैं।