Agjenti i Kërkimeve të Thellë Gemini planifikon, ekzekuton dhe sintetizon në mënyrë autonome detyra kërkimore me shumë hapa. I mundësuar nga Gemini, ai lundron në peizazhe komplekse informacioni për të prodhuar raporte të detajuara dhe të cituara. Aftësitë e reja ju lejojnë të planifikoni në mënyrë bashkëpunuese me agjentin, të lidheni me mjete të jashtme duke përdorur serverat MCP, të përfshini vizualizime (si grafikë dhe grafikë) dhe të ofroni dokumente direkt si të dhëna hyrëse.
Detyrat kërkimore përfshijnë kërkim dhe lexim përsëritës dhe mund të zgjasin disa minuta për t'u përfunduar. Duhet të përdorni ekzekutimin në sfond (set background=true ) për të ekzekutuar agjentin në mënyrë asinkrone dhe për të kërkuar rezultate ose përditësime të rrjedhës. Shihni Trajtimi i detyrave të gjata për më shumë detaje.
Shembulli i mëposhtëm tregon se si të filloni një detyrë kërkimore në sfond dhe të bëni një sondazh për rezultatet.
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.outputs[-1].text)
break
elif interaction.status == "failed":
print(f"Research failed: {interaction.error}")
break
time.sleep(10)
JavaScript
import { GoogleGenAI } from '@google/genai';
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
input: 'Research the history of Google TPUs.',
agent: 'deep-research-preview-04-2026',
background: true
});
console.log(`Research started: ${interaction.id}`);
while (true) {
const result = await client.interactions.get(interaction.id);
if (result.status === 'completed') {
console.log(result.outputs[result.outputs.length - 1].text);
break;
} else if (result.status === 'failed') {
console.log(`Research failed: ${result.error}`);
break;
}
await new Promise(resolve => setTimeout(resolve, 10000));
}
PUSHTIM
# 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"
Versionet e Mbështetura
Agjenti i Kërkimit të Thellë vjen në dy versione:
- Kërkim i Thellë (
deep-research-preview-04-2026): I projektuar për shpejtësi dhe efikasitet, ideal për t'u transmetuar përsëri në një ndërfaqe përdoruesi të klientit. - Deep Research Max (
deep-research-max-preview-04-2026): Gjithëpërfshirje maksimale për mbledhjen dhe sintezën automatike të kontekstit.
Planifikim bashkëpunues
Planifikimi bashkëpunues ju jep kontroll mbi drejtimin e kërkimit përpara se agjenti të fillojë punën e tij. Kur aktivizohet, agjenti kthen një plan kërkimi të propozuar në vend që ta ekzekutojë menjëherë. Pastaj mund ta rishikoni, modifikoni ose miratoni planin përmes ndërveprimeve me shumë kthesa.
Hapi 1: Kërkoni një plan
Cakto collaborative_planning=True në bashkëveprimin e parë. Agjenti kthen një plan kërkimi në vend të një raporti të plotë.
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.outputs[-1].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.outputs[result.outputs.length - 1].text);
PUSHTIM
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
}'
Hapi 2: Përmirësoni planin (opsionale)
Përdorni previous_interaction_id për të vazhduar bisedën dhe për të përsëritur planin. Mbajeni collaborative_planning=True për të qëndruar në modalitetin e planifikimit.
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.outputs[-1].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.outputs[result.outputs.length - 1].text);
PUSHTIM
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
}'
Hapi 3: Miratimi dhe ekzekutimi
Cakto collaborative_planning=False (ose hiqe atë) për të miratuar planin dhe për të filluar kërkimin.
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.outputs[-1].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.outputs[result.outputs.length - 1].text);
PUSHTIM
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
}'
Vizualizimi
Kur visualization është vendosur në "auto" , agjenti mund të gjenerojë grafikë, grafikë dhe elementë të tjerë vizualë për të mbështetur gjetjet e tij të kërkimit. Imazhet e gjeneruara përfshihen në rezultatet e përgjigjeve dhe transmetohen si delta image . Për rezultatet më të mira, kërkoni në mënyrë të qartë pamjet në pyetjen tuaj - për shembull, "Përfshi grafikët që tregojnë trendet me kalimin e kohës" ose "Gjenero grafikë që krahasojnë pjesën e tregut". Vendosja visualization në "auto" aktivizon mundësinë, por agjenti gjeneron pamje vetëm kur kërkesa i kërkon ato.
Python
import base64
from IPython.display import Image, display
interaction = client.interactions.create(
agent="deep-research-preview-04-2026",
input="Analyze global semiconductor market trends. Include graphics showing market share changes.",
agent_config={
"type": "deep-research",
"visualization": "auto",
},
background=True,
)
print(f"Research started: {interaction.id}")
while (result := client.interactions.get(id=interaction.id)).status != "completed":
time.sleep(5)
for output in result.outputs:
if output.type == "text":
print(output.text)
elif output.type == "image" and output.data:
image_bytes = base64.b64decode(output.data)
print(f"Received image: {len(image_bytes)} bytes")
# To display in a Jupyter notebook:
# from IPython.display import display, Image
# display(Image(data=image_bytes))
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 output of result.outputs) {
if (output.type === 'text') {
console.log(output.text);
} else if (output.type === 'image' && output.data) {
console.log(`[Image Output: ${output.data.substring(0, 20)}...]`);
}
}
PUSHTIM
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
}'
Mjetet e mbështetura
Kërkimi i Thellë mbështet mjete të shumta të integruara dhe të jashtme. Si parazgjedhje (kur nuk ofrohet asnjë parametër tools ), agjenti ka qasje në Kërkimin Google, Kontekstin e URL-së dhe Ekzekutimin e Kodit. Ju mund të specifikoni në mënyrë të qartë mjetet për të kufizuar ose zgjeruar aftësitë e agjentit.
| Mjet | Vlera e tipit | Përshkrimi |
|---|---|---|
| Kërkimi në Google | google_search | Kërko në uebin publik. Aktivizuar si parazgjedhje. |
| Konteksti i URL-së | url_context | Lexo dhe përmbledh përmbajtjen e faqes së internetit. Aktivizuar si parazgjedhje. |
| Ekzekutimi i Kodit | code_execution | Ekzekutoni kodin për të kryer llogaritjet dhe analizat e të dhënave. Aktivizuar si parazgjedhje. |
| Serveri MCP | mcp_server | Lidhu me serverat e largët MCP për qasje në mjetet e jashtme. |
| Kërkimi i skedarëve | file_search | Kërko në korpusin e dokumenteve të ngarkuara. |
Kërkimi në Google
Aktivizoni në mënyrë të qartë Kërkimin në Google si mjetin e vetëm:
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
});
PUSHTIM
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
}'
Konteksti i URL-së
Jepini agjentit mundësinë për të lexuar dhe përmbledhur faqe specifike të internetit:
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
});
PUSHTIM
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
}'
Ekzekutimi i Kodit
Lejoni agjentin të ekzekutojë kodin për llogaritjet dhe analizën e të dhënave:
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
});
PUSHTIM
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "deep-research-preview-04-2026",
"input": "Calculate the 50th Fibonacci number.",
"tools": [{"type": "code_execution"}],
"background": true
}'
Serverat MCP
Jepni name e serverit dhe url në në konfigurimin e mjeteve. Gjithashtu mund të kaloni kredencialet e vërtetimit dhe të kufizoni mjetet që agjenti mund të thërrasë.
| Fushë | Lloji | E detyrueshme | Përshkrimi |
|---|---|---|---|
type | string | Po | Duhet të jetë "mcp_server" . |
name | string | Jo | Një emër shfaqës për serverin MCP. |
url | string | Jo | URL-ja e plotë për pikën fundore të serverit MCP. |
headers | object | Jo | Çiftet çelës-vlerë të dërguara si koka HTTP me çdo kërkesë drejtuar serverit (për shembull, tokenët e autentifikimit). |
allowed_tools | array | Jo | Kufizoni cilat mjete nga serveri mund të thirren nga agjenti. |
Përdorimi bazë
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
});
PUSHTIM
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
}'
Kërkimi i skedarëve
Jepini agjentit akses në të dhënat tuaja duke përdorur mjetin e Kërkimit të Skedarëve .
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'] },
]
});
PUSHTIM
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"]},
]
}'
Drejtueshmëria dhe formatimi
Mund ta drejtoni rezultatin e agjentit duke dhënë udhëzime specifike formatimi në njoftimin tuaj. Kjo ju lejon të strukturoni raportet në seksione dhe nënseksione specifike, të përfshini tabela të dhënash ose të përshtatni tonin për audienca të ndryshme (p.sh., "teknik", "ekzekutiv", "i rastësishëm").
Përcaktoni formatin e dëshiruar të daljes në mënyrë të qartë në tekstin tuaj të hyrjes.
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,
});
PUSHTIM
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
}'
Hyrjet multimodale
Kërkimi i Thellë mbështet të dhëna multimodale, duke përfshirë imazhe dhe dokumente (PDF), duke i lejuar agjentit të analizojë përmbajtjen vizuale dhe të kryejë kërkime në internet të kontekstualizuara nga të dhënat e dhëna.
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",
"uri": "https://storage.googleapis.com/generativeai-downloads/images/generated_elephants_giraffes_zebras_sunset.jpg"
}
],
agent="deep-research-preview-04-2026",
background=True
)
print(f"Research started: {interaction.id}")
while True:
interaction = client.interactions.get(interaction.id)
if interaction.status == "completed":
print(interaction.outputs[-1].text)
break
elif interaction.status == "failed":
print(f"Research failed: {interaction.error}")
break
time.sleep(10)
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',
uri: 'https://storage.googleapis.com/generativeai-downloads/images/generated_elephants_giraffes_zebras_sunset.jpg'
}
],
agent: 'deep-research-preview-04-2026',
background: true
});
console.log(`Research started: ${interaction.id}`);
while (true) {
const result = await client.interactions.get(interaction.id);
if (result.status === 'completed') {
console.log(result.outputs[result.outputs.length - 1].text);
break;
} else if (result.status === 'failed') {
console.log(`Research failed: ${result.error}`);
break;
}
await new Promise(resolve => setTimeout(resolve, 10000));
}
PUSHTIM
# 1. Start the research task with image input
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"input": [
{"type": "text", "text": "Analyze the interspecies dynamics and behavioral risks present in the provided image of the African watering hole. Specifically, investigate the symbiotic relationship between the avian species and the pachyderms shown, and conduct a risk assessment for the reticulated giraffes based on their drinking posture relative to the specific predator visible in the foreground."},
{"type": "image", "uri": "https://storage.googleapis.com/generativeai-downloads/images/generated_elephants_giraffes_zebras_sunset.jpg"}
],
"agent": "deep-research-preview-04-2026",
"background": true
}'
# 2. Poll for results (Replace INTERACTION_ID)
# curl -X GET "https://generativelanguage.googleapis.com/v1beta/interactions/INTERACTION_ID" \
# -H "x-goog-api-key: $GEMINI_API_KEY"
Kuptimi i dokumentit
Kaloni dokumentet direkt si të dhëna multimodale. Agjenti analizon dokumentet e dhëna dhe kryen kërkime të bazuara në përmbajtjen e tyre.
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
});
PUSHTIM
# 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
}'
Trajtimi i detyrave afatgjata
Kërkimi i Thellë është një proces me shumë hapa që përfshin planifikimin, kërkimin, leximin dhe shkrimin. Ky cikël zakonisht tejkalon limitet standarde të kohës së skadimit të thirrjeve sinkrone të API-t.
Agjentët duhet të përdorin background=True . API kthen menjëherë një objekt të pjesshëm Interaction . Mund të përdorni vetinë id për të marrë një ndërveprim për anketim. Gjendja e ndërveprimit do të kalojë nga in_progress në completed ose failed .
Transmetim
Kërkimi i Thellë mbështet transmetimin në kohë reale për të marrë përditësime mbi progresin e kërkimit, duke përfshirë përmbledhjet e mendimeve, tekstin e prodhuar dhe imazhet e gjeneruara. Duhet të vendosni stream=True dhe background=True .
Për të marrë hapa të ndërmjetëm arsyetimi (mendime) dhe përditësime të progresit, duhet të aktivizoni përmbledhjet e të menduarit duke vendosur thinking_summaries në "auto" në agent_config . Pa këtë, transmetimi mund të ofrojë vetëm rezultatet përfundimtare.
Llojet e ngjarjeve të transmetimit
| Lloji i ngjarjes | Lloji delta | Përshkrimi |
|---|---|---|
content.delta | thought_summary | Hapi i ndërmjetëm i arsyetimit nga agjenti. |
content.delta | text | Pjesë e tekstit përfundimtar të rezultatit. |
content.delta | image | Një imazh i gjeneruar (i koduar me base64). |
Shembulli i mëposhtëm nis një detyrë kërkimore dhe përpunon transmetimin me rilidhje automatike. Ai gjurmon interaction_id dhe last_event_id në mënyrë që nëse lidhja ndërpritet (për shembull, pas skadimit prej 600 sekondash), ajo të mund të rifillojë nga vendi ku u ndërpre.
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 chunk in stream:
if chunk.event_type == "interaction.start":
interaction_id = chunk.interaction.id
if chunk.event_id:
last_event_id = chunk.event_id
if chunk.event_type == "content.delta":
if chunk.delta.type == "text":
print(chunk.delta.text, end="", flush=True)
elif chunk.delta.type == "thought_summary":
print(f"Thought: {chunk.delta.content.text}", flush=True)
elif chunk.event_type in ("interaction.complete", "error"):
is_complete = True
stream = client.interactions.create(
input="Research the history of Google TPUs.",
agent="deep-research-preview-04-2026",
background=True,
stream=True,
agent_config={"type": "deep-research", "thinking_summaries": "auto"},
)
process_stream(stream)
# Reconnect if the connection drops
while not is_complete and interaction_id:
status = client.interactions.get(interaction_id)
if status.status != "in_progress":
break
stream = client.interactions.get(
id=interaction_id, stream=True, last_event_id=last_event_id,
)
process_stream(stream)
JavaScript
import { GoogleGenAI } from '@google/genai';
const client = new GoogleGenAI({});
let interactionId;
let lastEventId;
let isComplete = false;
async function processStream(stream) {
for await (const chunk of stream) {
if (chunk.event_type === 'interaction.start') {
interactionId = chunk.interaction.id;
}
if (chunk.event_id) lastEventId = chunk.event_id;
if (chunk.event_type === 'content.delta') {
if (chunk.delta.type === 'text') {
process.stdout.write(chunk.delta.text);
} else if (chunk.delta.type === 'thought_summary') {
console.log(`Thought: ${chunk.delta.content.text}`);
}
} else if (['interaction.complete', 'error'].includes(chunk.event_type)) {
isComplete = true;
}
}
}
const stream = await client.interactions.create({
input: 'Research the history of Google TPUs.',
agent: 'deep-research-preview-04-2026',
background: true,
stream: true,
agent_config: { type: 'deep-research', thinking_summaries: 'auto' },
});
await processStream(stream);
// Reconnect if the connection drops
while (!isComplete && interactionId) {
const status = await client.interactions.get(interactionId);
if (status.status !== 'in_progress') break;
const resumeStream = await client.interactions.get(interactionId, {
stream: true, last_event_id: lastEventId,
});
await processStream(resumeStream);
}
PUSHTIM
# 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"
Pyetje dhe ndërveprime pasuese
Mund ta vazhdoni bisedën pasi agjenti të kthejë raportin përfundimtar duke përdorur previous_interaction_id . Kjo ju lejon të kërkoni sqarime, përmbledhje ose hollësi mbi pjesë specifike të hulumtimit pa e rinisur të gjithë detyrën.
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.outputs[-1].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.outputs[interaction.outputs.length - 1].text);
PUSHTIM
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"
}'
Kur duhet të përdoret Agjenti i Kërkimeve të Thellë Gemini
Kërkimi i Thellë është një agjent , jo vetëm një model. Është më i përshtatshmi për ngarkesat e punës që kërkojnë një qasje "analist-në-kuti" në vend të bisedave me vonesë të ulët.
| Karakteristikë | Modelet Standarde të Binjakëve | Agjent i Kërkimeve të Thellë Gemini |
|---|---|---|
| Latencia | Sekonda | Minuta (Asinkron/Sfond) |
| Procesi | Gjenero -> Dalje | Plan -> Kërko -> Lexo -> Itero -> Dalje |
| Prodhimi | Tekst bisedor, kod, përmbledhje të shkurtra | Raporte të hollësishme, analiza të gjata, tabela krahasuese |
| Më e mira për | Chatbot, nxjerrje, shkrim krijues | Analiza e tregut, kujdesi i duhur, rishikimet e literaturës, peizazhi konkurrues |
Konfigurimi i agjentit
Deep Research përdor parametrin agent_config për të kontrolluar sjelljen. Kalojeni atë si fjalor me fushat e mëposhtme:
| Fushë | Lloji | Parazgjedhur | Përshkrimi |
|---|---|---|---|
type | string | E detyrueshme | Duhet të jetë "deep-research" . |
thinking_summaries | string | "none" | Vendos në "auto" për të marrë hapa të ndërmjetëm arsyetimi gjatë transmetimit. Vendos në "none" për ta çaktivizuar. |
visualization | string | "auto" | Caktoje në "auto" për të aktivizuar grafikët dhe imazhet e gjeneruara nga agjentët. Caktoje në "off" për t'i çaktivizuar. |
collaborative_planning | boolean | false | Vendoseni në true për të aktivizuar shqyrtimin e planit me shumë kthesa përpara se të fillojë kërkimi. |
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,
});
PUSHTIM
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
}'
Disponueshmëria dhe çmimet
Mund të qaseni në Agjentin e Kërkimit të Thellë Gemini duke përdorur API-në e Ndërveprimeve në Google AI Studio dhe API-në e Gemini.
Çmimi ndjek një model "paguaj sipas përdorimit" bazuar në modelet themelore Gemini dhe mjetet specifike që përdor agjenti. Ndryshe nga kërkesat standarde të bisedës, ku një kërkesë çon në një rezultat, një detyrë e Kërkimit të Thellë është një rrjedhë pune agjentike. Një kërkesë e vetme shkakton një cikël autonom planifikimi, kërkimi, leximi dhe arsyetimi.
Kostot e vlerësuara
Kostot ndryshojnë në varësi të thellësisë së kërkimit të kërkuar. Agjenti përcakton në mënyrë autonome se sa lexim dhe kërkim është i nevojshëm për t'iu përgjigjur kërkesës suaj.
- Kërkime të Thella (
deep-research-preview-04-2026): Për një pyetje tipike që kërkon analizë të moderuar, agjenti mund të përdorë ~80 pyetje kërkimi, ~250 mijë tokenë hyrës (~50-70% të ruajtur në memorien e përkohshme) dhe ~60 mijë tokenë dalës.- Totali i vlerësuar: ~$1.00 – $3.00 për detyrë
- Deep Research Max (
deep-research-max-preview-04-2026): Për analizë të thellë të peizazhit konkurrues ose për verifikim të hollësishëm, agjenti mund të përdorë deri në ~160 pyetje kërkimi, ~900 mijë tokenë hyrës (~50-70% të ruajtur në memorje) dhe ~80 mijë tokenë dalës.- Totali i vlerësuar: ~$3.00 – $7.00 për detyrë
Konsideratat e sigurisë
Dhënia e aksesit në internet dhe në skedarët tuaj privatë një agjenti kërkon shqyrtim të kujdesshëm të rreziqeve të sigurisë.
- Injeksion i menjëhershëm duke përdorur skedarë: Agjenti lexon përmbajtjen e skedarëve që jepni. Sigurohuni që dokumentet e ngarkuara (PDF, skedarë teksti) vijnë nga burime të besueshme. Një skedar keqdashës mund të përmbajë tekst të fshehur të projektuar për të manipuluar rezultatin e agjentit.
- Rreziqet e përmbajtjes së uebit: Agjenti kërkon në uebin publik. Ndërsa ne zbatojmë filtra të fuqishëm sigurie, ekziston rreziku që agjenti të hasë dhe të përpunojë faqe uebi me qëllim të keq. Ne rekomandojmë të rishikoni
citationse dhëna në përgjigje për të verifikuar burimet. - Ekfiltrimi: Kini kujdes kur i kërkoni agjentit të përmbledhë të dhëna të brendshme të ndjeshme nëse po e lejoni edhe atë të shfletojë uebin.
Praktikat më të mira
- Njoftim për të panjohurat: Udhëzoni agjentin se si të trajtojë të dhënat që mungojnë. Për shembull, shtoni në njoftimin tuaj "Nëse shifra specifike për vitin 2025 nuk janë të disponueshme, deklaroni qartë se ato janë parashikime ose të padisponueshme në vend të vlerësimeve" .
- Jepni kontekst: Bazoni kërkimin e agjentit duke dhënë informacion mbi sfondin ose kufizimet direkt në kërkesën e të dhënave hyrëse.
- Përdorni planifikim bashkëpunues: Për pyetje komplekse, aktivizoni planifikimin bashkëpunues për të shqyrtuar dhe rafinuar planin e kërkimit para ekzekutimit.
- Hyrjet multimodale: Agjenti i Kërkimit të Thellë mbështet hyrjet multimodale. Përdoreni me kujdes, pasi kjo rrit kostot dhe rrezikon tejmbushjen e dritares së kontekstit.
Kufizime
- Statusi Beta : API-ja e Ndërveprimeve është në beta publike. Karakteristikat dhe skemat mund të ndryshojnë.
- Mjete të personalizuara: Aktualisht nuk mund të ofroni mjete të personalizuara për Thirrjen e Funksioneve, por mund të përdorni serverë të largët MCP (Protokolli i Kontekstit të Modelit) me agjentin e Kërkimit të Thellë.
- Prodhimi i strukturuar: Agjenti i Kërkimit të Thellë aktualisht nuk mbështet rezultatet e strukturuara.
- Koha maksimale e kërkimit: Agjenti i Kërkimit të Thellë ka një kohë maksimale kërkimi prej 60 minutash. Shumica e detyrave duhet të përfundojnë brenda 20 minutash.
- Kërkesa për ruajtje: Ekzekutimi i agjentit duke përdorur
background=Truekërkonstore=True. - Kërkimi në Google: Kërkimi në Google është aktivizuar si parazgjedhje dhe zbatohen kufizime specifike për rezultatet e bazuara.
Çfarë vjen më pas
- Mësoni më shumë rreth API-t të Ndërveprimeve .
- Provoni Kërkimin e Thellë në Librin e Gatimit të Gemini API .
- Mësoni si të përdorni të dhënat tuaja duke përdorur mjetin e Kërkimit të Skedarëve .