عامل Gemini Deep Research بهطور خودکار وظایف پژوهشی چندمرحلهای را برنامهریزی، اجرا، و ترکیب میکند. این ویژگی با بهرهگیری از Gemini، در فضاهای اطلاعاتی پیچیده پیمایش میکند تا گزارشهای دقیق و مستند تولید کند. قابلیتهای جدید به شما امکان میدهد با عامل بهصورت مشارکتی برنامهریزی کنید، بااستفاده از سرورهای MCP به ابزارهای خارجی متصل شوید، تصویرسازیهایی (مثل نمودارها و گرافها) اضافه کنید، و اسناد را مستقیماً بهعنوان ورودی ارائه دهید.
تکالیف پژوهشی شامل جستجو و خواندن تکرارشونده است و تکمیل آن میتواند چند دقیقه طول بکشد. برای اجرای ناهمگام عامل و نظرسنجی برای نتایج یا بهروزرسانیهای جاریسازی، باید از اجرای پسزمینه (تنظیم 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-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.steps[-1].content[0].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-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.steps.at(-1).content[0].text);
break;
} else if (result.status === 'failed') {
console.log(`Research failed: ${result.error}`);
break;
}
await new Promise(resolve => setTimeout(resolve, 10000));
}
جاوا
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionStatus;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.GetInteractionByIdRequest;
import java.util.Collections;
Client client = new Client();
CreateAgentInteraction params =
CreateAgentInteraction.builder()
.agent("deep-research-preview-04-2026")
.input(InteractionsInput.of("Research the history of Google TPUs."))
.background(true)
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
System.out.println("Research started: " + interaction.id().orElse(""));
while (true) {
interaction =
client.interactions
.get(GetInteractionByIdRequest.builder().id(interaction.id().get()).build())
.interaction()
.get();
if (InteractionStatus.COMPLETED.equals(interaction.status().orElse(null))) {
System.out.println(interaction.outputText().orElse(""));
break;
} else if (InteractionStatus.FAILED.equals(interaction.status().orElse(null))) {
System.out.println("Research failed: " + interaction.errors().orElse(Collections.emptyList()));
break;
}
Thread.sleep(10000);
}
رفتن
package main
import (
"context"
"fmt"
"log"
"time"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("deep-research-preview-04-2026"),
Input: interactions.NewInteractionsInput("Research the history of Google TPUs."),
Background: genai.Ptr(true),
}),
})
if err != nil {
log.Fatal(err)
}
interaction := res.Interaction
if interaction.ID != nil {
fmt.Printf("Research started: %s\n", *interaction.ID)
}
for {
getRes, err := client.Interactions.Get(ctx, operations.GetInteractionByIDRequest{
ID: *interaction.ID,
})
if err != nil {
log.Fatal(err)
}
interaction = getRes.Interaction
if interaction.Status == interactions.InteractionStatusCompleted {
if interaction.OutputText != nil {
fmt.Println(*interaction.OutputText)
}
break
} else if interaction.Status == interactions.InteractionStatusFailed {
fmt.Printf("Research failed: %v\n", interaction.Errors)
break
}
time.Sleep(10 * time.Second)
}
}
استراحت
# 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 در دو نسخه ارائه میشود:
- Deep Research (
deep-research-preview-04-2026): برای سرعت و کارایی طراحی شده است، برای جاریسازی به رابط کاربری مشتری ایدهآل است. - Deep Research Max (
deep-research-max-preview-04-2026): حداکثر جامعیت برای جمعآوری و ترکیب خودکار بافت.
برنامهریزی مشارکتی
برنامهریزی مشارکتی به شما امکان میدهد قبلاز اینکه عامل کارش را شروع کند، جهت پژوهش را کنترل کنید و به شما اجازه میدهد طرح پژوهش را قبلاز اجرا بازبینی و اصلاح کنید. وقتی فعال باشد، عامل بهجای اجرای فوری، یک طرح پژوهشی پیشنهادی برمیگرداند. سپس میتوانید طرح را ازطریق تعاملات چند مرحلهای مرور، اصلاح، یا تأیید کنید.
مرحله ۱: درخواست طرح
collaborative_planning=True را در اولین تعامل تنظیم کنید. عامل
بهجای گزارش کامل، طرح پژوهشی برمیگرداند.
Python
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.steps[-1].content[0].text)
JavaScript
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.steps.at(-1).content[0].text);
جاوا
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.DeepResearchAgentConfig;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionStatus;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.ThinkingSummaries;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.GetInteractionByIdRequest;
Client client = new Client();
// First interaction: request a research plan
CreateAgentInteraction params =
CreateAgentInteraction.builder()
.agent("deep-research-preview-04-2026")
.input(InteractionsInput.of("Do some research on Google TPUs."))
.agentConfig(
DeepResearchAgentConfig.builder()
.thinkingSummaries(ThinkingSummaries.AUTO)
.collaborativePlanning(true)
.build())
.background(true)
.build();
Interaction planInteraction =
client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
// Wait for and retrieve the plan
Interaction result;
while (true) {
result =
client.interactions
.get(GetInteractionByIdRequest.builder().id(planInteraction.id().get()).build())
.interaction()
.get();
if (InteractionStatus.COMPLETED.equals(result.status().orElse(null))) {
break;
}
Thread.sleep(5000);
}
System.out.println(result.outputText().orElse(""));
رفتن
package main
import (
"context"
"fmt"
"log"
"time"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
agentCfg := interactions.NewCreateAgentInteractionAgentConfig(interactions.DeepResearchAgentConfig{
ThinkingSummaries: interactions.ThinkingSummariesAuto.ToPointer(),
CollaborativePlanning: genai.Ptr(true),
})
// First interaction: request a research plan
planRes, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("deep-research-preview-04-2026"),
Input: interactions.NewInteractionsInput("Do some research on Google TPUs."),
AgentConfig: &agentCfg,
Background: genai.Ptr(true),
}),
})
if err != nil {
log.Fatal(err)
}
// Wait for and retrieve the plan
var result *interactions.Interaction
for {
getRes, err := client.Interactions.Get(ctx, operations.GetInteractionByIDRequest{
ID: *planRes.Interaction.ID,
})
if err != nil {
log.Fatal(err)
}
result = getRes.Interaction
if result.Status == interactions.InteractionStatusCompleted {
break
}
time.Sleep(5 * time.Second)
}
if result.OutputText != nil {
fmt.Println(*result.OutputText)
}
}
استراحت
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 را نگه دارید.
Python
# 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.steps[-1].content[0].text)
JavaScript
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.steps.at(-1).content[0].text);
جاوا
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.DeepResearchAgentConfig;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionStatus;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.ThinkingSummaries;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.GetInteractionByIdRequest;
Client client = new Client();
String planInteractionId = "PLAN_INTERACTION_ID";
// Second interaction: refine the plan
CreateAgentInteraction params =
CreateAgentInteraction.builder()
.agent("deep-research-preview-04-2026")
.input(
InteractionsInput.of(
"Focus more on the differences between Google TPUs and competitor hardware, and less on the history."))
.agentConfig(
DeepResearchAgentConfig.builder()
.thinkingSummaries(ThinkingSummaries.AUTO)
.collaborativePlanning(true)
.build())
.previousInteractionId(planInteractionId)
.background(true)
.build();
Interaction refinedPlan =
client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
Interaction result;
while (true) {
result =
client.interactions
.get(GetInteractionByIdRequest.builder().id(refinedPlan.id().get()).build())
.interaction()
.get();
if (InteractionStatus.COMPLETED.equals(result.status().orElse(null))) {
break;
}
Thread.sleep(5000);
}
System.out.println(result.outputText().orElse(""));
رفتن
package main
import (
"context"
"fmt"
"log"
"time"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
planInteractionID := "PLAN_INTERACTION_ID"
agentCfg := interactions.NewCreateAgentInteractionAgentConfig(interactions.DeepResearchAgentConfig{
ThinkingSummaries: interactions.ThinkingSummariesAuto.ToPointer(),
CollaborativePlanning: genai.Ptr(true),
})
// Second interaction: refine the plan
refinedRes, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("deep-research-preview-04-2026"),
Input: interactions.NewInteractionsInput("Focus more on the differences between Google TPUs and competitor hardware, and less on the history."),
AgentConfig: &agentCfg,
PreviousInteractionID: genai.Ptr(planInteractionID),
Background: genai.Ptr(true),
}),
})
if err != nil {
log.Fatal(err)
}
var result *interactions.Interaction
for {
getRes, err := client.Interactions.Get(ctx, operations.GetInteractionByIDRequest{
ID: *refinedRes.Interaction.ID,
})
if err != nil {
log.Fatal(err)
}
result = getRes.Interaction
if result.Status == interactions.InteractionStatusCompleted {
break
}
time.Sleep(5 * time.Second)
}
if result.OutputText != nil {
fmt.Println(*result.OutputText)
}
}
استراحت
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 را تنظیم کنید (یا آن را حذف کنید).
Python
# 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.steps[-1].content[0].text)
JavaScript
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.steps.at(-1).content[0].text);
جاوا
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.DeepResearchAgentConfig;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionStatus;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.ThinkingSummaries;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.GetInteractionByIdRequest;
Client client = new Client();
String refinedPlanId = "REFINED_PLAN_ID";
// Third interaction: approve the plan and kick off research
CreateAgentInteraction params =
CreateAgentInteraction.builder()
.agent("deep-research-preview-04-2026")
.input(InteractionsInput.of("Plan looks good!"))
.agentConfig(
DeepResearchAgentConfig.builder()
.thinkingSummaries(ThinkingSummaries.AUTO)
.collaborativePlanning(false)
.build())
.previousInteractionId(refinedPlanId)
.background(true)
.build();
Interaction finalReport =
client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
Interaction result;
while (true) {
result =
client.interactions
.get(GetInteractionByIdRequest.builder().id(finalReport.id().get()).build())
.interaction()
.get();
if (InteractionStatus.COMPLETED.equals(result.status().orElse(null))) {
break;
}
Thread.sleep(5000);
}
System.out.println(result.outputText().orElse(""));
رفتن
package main
import (
"context"
"fmt"
"log"
"time"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
refinedPlanID := "REFINED_PLAN_ID"
agentCfg := interactions.NewCreateAgentInteractionAgentConfig(interactions.DeepResearchAgentConfig{
ThinkingSummaries: interactions.ThinkingSummariesAuto.ToPointer(),
CollaborativePlanning: genai.Ptr(false),
})
// Third interaction: approve the plan and kick off research
finalRes, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("deep-research-preview-04-2026"),
Input: interactions.NewInteractionsInput("Plan looks good!"),
AgentConfig: &agentCfg,
PreviousInteractionID: genai.Ptr(refinedPlanID),
Background: genai.Ptr(true),
}),
})
if err != nil {
log.Fatal(err)
}
var result *interactions.Interaction
for {
getRes, err := client.Interactions.Get(ctx, operations.GetInteractionByIDRequest{
ID: *finalRes.Interaction.ID,
})
if err != nil {
log.Fatal(err)
}
result = getRes.Interaction
if result.Status == interactions.InteractionStatusCompleted {
break
}
time.Sleep(5 * time.Second)
}
if result.OutputText != nil {
fmt.Println(*result.OutputText)
}
}
REST
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" این قابلیت را فعال میکند، اما عامل فقط زمانی عناصر دیداری تولید میکند
که پیامواره آنها را درخواست کند.
Python
import base64
import time
from google import genai
client = genai.Client()
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 step in result.steps:
if step.type == "model_output":
for content_item in step.content:
if content_item.type == "text":
print(content_item.text)
elif content_item.type == "image" and content_item.data:
image_bytes = base64.b64decode(content_item.data)
print(f"Received image: {len(image_bytes)} bytes")
JavaScript
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 step of result.steps) {
if (step.type === 'model_output') {
for (const contentItem of step.content) {
if (contentItem.type === 'text') {
console.log(contentItem.text);
} else if (contentItem.type === 'image' && contentItem.data) {
console.log(`[Image Output: ${contentItem.data.substring(0, 20)}...]`);
}
}
}
}
جاوا
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.Content;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.DeepResearchAgentConfig;
import com.google.genai.gaos.models.interactions.ImageContent;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionStatus;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.ModelOutputStep;
import com.google.genai.gaos.models.interactions.Step;
import com.google.genai.gaos.models.interactions.TextContent;
import com.google.genai.gaos.models.interactions.Visualization;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.GetInteractionByIdRequest;
import java.util.Base64;
import java.util.Collections;
Client client = new Client();
CreateAgentInteraction params =
CreateAgentInteraction.builder()
.agent("deep-research-preview-04-2026")
.input(
InteractionsInput.of(
"Analyze global semiconductor market trends. Include graphics showing market share changes."))
.agentConfig(DeepResearchAgentConfig.builder().visualization(Visualization.AUTO).build())
.background(true)
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
System.out.println("Research started: " + interaction.id().orElse(""));
Interaction result;
while (true) {
result =
client.interactions
.get(GetInteractionByIdRequest.builder().id(interaction.id().get()).build())
.interaction()
.get();
if (InteractionStatus.COMPLETED.equals(result.status().orElse(null))) {
break;
}
Thread.sleep(5000);
}
for (Step step : result.steps().orElse(Collections.emptyList())) {
if (step instanceof ModelOutputStep) {
for (Content contentItem : ((ModelOutputStep) step).content().orElse(Collections.emptyList())) {
if (contentItem instanceof TextContent) {
System.out.println(((TextContent) contentItem).text().orElse(""));
} else if (contentItem instanceof ImageContent) {
ImageContent img = (ImageContent) contentItem;
if (img.data().isPresent()) {
byte[] imageBytes = Base64.getDecoder().decode(img.data().get());
System.out.println("Received image: " + imageBytes.length + " bytes");
}
}
}
}
}
رفتن
package main
import (
"context"
"encoding/base64"
"fmt"
"log"
"time"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
agentCfg := interactions.NewCreateAgentInteractionAgentConfig(interactions.DeepResearchAgentConfig{
Visualization: interactions.VisualizationAuto.ToPointer(),
})
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("deep-research-preview-04-2026"),
Input: interactions.NewInteractionsInput("Analyze global semiconductor market trends. Include graphics showing market share changes."),
AgentConfig: &agentCfg,
Background: genai.Ptr(true),
}),
})
if err != nil {
log.Fatal(err)
}
if res.Interaction.ID != nil {
fmt.Printf("Research started: %s\n", *res.Interaction.ID)
}
var result *interactions.Interaction
for {
getRes, err := client.Interactions.Get(ctx, operations.GetInteractionByIDRequest{
ID: *res.Interaction.ID,
})
if err != nil {
log.Fatal(err)
}
result = getRes.Interaction
if result.Status == interactions.InteractionStatusCompleted {
break
}
time.Sleep(5 * time.Second)
}
for _, step := range result.Steps {
if outStep := step.ModelOutputStep; outStep != nil {
for _, contentItem := range outStep.Content {
if textContent := contentItem.TextContent; textContent != nil {
fmt.Println(textContent.GetText())
} else if imgContent := contentItem.ImageContent; imgContent != nil && imgContent.Data != nil {
imageBytes, err := base64.StdEncoding.DecodeString(*imgContent.Data)
if err == nil {
fmt.Printf("Received image: %d bytes\n", len(imageBytes))
}
}
}
}
}
}
REST
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 ارائه نشده باشد)، نماینده به «جستجوی Google»، «بافت نشانی وب»، و «اجرای کد» دسترسی دارد. میتوانید بهطور صریح
ابزارهایی را برای محدود کردن یا گسترش دادن قابلیتهای عامل مشخص کنید.
| ابزار | تایپ کردن مقدار | شرح |
|---|---|---|
| جستجوی Google | google_search |
جستجوی وب عمومی. بهطور پیشفرض فعال است. |
| بافت نشانی وب | url_context |
محتوای صفحه وب را بخواند و خلاصه کند. بهطور پیشفرض فعال است. |
| اجرای کد | code_execution |
برای انجام محاسبات و تجزیهوتحلیل دادهها، کد اجرا کنید. بهطور پیشفرض فعال است. |
| سرور MCP | mcp_server |
برای دسترسی به ابزار خارجی، به سرورهای MCP راه دور متصل شوید. |
| جستجوی فایل | file_search |
در گردآوری اطلاعات سند بارگذاریشدهتان جستجو کنید. |
جستجوی Google
بهطور صریح «جستجوی Google» را بهعنوان تنها ابزار فعال کنید:
Python
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,
)
JavaScript
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
});
جاوا
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.GoogleSearch;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.Arrays;
Client client = new Client();
CreateAgentInteraction params =
CreateAgentInteraction.builder()
.agent("deep-research-preview-04-2026")
.input(InteractionsInput.of("What are the latest developments in quantum computing?"))
.tools(Arrays.asList(GoogleSearch.builder().build()))
.background(true)
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
رفتن
package main
import (
"context"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
_, err = client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("deep-research-preview-04-2026"),
Input: interactions.NewInteractionsInput("What are the latest developments in quantum computing?"),
Tools: []interactions.Tool{
interactions.NewTool(interactions.GoogleSearch{}),
},
Background: genai.Ptr(true),
}),
})
if err != nil {
log.Fatal(err)
}
}
استراحت
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
}'
بافت نشانی وب
به عامل توانایی خواندن و خلاصه کردن صفحههای وب خاص را بدهید:
Python
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,
)
JavaScript
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
});
جاوا
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.URLContext;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.Arrays;
Client client = new Client();
CreateAgentInteraction params =
CreateAgentInteraction.builder()
.agent("deep-research-preview-04-2026")
.input(InteractionsInput.of("Summarize the content of https://www.wikipedia.org/."))
.tools(Arrays.asList(URLContext.builder().build()))
.background(true)
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
رفتن
package main
import (
"context"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
_, err = client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("deep-research-preview-04-2026"),
Input: interactions.NewInteractionsInput("Summarize the content of https://www.wikipedia.org/."),
Tools: []interactions.Tool{
interactions.NewTool(interactions.URLContext{}),
},
Background: genai.Ptr(true),
}),
})
if err != nil {
log.Fatal(err)
}
}
REST
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
}'
اجرای کد
به نماینده اجازه دهید کد را برای محاسبات و تجزیهوتحلیل دادهها اجرا کند:
Python
interaction = client.interactions.create(
agent="deep-research-preview-04-2026",
input="Calculate the 50th Fibonacci number.",
tools=[{"type": "code_execution"}],
background=True,
)
JavaScript
const interaction = await client.interactions.create({
agent: 'deep-research-preview-04-2026',
input: 'Calculate the 50th Fibonacci number.',
tools: [{ type: 'code_execution' }],
background: true
});
جاوا
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CodeExecution;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.Arrays;
Client client = new Client();
CreateAgentInteraction params =
CreateAgentInteraction.builder()
.agent("deep-research-preview-04-2026")
.input(InteractionsInput.of("Calculate the 50th Fibonacci number."))
.tools(Arrays.asList(CodeExecution.builder().build()))
.background(true)
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
رفتن
package main
import (
"context"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
_, err = client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("deep-research-preview-04-2026"),
Input: interactions.NewInteractionsInput("Calculate the 50th Fibonacci number."),
Tools: []interactions.Tool{
interactions.NewTool(interactions.CodeExecution{}),
},
Background: genai.Ptr(true),
}),
})
if err != nil {
log.Fatal(err)
}
}
استراحت
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"input": "Calculate the 50th Fibonacci number.",
"agent": "deep-research-preview-04-2026",
"tools": [{"type": "code_execution"}],
"background": true
}'
سرورهای MCP
به سرورهای MCP راه دور متصل شوید تا به نماینده امکان دسترسی به ابزارها و سرویسهای خارجی را بدهید.
سرور name و url را در پیکربندی ابزارها ارائه دهید. همچنین میتوانید
اعتبارنامههای اصالتسنجی را ارسال کنید و ابزارهایی را که نماینده میتواند فراخوانی کند محدود کنید.
| فیلد | نوع | الزامی | شرح |
|---|---|---|---|
type |
string |
بله | باید "mcp_server" باشد. |
name |
string |
نه | نام نمایشی برای سرور MCP. |
url |
string |
نه | نشانی وب کامل نقطه پایان سرور MCP. |
headers |
object |
نه | جفتهای کلید-مقدار که بهعنوان سرصفحههای HTTP با هر درخواست به سرور ارسال میشوند (برای مثال، کدهای اصالتسنجی). |
allowed_tools |
array |
نه | ابزارهایی را که کارگزار میتواند از سرور فراخوانی کند محدود کنید. |
استفاده پایه
Python
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,
)
JavaScript
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
});
جاوا
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.MCPServer;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.Arrays;
import java.util.Collections;
Client client = new Client();
CreateAgentInteraction params =
CreateAgentInteraction.builder()
.agent("deep-research-preview-04-2026")
.input(InteractionsInput.of("Check the status of my last server deployment."))
.tools(
Arrays.asList(
MCPServer.builder()
.name("Deployment Tracker")
.url("https://mcp.example.com/mcp")
.headers(Collections.singletonMap("Authorization", "Bearer my-token"))
.build()))
.background(true)
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
رفتن
package main
import (
"context"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
_, err = client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("deep-research-preview-04-2026"),
Input: interactions.NewInteractionsInput("Check the status of my last server deployment."),
Tools: []interactions.Tool{
interactions.NewTool(interactions.MCPServer{
Name: genai.Ptr("Deployment Tracker"),
URL: genai.Ptr("https://mcp.example.com/mcp"),
Headers: map[string]string{
"Authorization": "Bearer my-token",
},
}),
},
Background: genai.Ptr(true),
}),
})
if err != nil {
log.Fatal(err)
}
}
استراحت
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
}'
جستجوی فایل
بااستفاده از ابزار جستجوی فایل، به نماینده اجازه دهید به دادههای خودتان دسترسی داشته باشد.
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-preview-04-2026",
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-preview-04-2026',
background: true,
tools: [
{ type: 'file_search', file_search_store_names: ['fileSearchStores/my-store-name'] },
]
});
جاوا
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.FileSearch;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.Arrays;
Client client = new Client();
CreateAgentInteraction params =
CreateAgentInteraction.builder()
.agent("deep-research-preview-04-2026")
.input(
InteractionsInput.of(
"Compare our 2025 fiscal year report against current public web news."))
.tools(
Arrays.asList(
FileSearch.builder()
.fileSearchStoreNames(Arrays.asList("fileSearchStores/my-store-name"))
.build()))
.background(true)
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
رفتن
package main
import (
"context"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
_, err = client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("deep-research-preview-04-2026"),
Input: interactions.NewInteractionsInput("Compare our 2025 fiscal year report against current public web news."),
Tools: []interactions.Tool{
interactions.NewTool(interactions.FileSearch{
FileSearchStoreNames: []string{"fileSearchStores/my-store-name"},
}),
},
Background: genai.Ptr(true),
}),
})
if err != nil {
log.Fatal(err)
}
}
استراحت
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"]},
]
}'
هدایتپذیری و قالببندی
میتوانید با ارائه دستورالعملهای قالببندی خاص در پیاموارهتان، خروجی نماینده را هدایت کنید. این کار به شما امکان میدهد گزارشها را در بخشها و زیربخشهای خاصی ساختاربندی کنید، جدولهای داده را اضافه کنید، یا لحن را برای مخاطبان مختلف (مثلاً «فنی»، «اجرایی»، «غیررسمی») تنظیم کنید.
قالب خروجی موردنظر را بهطور صریح در نوشتار ورودیتان تعریف کنید.
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-preview-04-2026",
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-preview-04-2026',
background: true,
});
جاوا
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
Client client = new Client();
String prompt =
"Research the competitive landscape of EV batteries.\n\n"
+ "Format the output as a technical report with the following structure:\n"
+ "1. Executive Summary\n"
+ "2. Key Players (Must include a data table comparing capacity and chemistry)\n"
+ "3. Supply Chain Risks";
CreateAgentInteraction params =
CreateAgentInteraction.builder()
.agent("deep-research-preview-04-2026")
.input(InteractionsInput.of(prompt))
.background(true)
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
رفتن
package main
import (
"context"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
prompt := "Research the competitive landscape of EV batteries.\n\n" +
"Format the output as a technical report with the following structure:\n" +
"1. Executive Summary\n" +
"2. Key Players (Must include a data table comparing capacity and chemistry)\n" +
"3. Supply Chain Risks"
_, err = client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("deep-research-preview-04-2026"),
Input: interactions.NewInteractionsInput(prompt),
Background: genai.Ptr(true),
}),
})
if err != nil {
log.Fatal(err)
}
}
استراحت
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)، پشتیبانی میکند و به عامل امکان میدهد محتوای بصری را تحلیل کند و پژوهشهای مبتنی بر وب را بااستفاده از ورودیهای ارائهشده زمینهسازی کند.
Python
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",
"mime_type": "image/jpeg",
"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.steps[-1].content[0].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 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',
mime_type: "image/jpeg",
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.steps.at(-1).content[0].text);
break;
} else if (result.status === 'failed') {
console.log(`Research failed: ${result.error}`);
break;
}
await new Promise(resolve => setTimeout(resolve, 10000));
}
جاوا
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.ImageContent;
import com.google.genai.gaos.models.interactions.ImageContentMimeType;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionStatus;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.TextContent;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.GetInteractionByIdRequest;
import java.util.Arrays;
import java.util.Collections;
Client client = new Client();
String 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.";
CreateAgentInteraction params =
CreateAgentInteraction.builder()
.agent("deep-research-preview-04-2026")
.input(
InteractionsInput.ofContent(
Arrays.asList(
TextContent.builder().text(prompt).build(),
ImageContent.builder()
.mimeType(ImageContentMimeType.IMAGE_JPEG)
.uri(
"https://storage.googleapis.com/generativeai-downloads/images/generated_elephants_giraffes_zebras_sunset.jpg")
.build())))
.background(true)
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
System.out.println("Research started: " + interaction.id().orElse(""));
while (true) {
interaction =
client.interactions
.get(GetInteractionByIdRequest.builder().id(interaction.id().get()).build())
.interaction()
.get();
if (InteractionStatus.COMPLETED.equals(interaction.status().orElse(null))) {
System.out.println(interaction.outputText().orElse(""));
break;
} else if (InteractionStatus.FAILED.equals(interaction.status().orElse(null))) {
System.out.println("Research failed: " + interaction.errors().orElse(Collections.emptyList()));
break;
}
Thread.sleep(10000);
}
رفتن
package main
import (
"context"
"fmt"
"log"
"time"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
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."
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("deep-research-preview-04-2026"),
Input: interactions.NewInteractionsInput([]interactions.Content{
interactions.NewContent(interactions.TextContent{Text: prompt}),
interactions.NewContent(interactions.ImageContent{
MimeType: interactions.ImageContentMimeType("image/jpeg").ToPointer(),
URI: genai.Ptr("https://storage.googleapis.com/generativeai-downloads/images/generated_elephants_giraffes_zebras_sunset.jpg"),
}),
}),
Background: genai.Ptr(true),
}),
})
if err != nil {
log.Fatal(err)
}
interaction := res.Interaction
if interaction.ID != nil {
fmt.Printf("Research started: %s\n", *interaction.ID)
}
for {
getRes, err := client.Interactions.Get(ctx, operations.GetInteractionByIDRequest{
ID: *interaction.ID,
})
if err != nil {
log.Fatal(err)
}
interaction = getRes.Interaction
if interaction.Status == interactions.InteractionStatusCompleted {
if interaction.OutputText != nil {
fmt.Println(*interaction.OutputText)
}
break
} else if interaction.Status == interactions.InteractionStatusFailed {
fmt.Printf("Research failed: %v\n", interaction.Errors)
break
}
time.Sleep(10 * time.Second)
}
}
استراحت
# 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", "mime_type": "image/jpeg", "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"
درک سند
درک سند امکان ارسال مستقیم اسناد را بهعنوان ورودی چندوجهی فراهم میکند. نماینده اسناد ارائهشده را تجزیهوتحلیل میکند و پژوهشی را براساس محتوای آنها انجام میدهد.
Python
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,
)
JavaScript
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
});
جاوا
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.DocumentContent;
import com.google.genai.gaos.models.interactions.DocumentContentMimeType;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.TextContent;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.Arrays;
Client client = new Client();
CreateAgentInteraction params =
CreateAgentInteraction.builder()
.agent("deep-research-preview-04-2026")
.input(
InteractionsInput.ofContent(
Arrays.asList(
TextContent.builder().text("What is this document about?").build(),
DocumentContent.builder()
.uri("https://arxiv.org/pdf/1706.03762")
.mimeType(DocumentContentMimeType.APPLICATION_PDF)
.build())))
.background(true)
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
رفتن
package main
import (
"context"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
_, err = client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("deep-research-preview-04-2026"),
Input: interactions.NewInteractionsInput([]interactions.Content{
interactions.NewContent(interactions.TextContent{Text: "What is this document about?"}),
interactions.NewContent(interactions.DocumentContent{
URI: genai.Ptr("https://arxiv.org/pdf/1706.03762"),
MimeType: interactions.DocumentContentMimeType("application/pdf").ToPointer(),
}),
}),
Background: genai.Ptr(true),
}),
})
if err != nil {
log.Fatal(err)
}
}
REST
# 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
}'
رسیدگی به تکالیف طولانیمدت
Deep Research فرایندی چندمرحلهای است که شامل برنامهریزی، جستجو، خواندن، و نوشتن میشود. این چرخه معمولاً از حد مجاز زماناتمام استاندارد فراخوانیهای همگام API فراتر میرود.
عاملها باید از background=True استفاده کنند. میانای برنامهسازی کاربردی فوراً شیء
Interaction ناقصی را برمیگرداند. میتوانید از ویژگی id برای بازیابی تعامل برای نظرسنجی استفاده کنید. وضعیت تعامل از
in_progress به completed یا failed تغییر خواهد کرد. برای راهنمای جامع درباره مدیریت کردن کارهای پسزمینه، اجرا در پسزمینه را ببینید.
جاریسازی
«پژوهش عمیق» از جاریسازی برای دریافت بهروزرسانیهای همزمان درباره پیشرفت پژوهش، ازجمله خلاصههای فکری، برونداد نوشتاری، و تصاویر تولیدشده پشتیبانی میکند.
باید stream=True و background=True را تنظیم کنید.
برای دریافت مراحل استدلال میانی (افکار) و بهروزرسانیهای پیشرفت،
باید خلاصههای تفکر را با تنظیم thinking_summaries روی
"auto" در agent_config فعال کنید. بدون این، جاریسازی ممکن است فقط نتایج نهایی را ارائه دهد.
انواع رویداد جاریسازی
| نوع رویداد | نوع دلتا | شرح |
|---|---|---|
step.delta |
thought |
مرحله استدلال میانی از عامل. |
step.delta |
text |
بخشی از برونداد نوشتاری نهایی. |
step.delta |
image |
تصویر تولیدشده (کدبندیشده با base64). |
مثال زیر یک تکلیف پژوهشی را شروع میکند و جاریسازی را با اتصال مجدد خودکار پردازش میکند. این روش interaction_id و last_event_id را ردیابی میکند تا اگر اتصال قطع شد (برای مثال، پساز مهلت ۶۰۰ ثانیهای)، بتواند از جایی که متوقف شده بود ازسر گرفته شود.
Python
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 event in stream:
if event.event_type == "interaction.created":
interaction_id = event.interaction.id
if event.event_id:
last_event_id = event.event_id
if event.event_type == "step.delta":
if event.delta.type == "text":
print(event.delta.text, end="", flush=True)
elif event.delta.type == "thought":
print(f"Thought: {event.delta.text}", flush=True)
elif event.event_type in ("interaction.completed", "interaction.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)
JavaScript
import { GoogleGenAI } from '@google/genai';
const client = new GoogleGenAI({});
let interactionId;
let lastEventId;
let isComplete = false;
async function processStream(stream) {
for await (const event of stream) {
if (event.type === 'interaction.created') {
interactionId = event.interaction.id;
}
if (event.event_id) lastEventId = event.event_id;
if (event.type === 'step.delta') {
if (event.delta.type === 'text') {
process.stdout.write(event.delta.text);
} else if (event.delta.type === 'thought') {
console.log(`Thought: ${event.delta.text}`);
}
} else if (['interaction.completed', 'interaction.error'].includes(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);
}
جاوا
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.Content;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.DeepResearchAgentConfig;
import com.google.genai.gaos.models.interactions.ErrorEvent;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionCompletedEvent;
import com.google.genai.gaos.models.interactions.InteractionCreatedEvent;
import com.google.genai.gaos.models.interactions.InteractionSSEEvent;
import com.google.genai.gaos.models.interactions.InteractionSSEStreamEvent;
import com.google.genai.gaos.models.interactions.InteractionStatus;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.StepDelta;
import com.google.genai.gaos.models.interactions.TextContent;
import com.google.genai.gaos.models.interactions.TextDelta;
import com.google.genai.gaos.models.interactions.ThinkingSummaries;
import com.google.genai.gaos.models.interactions.ThoughtSummaryDelta;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.GetInteractionByIdRequest;
import com.google.genai.gaos.utils.EventStream;
class StreamProcessor {
String interactionId = null;
String lastEventId = null;
boolean isComplete = false;
void processStream(EventStream<InteractionSSEStreamEvent> stream) {
for (InteractionSSEStreamEvent streamEvent : stream) {
InteractionSSEEvent event = streamEvent.data().orElse(null);
if (event instanceof InteractionCreatedEvent) {
InteractionCreatedEvent created = (InteractionCreatedEvent) event;
interactionId = created.interaction().flatMap(i -> i.id()).orElse(null);
if (created.eventId().isPresent()) {
lastEventId = created.eventId().get();
}
} else if (event instanceof StepDelta) {
StepDelta stepDelta = (StepDelta) event;
if (stepDelta.eventId().isPresent()) {
lastEventId = stepDelta.eventId().get();
}
if (stepDelta.delta().isPresent()) {
if (stepDelta.delta().get() instanceof TextDelta) {
System.out.print(((TextDelta) stepDelta.delta().get()).text().orElse(""));
System.out.flush();
} else if (stepDelta.delta().get() instanceof ThoughtSummaryDelta) {
ThoughtSummaryDelta thought = (ThoughtSummaryDelta) stepDelta.delta().get();
Content content = thought.content().orElse(null);
if (content instanceof TextContent) {
System.out.println("Thought: " + ((TextContent) content).text().orElse(""));
}
}
}
} else if (event instanceof InteractionCompletedEvent || event instanceof ErrorEvent) {
isComplete = true;
}
}
}
}
Client client = new Client();
StreamProcessor processor = new StreamProcessor();
CreateAgentInteraction params =
CreateAgentInteraction.builder()
.agent("deep-research-preview-04-2026")
.input(InteractionsInput.of("Research the history of Google TPUs."))
.background(true)
.stream(true)
.agentConfig(
DeepResearchAgentConfig.builder().thinkingSummaries(ThinkingSummaries.AUTO).build())
.build();
try (EventStream<InteractionSSEStreamEvent> stream =
client.interactions.create(CreateInteractionRequestBody.of(params)).events()) {
processor.processStream(stream);
}
// Reconnect if the connection drops
while (!processor.isComplete && processor.interactionId != null) {
Interaction status =
client.interactions
.get(GetInteractionByIdRequest.builder().id(processor.interactionId).build())
.interaction()
.get();
if (!InteractionStatus.IN_PROGRESS.equals(status.status().orElse(null))) {
break;
}
try (EventStream<InteractionSSEStreamEvent> stream =
client.interactions
.get(
GetInteractionByIdRequest.builder()
.id(processor.interactionId)
.stream(true)
.lastEventId(processor.lastEventId)
.build())
.events()) {
processor.processStream(stream);
}
}
رفتن
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
"google.golang.org/genai/interactions/types/stream"
)
type StreamProcessor struct {
interactionID string
lastEventID *string
isComplete bool
}
func (p *StreamProcessor) processStream(s *stream.EventStream[interactions.InteractionSSEStreamEvent]) {
defer s.Close()
for s.Next() {
event := s.Value()
if created := event.GetDataInteractionCreated(); created != nil {
p.interactionID = created.Interaction.ID
if created.EventID != nil {
p.lastEventID = created.EventID
}
} else if stepDelta := event.GetDataStepDelta(); stepDelta != nil {
if stepDelta.EventID != nil {
p.lastEventID = stepDelta.EventID
}
if textDelta := stepDelta.GetDeltaText(); textDelta != nil {
fmt.Print(textDelta.GetText())
} else if thoughtDelta := stepDelta.GetDeltaThoughtSummary(); thoughtDelta != nil {
if textContent := thoughtDelta.GetContentText(); textContent != nil {
fmt.Printf("Thought: %s\n", textContent.GetText())
}
}
} else if event.GetDataInteractionCompleted() != nil || event.GetDataError() != nil {
p.isComplete = true
}
}
}
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
processor := &StreamProcessor{}
agentCfg := interactions.NewCreateAgentInteractionAgentConfig(interactions.DeepResearchAgentConfig{
ThinkingSummaries: interactions.ThinkingSummariesAuto.ToPointer(),
})
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("deep-research-preview-04-2026"),
Input: interactions.NewInteractionsInput("Research the history of Google TPUs."),
Background: genai.Ptr(true),
Stream: genai.Ptr(true),
AgentConfig: &agentCfg,
}),
})
if err != nil {
log.Fatal(err)
}
processor.processStream(res.InteractionSSEStreamEvent)
// Reconnect if the connection drops
for !processor.isComplete && processor.interactionID != "" {
statusRes, err := client.Interactions.Get(ctx, operations.GetInteractionByIDRequest{
ID: processor.interactionID,
})
if err != nil || statusRes.Interaction.Status != interactions.InteractionStatusInProgress {
break
}
streamRes, err := client.Interactions.Get(ctx, operations.GetInteractionByIDRequest{
ID: processor.interactionID,
Stream: genai.Ptr(true),
LastEventID: processor.lastEventID,
})
if err != nil {
break
}
processor.processStream(streamRes.InteractionSSEStreamEvent)
}
}
REST
# 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 مکالمه را ادامه دهید. این کار به شما امکان میدهد بدون راهاندازی مجدد کل تکلیف، درباره بخشهای خاصی از تحقیق درخواست شفافسازی، خلاصهسازی، یا توضیح بیشتر کنید.
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-4-argon",
previous_interaction_id="COMPLETED_INTERACTION_ID"
)
print(interaction.steps[-1].content[0].text)
JavaScript
const interaction = await client.interactions.create({
input: 'Can you elaborate on the second point in the report?',
model: 'gemini-4-argon',
previous_interaction_id: 'COMPLETED_INTERACTION_ID'
});
console.log(interaction.steps.at(-1).content[0].text);
جاوا
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
Client client = new Client();
CreateModelInteraction params =
CreateModelInteraction.builder()
.model("gemini-4-argon")
.input(InteractionsInput.of("Can you elaborate on the second point in the report?"))
.previousInteractionId("COMPLETED_INTERACTION_ID")
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
System.out.println(interaction.outputText().orElse(""));
رفتن
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
Model: interactions.Model("gemini-4-argon"),
Input: interactions.NewInteractionsInput("Can you elaborate on the second point in the report?"),
PreviousInteractionID: genai.Ptr("COMPLETED_INTERACTION_ID"),
}),
})
if err != nil {
log.Fatal(err)
}
if res.Interaction.OutputText != nil {
fmt.Println(*res.Interaction.OutputText)
}
}
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?",
"model": "gemini-4-argon",
"previous_interaction_id": "COMPLETED_INTERACTION_ID"
}'
چه زمانی از کارگزار Gemini Deep Research استفاده کنیم
Deep Research یک عامل است، نه فقط یک مدل. این ویژگی برای حجمهای کاری که به رویکرد «تحلیلگر در جعبه» نیاز دارند مناسبتر است تا گپ با تأخیر کم.
| ویژگی | مدلهای Gemini استاندارد | عامل Gemini 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 تنظیم کنید. |
Python
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,
)
JavaScript
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,
});
جاوا
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.DeepResearchAgentConfig;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.ThinkingSummaries;
import com.google.genai.gaos.models.interactions.Visualization;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
Client client = new Client();
DeepResearchAgentConfig agentConfig =
DeepResearchAgentConfig.builder()
.thinkingSummaries(ThinkingSummaries.AUTO)
.visualization(Visualization.AUTO)
.collaborativePlanning(false)
.build();
CreateAgentInteraction params =
CreateAgentInteraction.builder()
.agent("deep-research-preview-04-2026")
.input(InteractionsInput.of("Research the competitive landscape of cloud GPUs."))
.agentConfig(agentConfig)
.background(true)
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
رفتن
package main
import (
"context"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
agentCfg := interactions.NewCreateAgentInteractionAgentConfig(interactions.DeepResearchAgentConfig{
ThinkingSummaries: interactions.ThinkingSummariesAuto.ToPointer(),
Visualization: interactions.VisualizationAuto.ToPointer(),
CollaborativePlanning: genai.Ptr(false),
})
_, err = client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("deep-research-preview-04-2026"),
Input: interactions.NewInteractionsInput("Research the competitive landscape of cloud GPUs."),
AgentConfig: &agentCfg,
Background: genai.Ptr(true),
}),
})
if err != nil {
log.Fatal(err)
}
}
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 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 دسترسی داشته باشید.
قیمتگذاری از مدل پرداخت به اندازه استفاده پیروی میکند که براساس مدلهای Gemini زیربنایی و ابزارهای خاصی است که نماینده استفاده میکند. برخلاف درخواستهای گپ استاندارد که در آنها یک درخواست به یک خروجی منجر میشود، تکلیف Deep Research یک گردش کار عاملگرا است. یک درخواست، حلقه خودگردانی از برنامهریزی، جستجو، خواندن، و استدلال را راهاندازی میکند.
هزینههای تخمینی
هزینهها براساس میزان تحقیق موردنیاز متفاوت است. عامل بهطور خودکار تعیین میکند که برای پاسخ دادن به پیامواره شما چقدر خواندن و جستجو لازم است.
- Deep Research (
deep-research-preview-04-2026): برای یک پُرسمان معمولی که به تحلیل متوسط نیاز دارد، ممکن است نماینده از حدود ۸۰ پُرسمان جستجو، حدود ۲۵۰ هزار نشانه ورودی (حدود ۵۰ تا ۷۰ درصد ذخیرهشده در حافظه نهان)، و حدود ۶۰ هزار نشانه خروجی استفاده کند.- مجموع تخمینی: حدود ۱٫۰۰ تا ۳٫۰۰ دلار برای هر تکلیف
- Deep Research Max (
deep-research-max-preview-04-2026): برای تجزیهوتحلیل عمیق فضای رقابتی یا بررسی دقیق گسترده، ممکن است کارگزار از حداکثر ۱۶۰ پُرسمان جستجو، ۹۰۰ هزار واحد ورودی (۵۰ تا ۷۰٪ حافظه نهان)، و ۸۰ هزار واحد خروجی استفاده کند.- مجموع تخمینی: حدود ۳ تا ۷ دلار برای هر تکلیف
ملاحظات ایمنی
اعطای دسترسی به وب و فایلهای خصوصی به یک عامل مستلزم بررسی دقیق خطرات ایمنی است.
- تزریق پیامواره بااستفاده از فایلها: نماینده محتوای فایلهایی را که ارائه میدهید میخواند. مطمئن شوید که اسناد بارگذاریشده (فایلهای PDF، فایلهای نوشتاری) از منابع معتبر باشند. فایل مخرب ممکن است حاوی نوشتار پنهانی باشد که برای دستکاری برونداد نماینده طراحی شده است.
- خطرات محتوای وب: نماینده وب عمومی را جستجو میکند. درحالیکه فیلترهای ایمنی قدرتمندی را پیادهسازی میکنیم، این خطر وجود دارد که عامل با صفحههای وب مخرب مواجه شود و آنها را پردازش کند. توصیه میکنیم
citationsارائهشده در پاسخ را برای درستیسنجی منابع مرور کنید. - برونفرستی: اگر به عامل اجازه میدهید در وب مرور کند، هنگام درخواست از او برای خلاصه کردن دادههای داخلی حساس احتیاط کنید.
روالهای مطلوب
- درخواست برای موارد ناشناخته: به عامل آموزش دهید که چگونه دادههای ناقص را مدیریت کند. برای مثال، «اگر ارقام خاصی برای سال ۲۰۲۵ دردسترس نیست، بهجای تخمین زدن، صریحاً بیان کنید که این ارقام پیشبینی هستند یا دردسترس نیستند» را به پیاموارهتان اضافه کنید.
- ارائه بافت: با ارائه اطلاعات پسزمینه یا محدودیتها مستقیماً در پیامواره ورودی، پژوهش نماینده را زمینهسازی کنید.
- استفاده از برنامهریزی مشارکتی: برای پُرسمانهای پیچیده، برنامهریزی مشارکتی را فعال کنید تا طرح پژوهش را قبلاز اجرا مرور و پالایش کنید.
- ورودیهای چندحالته: نماینده Deep Research از ورودیهای چندحالته پشتیبانی میکند. بااحتیاط استفاده کنید، زیرا این کار هزینهها را افزایش میدهد و خطر سرریز شدن پنجره بافت را بههمراه دارد.
محدودیتها
- ابزارهای سفارشی: درحالحاضر نمیتوانید ابزارهای سفارشی «فراخوانی تابع» ارائه دهید اما میتوانید از سرورهای MCP (پروتکل بافتار مدل) از دور با عامل «پژوهش دقیق» استفاده کنید.
- برونداد ساختاریافته: درحالحاضر عامل Deep Research از بروندادهای ساختاریافته پشتیبانی نمیکند.
- حداکثر زمان پژوهش: عامل Deep Research حداکثر ۶۰ دقیقه زمان پژوهش دارد. بیشتر تکلیفها باید ظرف ۲۰ دقیقه تکمیل شوند.
- الزام فروشگاه: اجرای عامل بااستفاده از
background=Trueنیازمندstore=Trueاست. - جستجوی Google: جستجوی Google بهطور پیشفرض فعال است و محدودیتهای خاصی برای نتایج زمینهای اعمال میشود.
قدم بعدی چیست
- درباره میانای برنامهسازی کاربردی تعاملات بیشتر بدانید.
- بااستفاده از ابزار جستجوی فایل، با نحوه استفاده از دادههای خودتان آشنا شوید.