عامل تحقیقات عمیق Gemini به طور خودکار وظایف تحقیقاتی چند مرحلهای را برنامهریزی، اجرا و ترکیب میکند. این عامل که توسط Gemini پشتیبانی میشود، در مناظر اطلاعاتی پیچیده پیمایش میکند تا گزارشهای دقیق و قابل استنادی تولید کند. قابلیتهای جدید به شما امکان میدهد تا به صورت مشارکتی با عامل برنامهریزی کنید، با استفاده از سرورهای MCP به ابزارهای خارجی متصل شوید، تجسمسازیها (مانند نمودارها و گرافها) را شامل کنید و اسناد را مستقیماً به عنوان ورودی ارائه دهید.
وظایف تحقیقاتی شامل جستجو و خواندن تکراری هستند و تکمیل آنها میتواند چندین دقیقه طول بکشد. شما باید از اجرای پسزمینه (set background=true ) برای اجرای ناهمگام عامل و نظرسنجی برای نتایج یا بهروزرسانیهای جریان استفاده کنید. برای جزئیات بیشتر به بخش مدیریت وظایف طولانیمدت مراجعه کنید.
مثال زیر نحوه شروع یک کار تحقیقاتی در پسزمینه و نظرسنجی برای نتایج را نشان میدهد.
پایتون
import time
from google import genai
client = genai.Client()
interaction = client.interactions.create(
input="Research the history of Google TPUs.",
agent="deep-research-preview-04-2026",
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)
جاوا اسکریپت
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-preview-04-2026',
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));
}
استراحت
# 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-preview-04-2026",
"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-preview-04-2026): طراحی شده برای سرعت و کارایی، ایدهآل برای استریم مجدد به رابط کاربری کلاینت. - Deep Research Max (
deep-research-max-preview-04-2026): حداکثر جامعیت برای جمعآوری و ترکیب خودکار محتوا.
برنامهریزی مشارکتی
برنامهریزی مشارکتی به شما امکان کنترل مسیر تحقیق را قبل از شروع کار عامل میدهد. وقتی فعال باشد، عامل به جای اجرای فوری، یک طرح تحقیقاتی پیشنهادی را برمیگرداند. سپس میتوانید از طریق تعاملات چند مرحلهای، طرح را بررسی، اصلاح یا تأیید کنید.
مرحله ۱: درخواست طرح
در اولین تعامل collaborative_planning=True را تنظیم کنید. عامل به جای یک گزارش کامل، یک طرح تحقیقاتی را برمیگرداند.
پایتون
from google import genai
client = genai.Client()
# First interaction: request a research plan
plan_interaction = client.interactions.create(
agent="deep-research-preview-04-2026",
input="Do some research on Google TPUs.",
agent_config={
"type": "deep-research",
"thinking_summaries": "auto",
"collaborative_planning": True,
},
background=True,
)
# Wait for and retrieve the plan
while (result := client.interactions.get(id=plan_interaction.id)).status != "completed":
time.sleep(5)
print(result.outputs[-1].text)
جاوا اسکریپت
const planInteraction = await client.interactions.create({
agent: 'deep-research-preview-04-2026',
input: 'Do some research on Google TPUs.',
agent_config: {
type: 'deep-research',
thinking_summaries: 'auto',
collaborative_planning: true
},
background: true
});
let result;
while ((result = await client.interactions.get(planInteraction.id)).status !== 'completed') {
await new Promise(r => setTimeout(r, 5000));
}
console.log(result.outputs[result.outputs.length - 1].text);
استراحت
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "deep-research-preview-04-2026",
"input": "Do some research on Google TPUs.",
"agent_config": {
"type": "deep-research",
"thinking_summaries": "auto",
"collaborative_planning": true
},
"background": true
}'
مرحله ۲: اصلاح طرح (اختیاری)
برای ادامه مکالمه و تکرار طرح previous_interaction_id استفاده کنید. برای ماندن در حالت برنامهریزی، collaborative_planning=True را نگه دارید.
پایتون
# Second interaction: refine the plan
refined_plan = client.interactions.create(
agent="deep-research-preview-04-2026",
input="Focus more on the differences between Google TPUs and competitor hardware, and less on the history.",
agent_config={
"type": "deep-research",
"thinking_summaries": "auto",
"collaborative_planning": True,
},
previous_interaction_id=plan_interaction.id,
background=True,
)
while (result := client.interactions.get(id=refined_plan.id)).status != "completed":
time.sleep(5)
print(result.outputs[-1].text)
جاوا اسکریپت
const refinedPlan = await client.interactions.create({
agent: 'deep-research-preview-04-2026',
input: 'Focus more on the differences between Google TPUs and competitor hardware, and less on the history.',
agent_config: {
type: 'deep-research',
thinking_summaries: 'auto',
collaborative_planning: true
},
previous_interaction_id: planInteraction.id,
background: true
});
let result;
while ((result = await client.interactions.get(refinedPlan.id)).status !== 'completed') {
await new Promise(r => setTimeout(r, 5000));
}
console.log(result.outputs[result.outputs.length - 1].text);
استراحت
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "deep-research-preview-04-2026",
"input": "Focus more on the differences between Google TPUs and competitor hardware, and less on the history.",
"agent_config": {
"type": "deep-research",
"thinking_summaries": "auto",
"collaborative_planning": true
},
"previous_interaction_id": "PREVIOUS_INTERACTION_ID",
"background": true
}'
مرحله ۳: تصویب و اجرا
برای تأیید طرح و شروع تحقیق، collaborative_planning=False را تنظیم کنید (یا آن را حذف کنید).
پایتون
# Third interaction: approve the plan and kick off research
final_report = client.interactions.create(
agent="deep-research-preview-04-2026",
input="Plan looks good!",
agent_config={
"type": "deep-research",
"thinking_summaries": "auto",
"collaborative_planning": False,
},
previous_interaction_id=refined_plan.id,
background=True,
)
while (result := client.interactions.get(id=final_report.id)).status != "completed":
time.sleep(5)
print(result.outputs[-1].text)
جاوا اسکریپت
const finalReport = await client.interactions.create({
agent: 'deep-research-preview-04-2026',
input: 'Plan looks good!',
agent_config: {
type: 'deep-research',
thinking_summaries: 'auto',
collaborative_planning: false
},
previous_interaction_id: refinedPlan.id,
background: true
});
let result;
while ((result = await client.interactions.get(finalReport.id)).status !== 'completed') {
await new Promise(r => setTimeout(r, 5000));
}
console.log(result.outputs[result.outputs.length - 1].text);
استراحت
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "deep-research-preview-04-2026",
"input": "Plan looks good!",
"agent_config": {
"type": "deep-research",
"thinking_summaries": "auto",
"collaborative_planning": false
},
"previous_interaction_id": "PREVIOUS_INTERACTION_ID",
"background": true
}'
تجسم
وقتی visualization روی "auto" تنظیم شود، عامل میتواند نمودارها، گرافها و سایر عناصر بصری را برای پشتیبانی از یافتههای تحقیقاتی خود تولید کند. تصاویر تولید شده در خروجیهای پاسخ گنجانده شده و به عنوان دلتاهای image پخش میشوند. برای بهترین نتیجه، صریحاً در درخواست خود از تصاویر بخواهید - برای مثال، «نمودارهایی را که روندها را در طول زمان نشان میدهند، وارد کنید» یا «گرافیکهایی را برای مقایسه سهم بازار ایجاد کنید». تنظیم visualization روی "auto" این قابلیت را فعال میکند، اما عامل فقط زمانی که درخواست آنها را داشته باشد، تصاویر را تولید میکند.
پایتون
import base64
from IPython.display import Image, display
interaction = client.interactions.create(
agent="deep-research-preview-04-2026",
input="Analyze global semiconductor market trends. Include graphics showing market share changes.",
agent_config={
"type": "deep-research",
"visualization": "auto",
},
background=True,
)
print(f"Research started: {interaction.id}")
while (result := client.interactions.get(id=interaction.id)).status != "completed":
time.sleep(5)
for output in result.outputs:
if output.type == "text":
print(output.text)
elif output.type == "image" and output.data:
image_bytes = base64.b64decode(output.data)
print(f"Received image: {len(image_bytes)} bytes")
# To display in a Jupyter notebook:
# from IPython.display import display, Image
# display(Image(data=image_bytes))
جاوا اسکریپت
import { GoogleGenAI } from '@google/genai';
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: 'deep-research-preview-04-2026',
input: 'Analyze global semiconductor market trends. Include graphics showing market share changes.',
agent_config: {
type: 'deep-research',
visualization: 'auto'
},
background: true
});
console.log(`Research started: ${interaction.id}`);
let result;
while ((result = await client.interactions.get(interaction.id)).status !== 'completed') {
await new Promise(r => setTimeout(r, 5000));
}
for (const output of result.outputs) {
if (output.type === 'text') {
console.log(output.text);
} else if (output.type === 'image' && output.data) {
console.log(`[Image Output: ${output.data.substring(0, 20)}...]`);
}
}
استراحت
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "deep-research-preview-04-2026",
"input": "Analyze global semiconductor market trends. Include graphics showing market share changes.",
"agent_config": {
"type": "deep-research",
"visualization": "auto"
},
"background": true
}'
ابزارهای پشتیبانی شده
Deep Research از چندین ابزار داخلی و خارجی پشتیبانی میکند. به طور پیشفرض (زمانی که هیچ پارامتر tools ارائه نشده باشد)، عامل به جستجوی گوگل، متن URL و اجرای کد دسترسی دارد. شما میتوانید به صراحت ابزارهایی را برای محدود کردن یا گسترش قابلیتهای عامل مشخص کنید.
| ابزار | مقدار نوع | توضیحات |
|---|---|---|
| جستجوی گوگل | google_search | جستجو در وب عمومی. به طور پیشفرض فعال است. |
| متن URL | url_context | خواندن و خلاصه کردن محتوای صفحه وب. به طور پیشفرض فعال است. |
| اجرای کد | code_execution | اجرای کد برای انجام محاسبات و تحلیل دادهها. به طور پیشفرض فعال است. |
| سرور MCP | mcp_server | برای دسترسی به ابزارهای خارجی، به سرورهای MCP از راه دور متصل شوید. |
| جستجوی فایل | file_search | مجموعه اسناد آپلود شده خود را جستجو کنید. |
جستجوی گوگل
به طور صریح جستجوی گوگل را به عنوان تنها ابزار فعال کنید:
پایتون
interaction = client.interactions.create(
agent="deep-research-preview-04-2026",
input="What are the latest developments in quantum computing?",
tools=[{"type": "google_search"}],
background=True,
)
جاوا اسکریپت
const interaction = await client.interactions.create({
agent: 'deep-research-preview-04-2026',
input: 'What are the latest developments in quantum computing?',
tools: [{ type: 'google_search' }],
background: true
});
استراحت
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "deep-research-preview-04-2026",
"input": "What are the latest developments in quantum computing?",
"tools": [{"type": "google_search"}],
"background": true
}'
متن URL
به نماینده این امکان را بدهید که صفحات وب خاصی را بخواند و خلاصه کند:
پایتون
interaction = client.interactions.create(
agent="deep-research-preview-04-2026",
input="Summarize the content of https://www.wikipedia.org/.",
tools=[{"type": "url_context"}],
background=True,
)
جاوا اسکریپت
const interaction = await client.interactions.create({
agent: 'deep-research-preview-04-2026',
input: 'Summarize the content of https://www.wikipedia.org/.',
tools: [{ type: 'url_context' }],
background: true
});
استراحت
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "deep-research-preview-04-2026",
"input": "Summarize the content of https://www.wikipedia.org/.",
"tools": [{"type": "url_context"}],
"background": true
}'
اجرای کد
به عامل اجازه دهید کدی را برای محاسبات و تجزیه و تحلیل دادهها اجرا کند:
پایتون
interaction = client.interactions.create(
agent="deep-research-preview-04-2026",
input="Calculate the 50th Fibonacci number.",
tools=[{"type": "code_execution"}],
background=True,
)
جاوا اسکریپت
const interaction = await client.interactions.create({
agent: 'deep-research-preview-04-2026',
input: 'Calculate the 50th Fibonacci number.',
tools: [{ type: 'code_execution' }],
background: true
});
استراحت
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "deep-research-preview-04-2026",
"input": "Calculate the 50th Fibonacci number.",
"tools": [{"type": "code_execution"}],
"background": true
}'
سرورهای MCP
name و url سرور را در پیکربندی ابزارها ارائه دهید. همچنین میتوانید اعتبارنامههای احراز هویت را ارسال کنید و ابزارهایی را که عامل میتواند فراخوانی کند، محدود کنید.
| میدان | نوع | مورد نیاز | توضیحات |
|---|---|---|---|
type | string | بله | باید "mcp_server" باشد. |
name | string | خیر | یک نام نمایشی برای سرور MCP. |
url | string | خیر | آدرس اینترنتی کامل برای نقطه پایانی سرور MCP. |
headers | object | خیر | جفتهای کلید-مقدار به عنوان هدرهای HTTP با هر درخواست به سرور ارسال میشوند (برای مثال، توکنهای احراز هویت). |
allowed_tools | array | خیر | ابزارهایی را که عامل میتواند از سرور فراخوانی کند، محدود کنید. |
کاربرد اولیه
پایتون
interaction = client.interactions.create(
agent="deep-research-preview-04-2026",
input="Check the status of my last server deployment.",
tools=[
{
"type": "mcp_server",
"name": "Deployment Tracker",
"url": "https://mcp.example.com/mcp",
"headers": {"Authorization": "Bearer my-token"},
}
],
background=True,
)
جاوا اسکریپت
const interaction = await client.interactions.create({
agent: 'deep-research-preview-04-2026',
input: 'Check the status of my last server deployment.',
tools: [
{
type: 'mcp_server',
name: 'Deployment Tracker',
url: 'https://mcp.example.com/mcp',
headers: { Authorization: 'Bearer my-token' }
}
],
background: true
});
استراحت
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "deep-research-preview-04-2026",
"input": "Check the status of my last server deployment.",
"tools": [
{
"type": "mcp_server",
"name": "Deployment Tracker",
"url": "https://mcp.example.com/mcp",
"headers": {"Authorization": "Bearer my-token"}
}
],
"background": true
}'
جستجوی فایل
با استفاده از ابزار جستجوی فایل، به نماینده اجازه دسترسی به دادههای خود را بدهید.
پایتون
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-preview-04-2026",
background=True,
tools=[
{
"type": "file_search",
"file_search_store_names": ['fileSearchStores/my-store-name']
}
]
)
جاوا اسکریپت
const interaction = await client.interactions.create({
input: 'Compare our 2025 fiscal year report against current public web news.',
agent: 'deep-research-preview-04-2026',
background: true,
tools: [
{ type: 'file_search', file_search_store_names: ['fileSearchStores/my-store-name'] },
]
});
استراحت
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-preview-04-2026",
"background": true,
"tools": [
{"type": "file_search", "file_search_store_names": ["fileSearchStores/my-store-name"]},
]
}'
قابلیت هدایت و قالببندی
شما میتوانید با ارائه دستورالعملهای قالببندی خاص در اعلان خود، خروجی نماینده را هدایت کنید. این به شما امکان میدهد گزارشها را در بخشها و زیربخشهای خاص ساختار دهید، جداول داده را در آنها بگنجانید یا لحن را برای مخاطبان مختلف (مثلاً "فنی"، "اجرایی"، "غیررسمی") تنظیم کنید.
قالب خروجی مورد نظر را به طور صریح در متن ورودی خود تعریف کنید.
پایتون
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-preview-04-2026",
background=True
)
جاوا اسکریپت
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-preview-04-2026',
background: true,
});
استراحت
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-preview-04-2026",
"background": true
}'
ورودیهای چندوجهی
Deep Research از ورودیهای چندوجهی، از جمله تصاویر و اسناد (PDF) پشتیبانی میکند و به عامل اجازه میدهد محتوای بصری را تجزیه و تحلیل کند و تحقیقات مبتنی بر وب را که توسط ورودیهای ارائه شده در متن قرار گرفتهاند، انجام دهد.
پایتون
import time
from google import genai
client = genai.Client()
prompt = """Analyze the interspecies dynamics and behavioral risks present
in the provided image of the African watering hole. Specifically, investigate
the symbiotic relationship between the avian species and the pachyderms
shown, and conduct a risk assessment for the reticulated giraffes based on
their drinking posture relative to the specific predator visible in the
foreground."""
interaction = client.interactions.create(
input=[
{"type": "text", "text": prompt},
{
"type": "image",
"uri": "https://storage.googleapis.com/generativeai-downloads/images/generated_elephants_giraffes_zebras_sunset.jpg"
}
],
agent="deep-research-preview-04-2026",
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)
جاوا اسکریپت
import { GoogleGenAI } from '@google/genai';
const client = new GoogleGenAI({});
const prompt = `Analyze the interspecies dynamics and behavioral risks present
in the provided image of the African watering hole. Specifically, investigate
the symbiotic relationship between the avian species and the pachyderms
shown, and conduct a risk assessment for the reticulated giraffes based on
their drinking posture relative to the specific predator visible in the
foreground.`;
const interaction = await client.interactions.create({
input: [
{ type: 'text', text: prompt },
{
type: 'image',
uri: 'https://storage.googleapis.com/generativeai-downloads/images/generated_elephants_giraffes_zebras_sunset.jpg'
}
],
agent: 'deep-research-preview-04-2026',
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));
}
استراحت
# 1. Start the research task with image input
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"input": [
{"type": "text", "text": "Analyze the interspecies dynamics and behavioral risks present in the provided image of the African watering hole. Specifically, investigate the symbiotic relationship between the avian species and the pachyderms shown, and conduct a risk assessment for the reticulated giraffes based on their drinking posture relative to the specific predator visible in the foreground."},
{"type": "image", "uri": "https://storage.googleapis.com/generativeai-downloads/images/generated_elephants_giraffes_zebras_sunset.jpg"}
],
"agent": "deep-research-preview-04-2026",
"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"
درک سند
اسناد را مستقیماً به عنوان ورودی چندوجهی ارسال کنید. عامل، اسناد ارائه شده را تجزیه و تحلیل کرده و تحقیقاتی را بر اساس محتوای آنها انجام میدهد.
پایتون
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="deep-research-preview-04-2026",
input=[
{"type": "text", "text": "What is this document about?"},
{
"type": "document",
"uri": "https://arxiv.org/pdf/1706.03762",
"mime_type": "application/pdf",
},
],
background=True,
)
جاوا اسکریپت
import { GoogleGenAI } from '@google/genai';
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: 'deep-research-preview-04-2026',
input: [
{ type: 'text', text: 'What is this document about?' },
{
type: 'document',
uri: 'https://arxiv.org/pdf/1706.03762',
mime_type: 'application/pdf'
}
],
background: true
});
استراحت
# 1. Start the research task with document input
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "deep-research-preview-04-2026",
"input": [
{"type": "text", "text": "What is this document about?"},
{"type": "document", "uri": "https://arxiv.org/pdf/1706.03762", "mime_type": "application/pdf"}
],
"background": true
}'
مدیریت وظایف طولانی مدت
پژوهش عمیق یک فرآیند چند مرحلهای است که شامل برنامهریزی، جستجو، خواندن و نوشتن میشود. این چرخه معمولاً از محدودیتهای استاندارد زمانبندی فراخوانیهای API همزمان فراتر میرود.
عاملها (agents) ملزم به استفاده از background=True هستند. API بلافاصله یک شیء Interaction جزئی را برمیگرداند. میتوانید از ویژگی id برای بازیابی یک تعامل برای نظرسنجی استفاده کنید. وضعیت تعامل از in_progress به completed یا failed تغییر خواهد کرد.
پخش جریانی
Deep Research از پخش جریانی برای دریافت بهروزرسانیهای بلادرنگ در مورد پیشرفت تحقیق، شامل خلاصه افکار، خروجی متن و تصاویر تولید شده، پشتیبانی میکند. شما باید stream=True و background=True را تنظیم کنید.
برای دریافت مراحل استدلال میانی (افکار) و بهروزرسانیهای پیشرفت، باید با تنظیم thinking_summaries روی "auto" در agent_config ، خلاصههای تفکر را فعال کنید. بدون این، جریان ممکن است فقط نتایج نهایی را ارائه دهد.
انواع رویدادهای استریم
| نوع رویداد | نوع دلتا | توضیحات |
|---|---|---|
content.delta | thought_summary | مرحله استدلال میانی از عامل. |
content.delta | text | بخشی از خروجی متن نهایی. |
content.delta | image | یک تصویر تولید شده (با کدگذاری base64). |
مثال زیر یک کار تحقیقاتی را شروع میکند و جریان را با اتصال مجدد خودکار پردازش میکند. این کار interaction_id ) و شناسه last_event_id را ردیابی میکند تا اگر اتصال قطع شد (برای مثال، پس از پایان مهلت ۶۰۰ ثانیهای)، بتواند از جایی که متوقف شده بود، ادامه یابد.
پایتون
from google import genai
client = genai.Client()
interaction_id = None
last_event_id = None
is_complete = False
def process_stream(stream):
global interaction_id, last_event_id, is_complete
for chunk in stream:
if chunk.event_type == "interaction.start":
interaction_id = chunk.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 in ("interaction.complete", "error"):
is_complete = True
stream = client.interactions.create(
input="Research the history of Google TPUs.",
agent="deep-research-preview-04-2026",
background=True,
stream=True,
agent_config={"type": "deep-research", "thinking_summaries": "auto"},
)
process_stream(stream)
# Reconnect if the connection drops
while not is_complete and interaction_id:
status = client.interactions.get(interaction_id)
if status.status != "in_progress":
break
stream = client.interactions.get(
id=interaction_id, stream=True, last_event_id=last_event_id,
)
process_stream(stream)
جاوا اسکریپت
import { GoogleGenAI } from '@google/genai';
const client = new GoogleGenAI({});
let interactionId;
let lastEventId;
let isComplete = false;
async function processStream(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 (['interaction.complete', 'error'].includes(chunk.event_type)) {
isComplete = true;
}
}
}
const stream = await client.interactions.create({
input: 'Research the history of Google TPUs.',
agent: 'deep-research-preview-04-2026',
background: true,
stream: true,
agent_config: { type: 'deep-research', thinking_summaries: 'auto' },
});
await processStream(stream);
// Reconnect if the connection drops
while (!isComplete && interactionId) {
const status = await client.interactions.get(interactionId);
if (status.status !== 'in_progress') break;
const resumeStream = await client.interactions.get(interactionId, {
stream: true, last_event_id: lastEventId,
});
await processStream(resumeStream);
}
استراحت
# 1. Start the stream (save the INTERACTION_ID from the interaction.start event
# and the last "event_id" you receive)
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-preview-04-2026",
"background": true,
"stream": true,
"agent_config": {
"type": "deep-research",
"thinking_summaries": "auto"
}
}'
# 2. If the connection drops, reconnect with your saved IDs
curl -X GET "https://generativelanguage.googleapis.com/v1beta/interactions/INTERACTION_ID?stream=true&last_event_id=LAST_EVENT_ID" \
-H "x-goog-api-key: $GEMINI_API_KEY"
سوالات و تعاملات بعدی
شما میتوانید پس از اینکه کارشناس گزارش نهایی را برگرداند، با استفاده از previous_interaction_id مکالمه را ادامه دهید. این به شما امکان میدهد بدون شروع مجدد کل کار، درخواست شفافسازی، خلاصهسازی یا شرح بخشهای خاصی از تحقیق را داشته باشید.
پایتون
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.1-pro-preview",
previous_interaction_id="COMPLETED_INTERACTION_ID"
)
print(interaction.outputs[-1].text)
جاوا اسکریپت
const interaction = await client.interactions.create({
input: 'Can you elaborate on the second point in the report?',
model: 'gemini-3.1-pro-preview',
previous_interaction_id: 'COMPLETED_INTERACTION_ID'
});
console.log(interaction.outputs[interaction.outputs.length - 1].text);
استراحت
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?",
"model": "gemini-3.1-pro-preview",
"previous_interaction_id": "COMPLETED_INTERACTION_ID"
}'
چه زمانی از Gemini Deep Research Agent استفاده کنیم؟
Deep Research یک عامل است، نه فقط یک مدل. این ابزار برای بارهای کاری که به رویکرد «تحلیلگر در دسترس» نیاز دارند، به جای چت با تأخیر کم، مناسبتر است.
| ویژگی | مدلهای استاندارد جمینی | نماینده تحقیقات عمیق جمینی |
|---|---|---|
| تأخیر | ثانیهها | دقیقه (غیرهمزمان/پسزمینه) |
| فرآیند | تولید -> خروجی | برنامهریزی -> جستجو -> خواندن -> تکرار -> خروجی |
| خروجی | متن مکالمه، کد، خلاصههای کوتاه | گزارشهای دقیق، تحلیلهای طولانی، جداول مقایسهای |
| بهترین برای | چتباتها، استخراج، نویسندگی خلاق | تحلیل بازار، بررسیهای لازم، بررسی ادبیات، محوطهسازی رقابتی |
پیکربندی عامل
Deep Research از پارامتر agent_config برای کنترل رفتار استفاده میکند. آن را به عنوان یک دیکشنری با فیلدهای زیر ارسال کنید:
| میدان | نوع | پیشفرض | توضیحات |
|---|---|---|---|
type | string | مورد نیاز | باید "deep-research" باشد. |
thinking_summaries | string | "none" | برای دریافت مراحل استدلال میانی در حین پخش، روی "auto" تنظیم کنید. برای غیرفعال کردن، روی "none" تنظیم کنید. |
visualization | string | "auto" | برای فعال کردن نمودارها و تصاویر تولید شده توسط عامل، روی "auto" تنظیم کنید. برای غیرفعال کردن، روی "off" تنظیم کنید. |
collaborative_planning | boolean | false | برای فعال کردن بررسی طرح چند نوبتی قبل از شروع تحقیق، روی true تنظیم کنید. |
پایتون
agent_config = {
"type": "deep-research",
"thinking_summaries": "auto",
"visualization": "auto",
"collaborative_planning": False,
}
interaction = client.interactions.create(
agent="deep-research-preview-04-2026",
input="Research the competitive landscape of cloud GPUs.",
agent_config=agent_config,
background=True,
)
جاوا اسکریپت
const interaction = await client.interactions.create({
agent: 'deep-research-preview-04-2026',
input: 'Research the competitive landscape of cloud GPUs.',
agent_config: {
type: 'deep-research',
thinking_summaries: 'auto',
visualization: 'auto',
collaborative_planning: false,
},
background: true,
});
استراحت
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 cloud GPUs.",
"agent": "deep-research-preview-04-2026",
"agent_config": {
"type": "deep-research",
"thinking_summaries": "auto",
"visualization": "auto",
"collaborative_planning": false
},
"background": true
}'
موجودی و قیمتگذاری
شما میتوانید با استفاده از Interactions API در Google AI Studio و Gemini API به Gemini Deep Research Agent دسترسی پیدا کنید.
قیمتگذاری از یک مدل پرداخت به ازای استفاده پیروی میکند که بر اساس مدلهای زیربنایی Gemini و ابزارهای خاصی است که عامل از آنها استفاده میکند. برخلاف درخواستهای چت استاندارد، که در آن یک درخواست منجر به یک خروجی میشود، یک وظیفه Deep Research یک گردش کار عاملمحور است. یک درخواست واحد، یک حلقه مستقل از برنامهریزی، جستجو، خواندن و استدلال را فعال میکند.
هزینههای تخمینی
هزینهها بسته به عمق تحقیق مورد نیاز متفاوت است. نماینده به طور مستقل میزان مطالعه و جستجو لازم برای پاسخ به سوال شما را تعیین میکند.
- تحقیقات عمیق (
deep-research-preview-04-2026): برای یک پرسوجوی معمولی که نیاز به تحلیل متوسط دارد، عامل ممکن است از حدود ۸۰ پرسوجوی جستجو، حدود ۲۵۰ هزار توکن ورودی (حدود ۵۰ تا ۷۰ درصد آن در حافظه پنهان ذخیره شده) و حدود ۶۰ هزار توکن خروجی استفاده کند.- مجموع تخمینی: تقریباً ۱ تا ۳ دلار برای هر کار
- Deep Research Max (
deep-research-max-preview-04-2026): برای تحلیل عمیق چشمانداز رقابتی یا بررسی دقیق و گسترده، عامل ممکن است تا حدود ۱۶۰ پرسوجوی جستجو، حدود ۹۰۰ هزار توکن ورودی (حدود ۵۰ تا ۷۰ درصد ذخیره شده) و حدود ۸۰ هزار توکن خروجی استفاده کند.- مجموع تخمینی: تقریباً ۳ تا ۷ دلار برای هر کار
ملاحظات ایمنی
دادن دسترسی به وب و فایلهای خصوصی شما به یک نماینده، مستلزم بررسی دقیق خطرات ایمنی است.
- تزریق سریع با استفاده از فایلها: عامل، محتوای فایلهایی را که شما ارائه میدهید میخواند. اطمینان حاصل کنید که اسناد آپلود شده (PDFها، فایلهای متنی) از منابع معتبری آمدهاند. یک فایل مخرب میتواند حاوی متن پنهانی باشد که برای دستکاری خروجی عامل طراحی شده است.
- خطرات محتوای وب: عامل در وب عمومی جستجو میکند. در حالی که ما فیلترهای ایمنی قوی را پیادهسازی میکنیم، این خطر وجود دارد که عامل با صفحات وب مخرب مواجه شده و آنها را پردازش کند. توصیه میکنیم برای تأیید منابع
citationsارائه شده در پاسخ را بررسی کنید. - استخراج اطلاعات: اگر به مامور اجازه مرور وب را میدهید، هنگام درخواست خلاصهسازی دادههای حساس داخلی از او احتیاط کنید.
بهترین شیوهها
- درخواست برای موارد ناشناخته: به نماینده آموزش دهید که چگونه با دادههای از دست رفته برخورد کند. برای مثال، عبارت «اگر ارقام خاص برای سال ۲۰۲۵ در دسترس نیست، صریحاً بیان کنید که آنها پیشبینی هستند یا در دسترس نیستند و نه تخمین» را به درخواست خود اضافه کنید.
- زمینه را فراهم کنید: با ارائه اطلاعات پیشزمینه یا محدودیتها بهطور مستقیم در فرم ورودی، تحقیقات عامل را زمینهسازی کنید.
- از برنامهریزی مشارکتی استفاده کنید: برای پرسشهای پیچیده، برنامهریزی مشارکتی را فعال کنید تا طرح تحقیق قبل از اجرا بررسی و اصلاح شود.
- ورودیهای چندوجهی: عامل تحقیقات عمیق از ورودیهای چندوجهی پشتیبانی میکند. با احتیاط استفاده کنید، زیرا این امر هزینهها را افزایش میدهد و خطر سرریز پنجره زمینه را به همراه دارد.
محدودیتها
- وضعیت بتا : رابط برنامهنویسی کاربردی تعاملات (Interactions API) در مرحله بتای عمومی است. ویژگیها و طرحوارهها ممکن است تغییر کنند.
- ابزارهای سفارشی: در حال حاضر نمیتوانید ابزارهای فراخوانی تابع سفارشی ارائه دهید، اما میتوانید از سرورهای MCP (پروتکل زمینه مدل) از راه دور با عامل Deep Research استفاده کنید.
- خروجی ساختاریافته: عامل تحقیقات عمیق در حال حاضر از خروجیهای ساختاریافته پشتیبانی نمیکند.
- حداکثر زمان تحقیق: عامل تحقیقات عمیق حداکثر ۶۰ دقیقه زمان تحقیق دارد. اکثر وظایف باید ظرف ۲۰ دقیقه انجام شوند.
- الزام ذخیره: اجرای عامل با استفاده از
background=Trueنیاز بهstore=Trueدارد. - جستجوی گوگل: جستجوی گوگل به طور پیشفرض فعال است و محدودیتهای خاصی برای نتایج مبتنی بر آن اعمال میشود.
قدم بعدی چیست؟
- درباره API تعاملات بیشتر بدانید.
- تحقیق عمیق را در کتاب آشپزی Gemini API امتحان کنید.
- یاد بگیرید که چگونه با استفاده از ابزار جستجوی فایل، از دادههای خود استفاده کنید.