סוכן Deep Research של Gemini מתכנן, מבצע ומסכם באופן אוטונומי משימות מחקר מרובות שלבים. הוא מבוסס על 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));
}
Java
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);
}
REST
# 1. Start the research task
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"input": "Research the history of Google TPUs.",
"agent": "deep-research-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): מקיף ביותר לאיסוף ולסינתזה אוטומטיים של הקשר.
תכנון משותף
תכנון שיתופי מאפשר לכם לשלוט בכיוון המחקר לפני שהסוכן מתחיל לעבוד. אתם יכולים לבדוק ולשפר את תוכנית המחקר לפני הביצוע. כשהתכונה מופעלת, הסוכן מחזיר תוכנית מחקר מוצעת במקום לבצע אותה באופן מיידי. לאחר מכן תוכלו לבדוק, לשנות או לאשר את התוכנית באמצעות אינטראקציות רב-שלביות.
שלב 1: שליחת בקשה לתוכנית
מגדירים את 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);
Java
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(""));
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": "Do some research on Google TPUs.",
"agent_config": {
"type": "deep-research",
"thinking_summaries": "auto",
"collaborative_planning": true
},
"background": true
}'
שלב 2: שיפור התוכנית (אופציונלי)
כדי להמשיך את השיחה ולשפר את התוכנית, אפשר להשתמש ב-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);
Java
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(""));
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": "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
}'
שלב 3: אישור וביצוע
מגדירים את הערך 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);
Java
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(""));
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)}...]`);
}
}
}
}
Java
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");
}
}
}
}
}
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, ל-URL Context ולביצוע קוד. אתם יכולים לציין במפורש כלים כדי להגביל את היכולות של הסוכן או להרחיב אותן.
| כלי | הקלדת ערך | תיאור |
|---|---|---|
| חיפוש Google | google_search |
חיפוש באינטרנט הציבורי. ההגדרה הזו מופעלת כברירת מחדל. |
| URL Context | 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
});
Java
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();
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": "What are the latest developments in quantum computing?",
"tools": [{"type": "google_search"}],
"background": true
}'
URL Context
לתת לסוכן את היכולת לקרוא ולסכם דפי אינטרנט ספציפיים:
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
});
Java
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();
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
});
Java
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();
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": "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 |
לא | כתובת ה-URL המלאה של נקודת הקצה של שרת ה-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
});
Java
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();
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": "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'] },
]
});
Java
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();
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"input": "Compare our 2025 fiscal year report against current public web news.",
"agent": "deep-research-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,
});
Java
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();
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"input": "Research the competitive landscape of EV batteries.\n\nFormat the output as a technical report with the following structure: \n1. Executive Summary\n2. Key Players (Must include a data table comparing capacity and chemistry)\n3. Supply Chain Risks",
"agent": "deep-research-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));
}
Java
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);
}
REST
# 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
});
Java
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();
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. ה-API מחזיר אובייקט Interaction חלקי באופן מיידי. אפשר להשתמש במאפיין id כדי לאחזר אינטראקציה לצורך בדיקה. מצב האינטראקציה ישתנה מin_progress לcompleted או לfailed. מדריך מקיף לניהול משימות ברקע זמין במאמר הפעלה ברקע.
סטרימינג
התכונה Deep Research תומכת בסטרימינג כדי לקבל עדכונים בזמן אמת על התקדמות המחקר, כולל סיכומי מחשבות, פלט טקסט ותמונות שנוצרו.
צריך להגדיר את stream=True ואת background=True.
כדי לקבל שלבי חשיבה רציונלית (מחשבות) ועדכוני התקדמות, צריך להפעיל סיכומי חשיבה על ידי הגדרת thinking_summaries לערך "auto" ב-agent_config. בלי זה, יכול להיות שהזרם יספק רק את התוצאות הסופיות.
סוגי אירועים של מקור נתונים
| סוג אירוע | סוג הדלתא | תיאור |
|---|---|---|
step.delta |
thought |
שלב ביניים של חשיבה רציונלית של הסוכן. |
step.delta |
text |
חלק מפלט הטקסט הסופי. |
step.delta |
image |
תמונה שנוצרה (בקידוד Base64). |
בדוגמה הבאה מתחילים משימת מחקר ומעבדים את הסטרימינג עם חיבור מחדש אוטומטי. הוא עוקב אחרי interaction_id ו-last_event_id, כך שאם החיבור ייפסק (לדוגמה, אחרי זמן קצוב לתפוגה של 600 שניות), הוא יוכל להמשיך מהמקום שבו הוא הפסיק.
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);
}
Java
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);
}
}
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-3.1-pro-preview",
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-3.1-pro-preview',
previous_interaction_id: 'COMPLETED_INTERACTION_ID'
});
console.log(interaction.steps.at(-1).content[0].text);
Java
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-3.1-pro-preview")
.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(""));
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-3.1-pro-preview",
"previous_interaction_id": "COMPLETED_INTERACTION_ID"
}'
מתי כדאי להשתמש ב-Gemini Deep Research agent
Deep Research הוא סוכן, לא רק מודל. היא מתאימה במיוחד לעומסי עבודה שדורשים גישה של "אנליסט בקופסה" ולא צ'אט עם זמן אחזור נמוך.
| תכונה | מודלים רגילים של Gemini | סוכן Deep Research ב-Gemini |
|---|---|---|
| זמן אחזור | שניות | דקות (אסינכרוני/ברקע) |
| Process | יצירה -> פלט | תכנון -> חיפוש -> קריאה -> חזרה על הפעולה -> פלט |
| פלט | טקסט שיחה, קוד, סיכומים קצרים | דוחות מפורטים, ניתוח ארוך, טבלאות השוואה |
| מתאים במיוחד עבור | צ'אטבוטים, חילוץ, כתיבה יוצרת | ניתוח שוק, בדיקת נאותות, סקירת ספרות, ניתוח מצב התחרות |
הגדרת הסוכן
הפרמטר agent_config משמש לשליטה בהתנהגות של Deep Research.
מעבירים אותו כמילון עם השדות הבאים:
| שדה | סוג | ברירת מחדל | תיאור |
|---|---|---|---|
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,
});
Java
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();
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
}'
זמינות ומחירים
אפשר לגשת לסוכן Deep Research ל-Gemini באמצעות Interactions API ב-Google AI Studio וב-Gemini API.
התמחור מבוסס על מודל של תשלום לפי שימוש, בהתאם למודלים הבסיסיים של Gemini ולכלים הספציפיים שבהם הסוכן משתמש. בניגוד לבקשות רגילות בצ'אט, שבהן בקשה מובילה לפלט אחד, משימה של Deep Research היא תהליך עבודה של AI אקטיבי. בקשה אחת מפעילה לולאה אוטונומית של תכנון, חיפוש, קריאה והסקת מסקנות.
עלויות משוערות
העלויות משתנות בהתאם לעומק המחקר הנדרש. הסוכן קובע באופן אוטונומי כמה קריאה וחיפוש נדרשים כדי לענות על ההנחיה.
- Deep Research (
deep-research-preview-04-2026): בשאילתה טיפוסית שדורשת ניתוח מתון, יכול להיות שהסוכן ישתמש בכ-80 שאילתות חיפוש, בכ-250,000 טוקנים של קלט (כ-50-70% במטמון) ובכ-60,000 טוקנים של פלט.- סך הכול משוער: כ-4 ש"ח עד 12 ש"ח לכל משימה
- Deep Research Max (
deep-research-max-preview-04-2026): לניתוח מעמיק של הסביבה התחרותית או לבדיקת נאותות מקיפה, יכול להיות שהסוכן ישתמש בעד 160 שאילתות חיפוש, עד 900,000 טוקנים של קלט (כ-50-70% במטמון) ועד 80,000 טוקנים של פלט.- סכום משוער כולל: כ-3.00$עד 7.00$ לכל משימה
שיקולי בטיחות
כדי לתת לסוכן גישה לאינטרנט ולקבצים הפרטיים שלכם, צריך לשקול היטב את סיכוני הבטיחות.
- החדרת פרומפטים באמצעות קבצים: הסוכן קורא את התוכן של הקבצים שאתם מספקים. חשוב לוודא שהמסמכים שהועלו (קובצי PDF, קובצי טקסט) מגיעים ממקורות מהימנים. קובץ זדוני יכול להכיל טקסט מוסתר שנועד לתמרן את הפלט של הסוכן.
- סיכונים בתוכן אינטרנט: הסוכן מחפש באינטרנט הציבורי. אנחנו מטמיעים מסנני בטיחות חזקים, אבל קיים סיכון שהסוכן ייתקל בדפי אינטרנט זדוניים ויעבד אותם. מומלץ לעיין ב
citationsשצוינו בתשובה כדי לאמת את המקורות. - העברת נתונים: חשוב לנקוט משנה זהירות כשמבקשים מהסוכן לסכם נתונים פנימיים רגישים אם מאפשרים לו גם לגלוש באינטרנט.
שיטות מומלצות
- הנחיה לגבי נתונים לא ידועים: מגדירים לסוכן איך לטפל בנתונים חסרים. לדוגמה, אפשר להוסיף את ההנחיה "אם נתונים ספציפיים לשנת 2025 לא זמינים, ציין במפורש שהם תחזיות או לא זמינים, במקום להעריך".
- מספקים הקשר: כדי שהסוכן יתמקד במחקר, כדאי לספק מידע רקע או מגבלות ישירות בפרומפט הקלט.
- שימוש בתכנון שיתופי: בשאילתות מורכבות, מומלץ להפעיל תכנון שיתופי כדי לבדוק ולשפר את תוכנית המחקר לפני הביצוע.
- Multimodal inputs: סוכן Deep Research תומך בקלט מרובה מצבים. צריך להשתמש בזה בזהירות, כי זה מגדיל את העלויות ואת הסיכון לחריגה מחלון ההקשר.
מגבלות
- כלים בהתאמה אישית: נכון לעכשיו, אי אפשר לספק כלים מותאמים אישית של קריאה להפעלת פונקציות, אבל אפשר להשתמש בשרתי MCP (Model Context Protocol) מרוחקים עם סוכן Deep Research.
- פלט מובנה: בשלב הזה, Deep Research לא תומך בפלט מובנה.
- זמן המחקר המקסימלי: לסוכן Deep Research יש זמן מחקר מקסימלי של 60 דקות. רוב המשימות אמורות להסתיים תוך 20 דקות.
- דרישה של החנות: כדי להריץ את הסוכן באמצעות
background=True, צריךstore=True. - חיפוש Google: חיפוש Google מופעל כברירת מחדל, והגבלות ספציפיות חלות על התוצאות המבוססות על מידע.