Gemini का Deep Research एजेंट

Gemini की Deep Research सुविधा वाला एजेंट, रिसर्च से जुड़े कई चरणों वाले टास्क को अपने-आप प्लान करता है, उन्हें पूरा करता है, और उनका विश्लेषण करता है. यह सुविधा, Gemini 3 Pro की मदद से काम करती है. यह वेब खोज और आपके डेटा का इस्तेमाल करके, जटिल जानकारी को आसानी से समझती है. साथ ही, उद्धरणों के साथ ज़्यादा जानकारी वाली रिपोर्ट जनरेट करती है.

रिसर्च के टास्क में, बार-बार खोज करना और पढ़ना शामिल होता है. इन्हें पूरा करने में कई मिनट लग सकते हैं. आपको एजेंट को एसिंक्रोनस तरीके से चलाने और नतीजों के लिए पोल करने के लिए, बैकग्राउंड एक्ज़ीक्यूशन (background=true सेट करें) का इस्तेमाल करना होगा. ज़्यादा जानकारी के लिए, लंबे समय तक चलने वाले टास्क मैनेज करना लेख पढ़ें.

यहां दिए गए उदाहरण में, बैकग्राउंड में रिसर्च टास्क शुरू करने और नतीजों के लिए पोल करने का तरीका बताया गया है.

Python

import time
from google import genai

client = genai.Client()

interaction = client.interactions.create(
    input="Research the history of Google TPUs.",
    agent='deep-research-pro-preview-12-2025',
    background=True
)

print(f"Research started: {interaction.id}")

while True:
    interaction = client.interactions.get(interaction.id)
    if interaction.status == "completed":
        print(interaction.outputs[-1].text)
        break
    elif interaction.status == "failed":
        print(f"Research failed: {interaction.error}")
        break
    time.sleep(10)

JavaScript

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

const client = new GoogleGenAI({});

const interaction = await client.interactions.create({
    input: 'Research the history of Google TPUs.',
    agent: 'deep-research-pro-preview-12-2025',
    background: true
});

console.log(`Research started: ${interaction.id}`);

while (true) {
    const result = await client.interactions.get(interaction.id);
    if (result.status === 'completed') {
        console.log(result.outputs[result.outputs.length - 1].text);
        break;
    } else if (result.status === 'failed') {
        console.log(`Research failed: ${result.error}`);
        break;
    }
    await new Promise(resolve => setTimeout(resolve, 10000));
}

REST

# 1. Start the research task
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
    "input": "Research the history of Google TPUs.",
    "agent": "deep-research-pro-preview-12-2025",
    "background": true
}'

# 2. Poll for results (Replace INTERACTION_ID)
# curl -X GET "https://generativelanguage.googleapis.com/v1beta/interactions/INTERACTION_ID" \
# -H "x-goog-api-key: $GEMINI_API_KEY"

अपने डेटा का इस्तेमाल करके रिसर्च करना

Deep Research के पास कई तरह के टूल का ऐक्सेस होता है. डिफ़ॉल्ट रूप से, एजेंट के पास सार्वजनिक इंटरनेट पर मौजूद जानकारी को ऐक्सेस करने का अधिकार होता है. इसके लिए, वह google_search और url_context टूल का इस्तेमाल करता है. इन टूल को डिफ़ॉल्ट रूप से तय करने की ज़रूरत नहीं है. हालांकि, अगर आपको फ़ाइल खोजें टूल का इस्तेमाल करके, एजेंट को अपने डेटा का ऐक्सेस भी देना है, तो आपको इसे इस तरह जोड़ना होगा जैसा कि यहां दिए गए उदाहरण में दिखाया गया है.

Python

import time
from google import genai

client = genai.Client()

interaction = client.interactions.create(
    input="Compare our 2025 fiscal year report against current public web news.",
    agent="deep-research-pro-preview-12-2025",
    background=True,
    tools=[
        {
            "type": "file_search",
            "file_search_store_names": ['fileSearchStores/my-store-name']
        }
    ]
)

JavaScript

const interaction = await client.interactions.create({
    input: 'Compare our 2025 fiscal year report against current public web news.',
    agent: 'deep-research-pro-preview-12-2025',
    background: true,
    tools: [
        { type: 'file_search', file_search_store_names: ['fileSearchStores/my-store-name'] },
    ]
});

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
    "input": "Compare our 2025 fiscal year report against current public web news.",
    "agent": "deep-research-pro-preview-12-2025",
    "background": true,
    "tools": [
        {"type": "file_search", "file_search_store_names": ["fileSearchStores/my-store-name"]},
    ]
}'

निर्देश देने और फ़ॉर्मैट करने की सुविधा

अपने प्रॉम्प्ट में फ़ॉर्मैटिंग से जुड़े खास निर्देश देकर, एजेंट के जवाब को अपनी ज़रूरत के हिसाब से बनाया जा सकता है. इससे रिपोर्ट को खास सेक्शन और सब-सेक्शन में व्यवस्थित किया जा सकता है.साथ ही, डेटा टेबल शामिल की जा सकती हैं या अलग-अलग ऑडियंस के हिसाब से टोन में बदलाव किया जा सकता है. उदाहरण के लिए, "टेक्निकल," "एग्ज़ेक्यूटिव," "कैज़ुअल").

अपने इनपुट टेक्स्ट में, आउटपुट का फ़ॉर्मैट साफ़ तौर पर बताएं.

Python

prompt = """
Research the competitive landscape of EV batteries.

Format the output as a technical report with the following structure:
1. Executive Summary
2. Key Players (Must include a data table comparing capacity and chemistry)
3. Supply Chain Risks
"""

interaction = client.interactions.create(
    input=prompt,
    agent="deep-research-pro-preview-12-2025",
    background=True
)

JavaScript

const prompt = `
Research the competitive landscape of EV batteries.

Format the output as a technical report with the following structure:
1. Executive Summary
2. Key Players (Must include a data table comparing capacity and chemistry)
3. Supply Chain Risks
`;

const interaction = await client.interactions.create({
    input: prompt,
    agent: 'deep-research-pro-preview-12-2025',
    background: true,
});

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
    "input": "Research the competitive landscape of EV batteries.\n\nFormat the output as a technical report with the following structure: \n1. Executive Summary\n2. Key Players (Must include a data table comparing capacity and chemistry)\n3. Supply Chain Risks",
    "agent": "deep-research-pro-preview-12-2025",
    "background": true
}'

लंबे समय तक चलने वाले टास्क मैनेज करना

Deep Research की सुविधा कई चरणों वाली प्रोसेस है. इसमें प्लान बनाना, खोजना, पढ़ना, और लिखना शामिल है. आम तौर पर, यह साइकल, सिंक्रोनस एपीआई कॉल के लिए तय की गई स्टैंडर्ड टाइमआउट की सीमाओं से ज़्यादा होता है.

एजेंट को background=True का इस्तेमाल करना होगा. एपीआई, Interaction ऑब्जेक्ट का कुछ हिस्सा तुरंत दिखाता है. पोलिंग के लिए इंटरैक्शन वापस पाने के लिए, id प्रॉपर्टी का इस्तेमाल किया जा सकता है. इंटरैक्शन की स्थिति in_progress से बदलकर completed या failed हो जाएगी.

स्ट्रीमिंग

Deep Research की सुविधा में स्ट्रीमिंग की सुविधा उपलब्ध है. इससे रिसर्च की प्रोग्रेस के बारे में रीयल-टाइम में अपडेट मिलते हैं. आपको stream=True और background=True को सेट करना होगा.

यहां दिए गए उदाहरण में, रिसर्च टास्क शुरू करने और स्ट्रीम को प्रोसेस करने का तरीका बताया गया है. इसमें यह भी बताया गया है कि interaction_id इवेंट को कैसे ट्रैक किया जाता है.interaction.start अगर नेटवर्क में रुकावट आती है, तो आपको स्ट्रीम फिर से शुरू करने के लिए इस आईडी की ज़रूरत होगी. इस कोड में event_id वैरिएबल भी शामिल है. इससे आपको उस खास जगह से फिर से शुरू करने में मदद मिलती है जहां आपने कनेक्शन बंद किया था.

Python

stream = client.interactions.create(
    input="Research the history of Google TPUs.",
    agent="deep-research-pro-preview-12-2025",
    background=True,
    stream=True,
    agent_config={
        "type": "deep-research",
        "thinking_summaries": "auto"
    }
)

interaction_id = None
last_event_id = None

for chunk in stream:
    if chunk.event_type == "interaction.start":
        interaction_id = chunk.interaction.id
        print(f"Interaction started: {interaction_id}")

    if chunk.event_id:
        last_event_id = chunk.event_id

    if chunk.event_type == "content.delta":
        if chunk.delta.type == "text":
            print(chunk.delta.text, end="", flush=True)
        elif chunk.delta.type == "thought_summary":
            print(f"Thought: {chunk.delta.content.text}", flush=True)

    elif chunk.event_type == "interaction.complete":
        print("\nResearch Complete")

JavaScript

const stream = await client.interactions.create({
    input: 'Research the history of Google TPUs.',
    agent: 'deep-research-pro-preview-12-2025',
    background: true,
    stream: true,
    agent_config: {
        type: 'deep-research',
        thinking_summaries: 'auto'
    }
});

let interactionId;
let lastEventId;

for await (const chunk of stream) {
    // 1. Capture Interaction ID
    if (chunk.event_type === 'interaction.start') {
        interactionId = chunk.interaction.id;
        console.log(`Interaction started: ${interactionId}`);
    }

    // 2. Track IDs for potential reconnection
    if (chunk.event_id) lastEventId = chunk.event_id;

    // 3. Handle Content
    if (chunk.event_type === 'content.delta') {
        if (chunk.delta.type === 'text') {
            process.stdout.write(chunk.delta.text);
        } else if (chunk.delta.type === 'thought_summary') {
            console.log(`Thought: ${chunk.delta.content.text}`);
        }
    } else if (chunk.event_type === 'interaction.complete') {
        console.log('\nResearch Complete');
    }
}

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?alt=sse" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
    "input": "Research the history of Google TPUs.",
    "agent": "deep-research-pro-preview-12-2025",
    "background": true,
    "stream": true,
    "agent_config": {
        "type": "deep-research",
        "thinking_summaries": "auto"
    }
}'
# Note: Look for the 'interaction.start' event to get the interaction ID.

स्ट्रीम से फिर से कनेक्ट किया जा रहा है

रिसर्च से जुड़े लंबे टास्क के दौरान, नेटवर्क में रुकावटें आ सकती हैं. इस समस्या को ठीक करने के लिए, आपके ऐप्लिकेशन को कनेक्शन से जुड़ी गड़बड़ियों का पता लगाना चाहिए. साथ ही, client.interactions.get() का इस्तेमाल करके स्ट्रीम को फिर से शुरू करना चाहिए.

फिर से शुरू करने के लिए, आपको ये दो वैल्यू देनी होंगी:

  1. इंटरैक्शन आईडी: यह आईडी, शुरुआती स्ट्रीम में मौजूद interaction.start इवेंट से मिलता है.
  2. लास्ट इवेंट आईडी: यह उस इवेंट का आईडी होता है जिसे आखिरी बार प्रोसेस किया गया था. इससे सर्वर को यह पता चलता है कि उसे इवेंट भेजना इसके बाद फिर से शुरू करना है. अगर यह पैरामीटर उपलब्ध नहीं कराया गया है, तो आपको स्ट्रीम की शुरुआत से वीडियो मिलेगा.

यहां दिए गए उदाहरणों में, एक ऐसा पैटर्न दिखाया गया है जिसमें कनेक्शन के बंद होने पर भी डेटा स्ट्रीम होता रहता है. इसमें, create के शुरुआती अनुरोध को स्ट्रीम करने की कोशिश की जाती है. अगर कनेक्शन बंद हो जाता है, तो get लूप पर वापस आ जाता है.

Python

import time
from google import genai

client = genai.Client()

# Configuration
agent_name = 'deep-research-pro-preview-12-2025'
prompt = 'Compare golang SDK test frameworks'

# State tracking
last_event_id = None
interaction_id = None
is_complete = False

def process_stream(event_stream):
    """Helper to process events from any stream source."""
    global last_event_id, interaction_id, is_complete
    for event in event_stream:
        # Capture Interaction ID
        if event.event_type == "interaction.start":
            interaction_id = event.interaction.id
            print(f"Interaction started: {interaction_id}")

        # Capture Event ID
        if event.event_id:
            last_event_id = event.event_id

        # Print content
        if event.event_type == "content.delta":
            if event.delta.type == "text":
                print(event.delta.text, end="", flush=True)
            elif event.delta.type == "thought_summary":
                print(f"Thought: {event.delta.content.text}", flush=True)

        # Check completion
        if event.event_type in ['interaction.complete', 'error']:
            is_complete = True

# 1. Attempt initial streaming request
try:
    print("Starting Research...")
    initial_stream = client.interactions.create(
        input=prompt,
        agent=agent_name,
        background=True,
        stream=True,
        agent_config={
            "type": "deep-research",
            "thinking_summaries": "auto"
        }
    )
    process_stream(initial_stream)
except Exception as e:
    print(f"\nInitial connection dropped: {e}")

# 2. Reconnection Loop
# If the code reaches here and is_complete is False, we resume using .get()
while not is_complete and interaction_id:
    print(f"\nConnection lost. Resuming from event {last_event_id}...")
    time.sleep(2) 

    try:
        resume_stream = client.interactions.get(
            id=interaction_id,
            stream=True,
            last_event_id=last_event_id
        )
        process_stream(resume_stream)
    except Exception as e:
        print(f"Reconnection failed, retrying... ({e})")

JavaScript

let lastEventId;
let interactionId;
let isComplete = false;

// Helper to handle the event logic
const handleStream = async (stream) => {
    for await (const chunk of stream) {
        if (chunk.event_type === 'interaction.start') {
            interactionId = chunk.interaction.id;
        }
        if (chunk.event_id) lastEventId = chunk.event_id;

        if (chunk.event_type === 'content.delta') {
            if (chunk.delta.type === 'text') {
                process.stdout.write(chunk.delta.text);
            } else if (chunk.delta.type === 'thought_summary') {
                console.log(`Thought: ${chunk.delta.content.text}`);
            }
        } else if (chunk.event_type === 'interaction.complete') {
            isComplete = true;
        }
    }
};

// 1. Start the task with streaming
try {
    const stream = await client.interactions.create({
        input: 'Compare golang SDK test frameworks',
        agent: 'deep-research-pro-preview-12-2025',
        background: true,
        stream: true,
        agent_config: {
            type: 'deep-research',
            thinking_summaries: 'auto'
        }
    });
    await handleStream(stream);
} catch (e) {
    console.log('\nInitial stream interrupted.');
}

// 2. Reconnect Loop
while (!isComplete && interactionId) {
    console.log(`\nReconnecting to interaction ${interactionId} from event ${lastEventId}...`);
    try {
        const stream = await client.interactions.get(interactionId, {
            stream: true,
            last_event_id: lastEventId
        });
        await handleStream(stream);
    } catch (e) {
        console.log('Reconnection failed, retrying in 2s...');
        await new Promise(resolve => setTimeout(resolve, 2000));
    }
}

REST

# 1. Start the research task (Initial Stream)
# Watch for event: interaction.start to get the INTERACTION_ID
# Watch for "event_id" fields to get the LAST_EVENT_ID
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?alt=sse" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
    "input": "Compare golang SDK test frameworks",
    "agent": "deep-research-pro-preview-12-2025",
    "background": true,
    "stream": true,
    "agent_config": {
        "type": "deep-research",
        "thinking_summaries": "auto"
    }
}'

# ... Connection interrupted ...

# 2. Reconnect (Resume Stream)
# Pass the INTERACTION_ID and the LAST_EVENT_ID you saved.
curl -X GET "https://generativelanguage.googleapis.com/v1beta/interactions/INTERACTION_ID?stream=true&last_event_id=LAST_EVENT_ID&alt=sse" \
-H "x-goog-api-key: $GEMINI_API_KEY"

फ़ॉलो-अप वाले सवाल और इंटरैक्शन

एजेंट से फ़ाइनल रिपोर्ट मिलने के बाद, previous_interaction_id का इस्तेमाल करके बातचीत जारी रखी जा सकती है. इससे आपको पूरी रिसर्च को फिर से शुरू किए बिना, रिसर्च के किसी खास सेक्शन के बारे में ज़्यादा जानकारी पाने, उसे छोटा करने या उसके बारे में ज़्यादा जानकारी देने के लिए कहा जा सकता है.

Python

import time
from google import genai

client = genai.Client()

interaction = client.interactions.create(
    input="Can you elaborate on the second point in the report?",
    model="gemini-3-pro-preview",
    previous_interaction_id="COMPLETED_INTERACTION_ID"
)

print(interaction.outputs[-1].text)

JavaScript

const interaction = await client.interactions.create({
    input: 'Can you elaborate on the second point in the report?',
    agent: 'deep-research-pro-preview-12-2025',
    previous_interaction_id: 'COMPLETED_INTERACTION_ID'
});
console.log(interaction.outputs[-1].text);

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
    "input": "Can you elaborate on the second point in the report?",
    "agent": "deep-research-pro-preview-12-2025",
    "previous_interaction_id": "COMPLETED_INTERACTION_ID"
}'

Gemini Deep Research Agent का इस्तेमाल कब करना चाहिए

Deep Research सिर्फ़ एक मॉडल नहीं, बल्कि एक एजेंट है. यह उन वर्कलोड के लिए सबसे सही है जिनमें कम इंतज़ार के समय वाली चैट के बजाय, "ऐनलिस्ट-इन-अ-बॉक्स" अप्रोच की ज़रूरत होती है.

सुविधा Gemini के स्टैंडर्ड मॉडल Gemini का Deep Research एजेंट
लेटेंसी सेकंड मिनट (एसिंक/बैकग्राउंड)
प्रोसेस जनरेट करें -> आउटपुट प्लान -> खोजें -> पढ़ें -> दोहराएं -> आउटपुट
आउटपुट बातचीत वाला टेक्स्ट, कोड, कम शब्दों में जानकारी ज़्यादा जानकारी वाली रिपोर्ट, लंबी अवधि का विश्लेषण, तुलना करने वाली टेबल
इन स्थितियों में बेहतर है चैटबॉट, जानकारी निकालना, क्रिएटिव राइटिंग मार्केट ऐनलिसिस, ज़रूरी जांच, साहित्य की समीक्षा, और प्रतिस्पर्धी लैंडस्केपिंग

उपलब्धता और कीमत

  • उपलब्धता: इसे Google AI Studio और Gemini API में Interactions API का इस्तेमाल करके ऐक्सेस किया जा सकता है.
  • शुल्क: खास दरों और जानकारी के लिए, शुल्क वाला पेज देखें.

सुरक्षा से जुड़ी बातें

किसी एजेंट को वेब और आपकी निजी फ़ाइलों का ऐक्सेस देने से पहले, सुरक्षा से जुड़े जोखिमों के बारे में सोच-विचार करना ज़रूरी है.

  • फ़ाइलों का इस्तेमाल करके प्रॉम्प्ट इंजेक्ट करना: एजेंट, आपकी दी गई फ़ाइलों का कॉन्टेंट पढ़ता है. पक्का करें कि अपलोड किए गए दस्तावेज़ (पीडीएफ़, टेक्स्ट फ़ाइलें) भरोसेमंद सोर्स से लिए गए हों. नुकसान पहुंचाने वाली फ़ाइल में ऐसा छिपा हुआ टेक्स्ट हो सकता है जिसे एजेंट के आउटपुट में बदलाव करने के लिए डिज़ाइन किया गया हो.
  • वेब कॉन्टेंट से जुड़े जोखिम: एजेंट, सार्वजनिक वेब पर खोज करता है. हम सुरक्षा के लिए मज़बूत फ़िल्टर लागू करते हैं. हालांकि, इस बात का खतरा बना रहता है कि एजेंट को नुकसान पहुंचाने वाले वेब पेजों का सामना करना पड़ सकता है और वह उन्हें प्रोसेस कर सकता है. हमारा सुझाव है कि जवाब में दिए गए citations की समीक्षा करके, सोर्स की पुष्टि करें.
  • डेटा चोरी: अगर आपने एजेंट को वेब ब्राउज़ करने की अनुमति दी है, तो संवेदनशील आंतरिक डेटा की खास जानकारी देने के लिए एजेंट से अनुरोध करते समय सावधानी बरतें.

सबसे सही तरीके

  • अनजान सवालों के जवाब देने के लिए प्रॉम्प्ट: एजेंट को यह निर्देश दें कि वह मौजूद न होने वाले डेटा को कैसे मैनेज करे. उदाहरण के लिए, अपने प्रॉम्प्ट में "अगर 2025 के लिए कुछ खास आंकड़े उपलब्ध नहीं हैं, तो अनुमान लगाने के बजाय साफ़ तौर पर बताएं कि वे अनुमान हैं या उपलब्ध नहीं हैं" जोड़ें.
  • संदर्भ दें: एजेंट को रिसर्च करने के लिए, इनपुट प्रॉम्प्ट में सीधे तौर पर बैकग्राउंड की जानकारी या पाबंदियां दें.
  • मल्टीमॉडल इनपुट Deep Research Agent, मल्टीमॉडल इनपुट के साथ काम करता है. इसका इस्तेमाल सावधानी से करें, क्योंकि इससे लागत बढ़ जाती है और कॉन्टेक्स्ट विंडो ओवरफ़्लो होने का खतरा बढ़ जाता है.

सीमाएं

  • बीटा वर्शन की स्थिति: Interactions API, सार्वजनिक बीटा वर्शन में उपलब्ध है. सुविधाओं और स्कीमा में बदलाव हो सकता है.
  • कस्टम टूल: फ़िलहाल, डीप रिसर्च एजेंट को कस्टम फ़ंक्शन कॉलिंग टूल या रिमोट एमसीपी (मॉडल कॉन्टेक्स्ट प्रोटोकॉल) सर्वर नहीं दिए जा सकते.
  • स्ट्रक्चर्ड आउटपुट और प्लान की मंज़ूरी: फ़िलहाल, Deep Research एजेंट में इंसानों से प्लान की मंज़ूरी लेने या स्ट्रक्चर्ड आउटपुट पाने की सुविधा उपलब्ध नहीं है.
  • रिसर्च के लिए ज़्यादा से ज़्यादा समय: Deep Research एजेंट को रिसर्च करने के लिए ज़्यादा से ज़्यादा 60 मिनट मिलते हैं. ज़्यादातर टास्क 20 मिनट में पूरे हो जाने चाहिए.
  • स्टोर की ज़रूरी शर्तें: background=True का इस्तेमाल करके एजेंट को लागू करने के लिए, store=True ज़रूरी है.
  • Google Search: Google Search डिफ़ॉल्ट रूप से चालू होता है. साथ ही, भरोसेमंद स्रोतों से मिली जानकारी के आधार पर तैयार किए गए जवाबों पर कुछ पाबंदियां लागू होती हैं.
  • ऑडियो इनपुट: ऑडियो इनपुट का इस्तेमाल नहीं किया जा सकता.

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

  • Interactions API के बारे में ज़्यादा जानें.
  • इस एजेंट को काम करने में मदद करने वाले Gemini 3 Pro मॉडल के बारे में पढ़ें.
  • फ़ाइल खोजें टूल का इस्तेमाल करके, अपने डेटा को इस्तेमाल करने का तरीका जानें.