Google Search से सटीक जानकारी पाने की सुविधा

Google Search से सटीक जानकारी पाने की सुविधा, Gemini मॉडल को वेब पर मौजूद रीयल-टाइम कॉन्टेंट से कनेक्ट करती है. साथ ही, यह सुविधा सभी उपलब्ध भाषाओं में काम करती है. इससे Gemini, ज़्यादा सटीक जवाब दे पाता है. साथ ही, यह अपनी जानकारी की समयसीमा के बाद भी, पुष्टि किए जा सकने वाले सोर्स का हवाला दे पाता है.

सटीक जानकारी पाने की सुविधा की मदद से, ऐसे ऐप्लिकेशन बनाए जा सकते हैं जो:

  • तथ्यों की सटीक जानकारी दें: जवाबों को असली दुनिया की जानकारी पर आधारित करके, मॉडल के गलत जवाब देने की संभावना को कम करें.
  • रीयल-टाइम जानकारी ऐक्सेस करें: हाल ही में हुए इवेंट और विषयों के बारे में सवालों के जवाब दें.
  • रेफ़रंस दें: मॉडल के दावों के सोर्स दिखाकर, उपयोगकर्ताओं का भरोसा जीतें.

Python

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-3-flash-preview",
    input="Who won the euro 2024?",
    tools=[{"type": "google_search"}]
)

# Print the model's text response
for step in interaction.steps:
    if step.type == "model_output":
        for content_block in step.content:
            if content_block.type == "text":
                print(content_block.text)

JavaScript

import { GoogleGenAI } from "@google/genai";

const client = new GoogleGenAI({});

const interaction = await client.interactions.create({
    model: "gemini-3-flash-preview",
    input: "Who won the euro 2024?",
    tools: [{ type: "google_search" }]
});

const modelStep = interaction.steps.find(s => s.type === 'model_output');
if (modelStep) {
  for (const contentBlock of modelStep.content) {
    if (contentBlock.type === 'text') console.log(contentBlock.text);
  }
}

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-3-flash-preview",
    "input": "Who won the euro 2024?",
    "tools": [{"type": "google_search"}]
  }'

Google Search से सटीक जानकारी पाने की सुविधा कैसे काम करती है

google_search टूल को चालू करने पर, मॉडल, जानकारी खोजने, प्रोसेस करने, और उसका हवाला देने से जुड़ा पूरा वर्कफ़्लो अपने-आप मैनेज करता है.

grounding-overview

  1. उपयोगकर्ता का प्रॉम्प्ट: आपका ऐप्लिकेशन, google_search टूल चालू होने पर, उपयोगकर्ता का प्रॉम्प्ट Gemini API को भेजता है.
  2. प्रॉम्प्ट का विश्लेषण: मॉडल, प्रॉम्प्ट का विश्लेषण करता है और यह तय करता है कि Google Search की मदद से जवाब को बेहतर बनाया जा सकता है या नहीं.
  3. Google Search: ज़रूरत पड़ने पर, मॉडल अपने-आप एक या एक से ज़्यादा खोज क्वेरी जनरेट करता है और उन्हें एक्ज़ीक्यूट करता है.
  4. खोज के नतीजों को प्रोसेस करना: मॉडल, खोज के नतीजों को प्रोसेस करता है, जानकारी को सिंथेसाइज़ करता है, और जवाब तैयार करता है.
  5. सटीक जानकारी वाला जवाब: एपीआई, खोज के नतीजों पर आधारित, उपयोगकर्ता के लिए काम का फ़ाइनल जवाब देता है. इस जवाब में, मॉडल का टेक्स्ट जवाब शामिल होता है. साथ ही, इसमें इनलाइन annotations भी शामिल होते हैं, जिनमें रेफ़रंस के साथ-साथ, खोज क्वेरी और खोज के सुझावों के साथ google_search_call और google_search_result के चरण शामिल होते हैं.

सटीक जानकारी वाले जवाब को समझना

जवाब के लिए सटीक जानकारी मिलने पर, मॉडल के टेक्स्ट आउटपुट में, टेक्स्ट कॉन्टेंट ब्लॉक पर सीधे तौर पर इनलाइन annotations शामिल होते हैं. इन एनोटेशन में, रेफ़रंस की जानकारी दी जाती है. इससे जवाब के हिस्सों को उनके सोर्स से लिंक किया जाता है.

{
  "steps": [
    {
      "type": "thought",
      "summary": [
        {
          "type": "text",
          "text": "The user is asking for the winner of Euro 2024. I need to search for the result of the Euro 2024 final."
        }
      ],
      "signature": "CoMDAXLI2nynRYojJIy6B1Jh9os2crpWLfB0..."
    },
    {
      "type": "google_search_call",
      "arguments": {
        "queries": ["UEFA Euro 2024 winner"]
      }
    },
    {
      "type": "google_search_result",
      "call_id": "search_001",
      "result": [
        {
          "search_suggestions": "<!-- HTML and CSS for the search widget -->"
        }
      ]
    },
    {
      "type": "model_output",
      "content": [
        {
          "type": "text",
          "text": "Spain won Euro 2024, defeating England 2-1 in the final. This victory marks Spain's record fourth European Championship title.",
          "annotations": [
            {
              "type": "url_citation",
              "url": "https://www.aljazeera.com/sports/euro-2024-final",
              "title": "aljazeera.com",
              "start_index": 0,
              "end_index": 56
            },
            {
              "type": "url_citation",
              "url": "https://www.uefa.com/euro2024/news/spain-wins-euro-2024",
              "title": "uefa.com",
              "start_index": 57,
              "end_index": 124
            }
          ]
        }
      ]
    }
  ]
}

जवाब में मौजूद मुख्य फ़ील्ड:

  • google_search_call : इसमें, मॉडल की ओर से एक्ज़ीक्यूट की गई खोज queries शामिल होती हैं.
  • google_search_result : इसमें search_suggestions शामिल होते हैं. यह आपके यूज़र इंटरफ़ेस (यूआई) में खोज के सुझावों को रेंडर करने के लिए, एचटीएमएल स्निपेट होता है. इस्तेमाल से जुड़ी पूरी ज़रूरी शर्तें, सेवा की शर्तों में दी गई हैं.
  • annotations के साथ text : मॉडल का सिंथेसाइज़ किया गया जवाब, जिसमें इनलाइन रेफ़रंस शामिल होते हैं. हर url_citation एनोटेशन, टेक्स्ट सेगमेंट (start_index और end_index से तय किया गया) को सोर्स यूआरएल से लिंक करता है. इनलाइन रेफ़रंस बनाने के लिए, यह ज़रूरी है.

Google Search से सटीक जानकारी पाने की सुविधा का इस्तेमाल, यूआरएल कॉन्टेक्स्ट टूल के साथ भी किया जा सकता है. इससे, सार्वजनिक वेब डेटा और आपके दिए गए खास यूआरएल, दोनों में सटीक जानकारी वाले जवाब दिए जा सकते हैं.

इनलाइन रेफ़रंस की मदद से सोर्स को एट्रिब्यूट करना

एपीआई, टेक्स्ट कॉन्टेंट ब्लॉक पर इनलाइन url_citation एनोटेशन दिखाता है. इससे आपको अपने यूज़र इंटरफ़ेस (यूआई) में सोर्स दिखाने के तरीके पर पूरा कंट्रोल मिलता है. हर एनोटेशन में start_index और end_index शामिल होता है. इससे यह पता चलता है कि यह टेक्स्ट के किस हिस्से का हवाला देता है. इन्हें एक्सट्रैक्ट और डिसप्ले करने का तरीका यहां बताया गया है.

Python

for step in interaction.steps:
    if step.type == "model_output":
        for content_block in step.content:
            if content_block.type == "text":
                print(content_block.text)
                if content_block.annotations:
                    print("\nCitations:")
                    for annotation in content_block.annotations:
                        if annotation.type == "url_citation":
                            cited_text = content_block.text[annotation.start_index:annotation.end_index]
                            print(f"  [{annotation.title}]({annotation.url})")
                            print(f"    Cited text: \"{cited_text}\"")

JavaScript

for (const step of interaction.steps) {
  if (step.type === 'model_output') {
    for (const contentBlock of step.content) {
      if (contentBlock.type === 'text') {
        console.log(contentBlock.text);
        if (contentBlock.annotations) {
          console.log("\nCitations:");
          for (const annotation of contentBlock.annotations) {
            if (annotation.type === 'url_citation') {
              const citedText = contentBlock.text.slice(annotation.startIndex, annotation.endIndex);
              console.log(`  [${annotation.title}](${annotation.url})`);
              console.log(`    Cited text: "${citedText}"`);
            }
          }
        }
      }
    }
  }
}

आउटपुट में, टेक्स्ट के बाद उसके रेफ़रंस दिखेंगे:

Spain won Euro 2024, defeating England 2-1 in the final. This victory marks Spain's record fourth European Championship title.

Citations:
  [aljazeera.com](https://www.aljazeera.com/sports/euro-2024-final)
    Cited text: "Spain won Euro 2024, defeating England 2-1 in the final."
  [uefa.com](https://www.uefa.com/euro2024/news/spain-wins-euro-2024)
    Cited text: "This victory marks Spain's record fourth European Championship title."

कीमत

Gemini 3 के साथ, Google Search से सटीक जानकारी पाने की सुविधा का इस्तेमाल करने पर, आपके प्रोजेक्ट से हर उस खोज क्वेरी के लिए शुल्क लिया जाता है जिसे मॉडल एक्ज़ीक्यूट करने का फ़ैसला लेता है. अगर मॉडल, किसी एक प्रॉम्प्ट का जवाब देने के लिए एक से ज़्यादा खोज क्वेरी एक्ज़ीक्यूट करने का फ़ैसला लेता है (उदाहरण के लिए, एक ही एपीआई कॉल में "UEFA Euro 2024 winner" और "Spain vs England Euro 2024 final score" खोजना), तो इस अनुरोध के लिए, टूल के दो बार इस्तेमाल का शुल्क लिया जाएगा. बिलिंग के मकसद से, यूनीक क्वेरी की गिनती करते समय, हम वेब पर खोज की खाली क्वेरी को अनदेखा करते हैं. यह बिलिंग मॉडल सिर्फ़ Gemini 3 मॉडल पर लागू होता है. Gemini 2.5 या उससे पुराने मॉडल के साथ, खोज से सटीक जानकारी पाने की सुविधा का इस्तेमाल करने पर, आपके प्रोजेक्ट से हर प्रॉम्प्ट के लिए शुल्क लिया जाता है.

कीमत की ज़्यादा जानकारी के लिए, Gemini API की कीमत वाला पेज देखें.

काम करने वाले मॉडल

मॉडल की पूरी क्षमताओं के बारे में जानने के लिए, मॉडल अवलोकन पेज देखें.

मॉडल Google Search से सटीक जानकारी पाने की सुविधा
Gemini 3.1 Flash की इमेज का प्रीव्यू ✔️
Gemini 3.1 Pro का प्रीव्यू ✔️
Gemini 3 Pro की इमेज का प्रीव्यू ✔️
Gemini 3 Flash का प्रीव्यू ✔️
Gemini 2.5 Pro ✔️
Gemini 2.5 Flash ✔️
Gemini 2.5 Flash-Lite ✔️
Gemini 2.0 Flash ✔️

टूल के काम करने वाले कॉम्बिनेशन

ज़्यादा मुश्किल इस्तेमाल के मामलों के लिए, Google Search से सटीक जानकारी पाने की सुविधा का इस्तेमाल, कोड एक्ज़ीक्यूशन और यूआरएल कॉन्टेक्स्ट जैसे अन्य टूल के साथ किया जा सकता है.

Gemini 3 मॉडल, बिल्ट-इन टूल (जैसे, Google Search से सटीक जानकारी पाने की सुविधा) को कस्टम टूल (फ़ंक्शन कॉलिंग) के साथ मिलाकर इस्तेमाल करने की सुविधा देते हैं. ज़्यादा जानने के लिए, टूल के कॉम्बिनेशन वाला पेज देखें.

आगे क्या करना है