סוכן Antigravity הוא סוכן מנוהל לשימוש כללי ב-Gemini API. קריאה אחת ל-API מספקת לכם סוכן שמבצע ניתוח, מריץ קוד, מנהל קבצים ומחפש באינטרנט בתוך ארגז חול מאובטח של Linux, שמתארח ב-Google.
הוא מבוסס על Gemini 3.8 Flash ומשתמש באותו מנגנון כמו Antigravity IDE. אפשר להגדיר את מודל Gemini הבסיסי באמצעות agent_config. אפשר לגשת אליהם דרך Interactions API ו-Google AI Studio.
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
input="Read Hacker News, summarize the top 10 stories, and save the results as a PDF.",
environment="remote",
)
print(interaction.output_text)
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "Read Hacker News, summarize the top 10 stories, and save the results as a PDF.",
environment: "remote",
}, { timeout: 300000 });
console.log(interaction.output_text);
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
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();
CreateAgentInteraction params = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("Read Hacker News, summarize the top 10 stories, and save the results as a PDF."))
.environment(CreateAgentInteractionEnvironment.of("remote"))
.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 '{
"agent": "antigravity-preview-09-2026",
"input": "Read Hacker News, summarize the top 10 stories, and save the results as a PDF.",
"environment": "remote"
}'
יכולות
כל שיחה יכולה להקצות ארגז חול של Linux ולהתחיל לולאה של שימוש בכלי. הסוכן מתכנן, פועל, בודק את התוצאות וחוזר על הפעולות עד שהמשימה מסתיימת.
- הרצת קוד: הרצת פקודות Bash, Python ו-Node.js. להתקין חבילות, להריץ בדיקות ולפתח אפליקציות.
- ניהול קבצים: קריאה, כתיבה, עריכה, חיפוש ורישום של קבצים בארגז החול. הקבצים נשמרים בין האינטראקציות.
- גישה לאינטרנט: חיפוש ב-Google ואחזור כתובות URL של נתונים.
- דחיסת הקשר: דחיסת הקשר אוטומטית (מופעלת בערך ב-135, 000 טוקנים) כדי לתמוך בסשנים ארוכים ורב-שלביים בלי לאבד את ההקשר או להגיע למגבלות הטוקנים.
במאמר מדריך למתחילים מוסבר איך להשתמש בסטרימינג ובשימוש רב-שלבי.
כלים נתמכים
כברירת מחדל, לסוכן יש גישה אל code_execution, google_search ו-url_context. הכלים של מערכת הקבצים מופעלים באופן אוטומטי כשמציינים את הפרמטר environment. אפשר גם להגדיר פונקציות בהתאמה אישית כדי לחבר את הסוכן לממשקי API ולכלים שלכם. צריך לציין את הפרמטר tools רק כשמתאימים אישית את קבוצת ברירת המחדל או מגבילים אותה, או כשמוסיפים פונקציות מותאמות אישית.
| כלי | הקלדת ערך | תיאור |
|---|---|---|
| הרצת קוד | code_execution |
הרצת פקודות של מעטפת (bash, Python, Node) עם לכידה של stdout/stderr. |
| חיפוש Google | google_search |
חיפוש באינטרנט הציבורי. |
| URL Context | url_context |
אחזור וקריאה של דפי אינטרנט. |
| מערכת קבצים | (הופעל באמצעות environment) |
קריאה, כתיבה, עריכה, חיפוש ורישום של קבצים בסביבת הארגז. המערכת מפעילה את הכלים האלה באופן אוטומטי כשמגדירים את environment. |
| פונקציות מותאמות אישית | function |
הגדרת פונקציות בהתאמה אישית שהסוכן יכול לבקש להפעיל. מידע נוסף על בקשה להפעלת פונקציה |
| שרת MCP מרוחק | mcp_server |
רישום שרתים חיצוניים של Model Context Protocol (MCP) ככלים. מידע נוסף מופיע בקטע שרתי MCP. |
אתם יכולים ליירט ולאמת את ההרצה של כלי code_execution ו-filesystem ישירות בארגז החול המרוחק באמצעות ווים סינכרוניים.
כדי להגביל את הסוכן לכלים ספציפיים, מעבירים רק את הכלים שצריך:
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
input="Search for the latest AI research papers on reasoning and summarize them.",
environment="remote",
tools=[
{"type": "google_search"},
{"type": "url_context"},
],
)
print(interaction.output_text)
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "Search for the latest AI research papers on reasoning and summarize them.",
environment: "remote",
tools: [
{ type: "google_search" },
{ type: "url_context" },
],
}, { timeout: 300000 });
console.log(interaction.output_text);
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
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.interactions.URLContext;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.List;
Client client = new Client();
CreateAgentInteraction params = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("Search for the latest AI research papers on reasoning and summarize them."))
.environment(CreateAgentInteractionEnvironment.of("remote"))
.tools(List.of(
GoogleSearch.builder().build(),
URLContext.builder().build()
))
.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 '{
"agent": "antigravity-preview-09-2026",
"input": "Search for the latest AI research papers on reasoning and summarize them.",
"environment": "remote",
"tools": [
{"type": "google_search"},
{"type": "url_context"}
]
}'
קלט מרובה מצבים
הסוכן Antigravity תומך בקלט רב-אופני. בשלב הזה יש תמיכה רק בקלט בשפות text וimage. צריך לספק את התמונות כמחרוזות מוטבעות בקידוד Base64 (data).
Python
import base64
from google import genai
client = genai.Client()
with open("path/to/chart.png", "rb") as f:
image_bytes = f.read()
interaction_inline = client.interactions.create(
agent="antigravity-preview-09-2026",
input=[
{"type": "text", "text": "Analyze this chart and summarize the trends."},
{
"type": "image",
"data": base64.b64encode(image_bytes).decode("utf-8"),
"mime_type": "image/png",
},
],
environment="remote",
)
JavaScript
import { GoogleGenAI } from "@google/genai";
import * as fs from "node:fs";
const client = new GoogleGenAI({});
const base64Image = fs.readFileSync("path/to/chart.png", { encoding: "base64" });
const interactionInline = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: [
{ type: "text", text: "Analyze this chart and summarize the trends." },
{
type: "image",
data: base64Image,
mime_type: "image/png",
},
],
environment: "remote",
}, { timeout: 300000 });
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
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.InteractionsInput;
import com.google.genai.gaos.models.interactions.TextContent;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Base64;
import java.util.List;
Client client = new Client();
byte[] imageBytes = Files.readAllBytes(Paths.get("path/to/chart.png"));
String base64Image = Base64.getEncoder().encodeToString(imageBytes);
CreateAgentInteraction params = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.ofContent(List.of(
TextContent.builder().text("Analyze this chart and summarize the trends.").build(),
ImageContent.builder()
.data(base64Image)
.mimeType(ImageContentMimeType.IMAGE_PNG)
.build()
)))
.environment(CreateAgentInteractionEnvironment.of("remote"))
.build();
Interaction interactionInline = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
System.out.println(interactionInline.outputText().orElse(""));
REST
BASE64_IMAGE=$(base64 -w0 /path/to/chart.png)
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d "{
\"agent\": \"antigravity-preview-09-2026\",
\"input\": [
{\"type\": \"text\", \"text\": \"Analyze this chart and summarize the trends.\"},
{
\"type\": \"image\",
\"mime_type\": \"image/png\",
\"data\": \"$BASE64_IMAGE\"
}
],
\"environment\": \"remote\"
}"
בקשה להפעלת פונקציה
התכונה 'הפעלת פונקציות' מאפשרת לכם לחבר את סוכן Antigravity לממשקי API ולמסדי נתונים חיצוניים על ידי הגדרת כלים מותאמים אישית שהסוכן יכול להפעיל. למידע על מושגים כלליים, אפשר לעיין במאמר בקשות להפעלת פונקציות באמצעות Gemini API.
בדוגמה הבאה מוצגת אינטראקציה של 2 תורות. הסוכן מבקש קודם קריאה לפונקציה מותאמת אישית get_weather, והלקוח מבצע אותה ומחזיר את התוצאה בתור השני.
Python
from google import genai
client = genai.Client()
# 1. Define the custom function
get_weather_tool = {
"type": "function",
"name": "get_weather",
"description": "Gets the current weather for a given location.",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and country, e.g. San Francisco, USA",
}
},
"required": ["location"],
},
}
# 2. Call the agent with the custom tool (Turn 1)
interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
input="What is the weather in Tokyo?",
environment="remote",
tools=[
{"type": "code_execution"}, # Enable default code execution
get_weather_tool, # Add custom function
],
)
# Check if the agent requested a function call
if interaction.status == "requires_action":
# Find function calls that do not have a matching function result.
# Filesystem tools (like write_to_file) are also represented as function calls
# but are executed automatically by the environment.
executed_calls = {step.call_id for step in interaction.steps if step.type == "function_result"}
pending_calls = [step for step in interaction.steps if step.type == "function_call" and step.id not in executed_calls]
if pending_calls:
fc_step = pending_calls[0]
print(f"Function to call: {fc_step.name} (ID: {fc_step.id})")
print(f"Arguments: {fc_step.arguments}")
# 3. Execute the function locally (simulated get_weather()) and send the result back (Turn 2)
function_result = {
"temperature": 23,
"unit": "celsius"
}
final_interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
previous_interaction_id=interaction.id, # Reference the interaction ID
environment=interaction.environment_id,
input=[
{
"type": "function_result",
"name": fc_step.name,
"call_id": fc_step.id,
"result": function_result,
}
],
)
print(final_interaction.output_text)
# Output: The current weather in Tokyo, Japan is 23°C (Celsius).
else:
print("No pending function calls.")
else:
print(f"Interaction completed with status: {interaction.status}")
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
// 1. Define the custom function
const get_weather_tool = {
type: "function",
name: "get_weather",
description: "Gets the current weather for a given location.",
parameters: {
type: "object",
properties: {
location: {
type: "string",
description: "The city and country, e.g. San Francisco, USA",
},
},
required: ["location"],
},
};
// 2. Call the agent with the custom tool (Turn 1)
const interaction = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "What is the weather in Tokyo?",
environment: "remote",
tools: [
{ type: "code_execution" },
get_weather_tool,
],
}, { timeout: 300000 });
if (interaction.status === "requires_action") {
// Find function calls that do not have a matching function result.
// Filesystem tools (like write_to_file) are also represented as function calls
// but are executed automatically by the environment.
const executedCalls = new Set(
interaction.steps
.filter(s => s.type === "function_result")
.map(s => s.call_id)
);
const pendingCalls = interaction.steps.filter(
s => s.type === "function_call" && !executedCalls.has(s.id)
);
if (pendingCalls.length > 0) {
const fcStep = pendingCalls[0];
console.log(`Function to call: ${fcStep.name} (ID: ${fcStep.id})`);
// 3. Execute the function locally (simulated get_weather()) and send the result back (Turn 2)
const functionResult = {
temperature: 23,
unit: "celsius"
};
const finalInteraction = await client.interactions.create({
agent: "antigravity-preview-09-2026",
previous_interaction_id: interaction.id, // Reference the interaction ID
environment: interaction.environment_id,
input: [
{
type: "function_result",
name: fcStep.name,
call_id: fcStep.id,
result: functionResult,
}
],
}, { timeout: 300000 });
console.log(finalInteraction.output_text);
} else {
console.log("No pending function calls.");
}
} else {
console.log(`Interaction completed with status: ${interaction.status}`);
}
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.CodeExecution;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
import com.google.genai.gaos.models.interactions.Function;
import com.google.genai.gaos.models.interactions.FunctionCallStep;
import com.google.genai.gaos.models.interactions.FunctionResultStep;
import com.google.genai.gaos.models.interactions.FunctionResultStepResultUnion;
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.Step;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
Client client = new Client();
// 1. Define the custom function
Function getWeatherTool = Function.builder()
.name("get_weather")
.description("Gets the current weather for a given location.")
.parameters(Map.of(
"type", "object",
"properties", Map.of(
"location", Map.of(
"type", "string",
"description", "The city and country, e.g. San Francisco, USA"
)
),
"required", List.of("location")
))
.build();
// 2. Call the agent with the custom tool (Turn 1)
CreateAgentInteraction params = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("What is the weather in Tokyo?"))
.environment(CreateAgentInteractionEnvironment.of("remote"))
.tools(List.of(
CodeExecution.builder().build(), // Enable default code execution
getWeatherTool // Add custom function
))
.build();
Interaction interaction = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
// Check if the agent requested a function call
if (interaction.status().orElse(null) == InteractionStatus.REQUIRES_ACTION) {
// Find function calls that do not have a matching function result.
List<Step> steps = interaction.steps().orElse(List.of());
Set<String> executedCalls = steps.stream()
.filter(step -> step instanceof FunctionResultStep)
.map(step -> ((FunctionResultStep) step).callId().orElse(""))
.collect(Collectors.toSet());
List<FunctionCallStep> pendingCalls = steps.stream()
.filter(step -> step instanceof FunctionCallStep)
.map(step -> (FunctionCallStep) step)
.filter(fc -> !executedCalls.contains(fc.id().orElse("")))
.collect(Collectors.toList());
if (!pendingCalls.isEmpty()) {
FunctionCallStep fcStep = pendingCalls.get(0);
System.out.println("Function to call: " + fcStep.name().orElse("") + " (ID: " + fcStep.id().orElse("") + ")");
System.out.println("Arguments: " + fcStep.arguments().orElse(Map.of()));
// 3. Execute the function locally (simulated get_weather()) and send the result back (Turn 2)
FunctionResultStep resultStep = FunctionResultStep.builder()
.name(fcStep.name().orElse(""))
.callId(fcStep.id().orElse(""))
.result(FunctionResultStepResultUnion.of("{\"temperature\": 23, \"unit\": \"celsius\"}"))
.build();
CreateAgentInteraction followupParams = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.previousInteractionId(interaction.id().orElse(""))
.environment(CreateAgentInteractionEnvironment.of(interaction.environmentId().orElse("")))
.input(InteractionsInput.ofStep(List.of(resultStep)))
.build();
Interaction finalInteraction = client.interactions.create(CreateInteractionRequestBody.of(followupParams)).interaction().get();
System.out.println(finalInteraction.outputText().orElse(""));
// Output: The current weather in Tokyo, Japan is 23°C (Celsius).
} else {
System.out.println("No pending function calls.");
}
} else {
System.out.println("Interaction completed with status: " + interaction.status().orElse(null));
}
REST
# 1. Turn 1: Request function call
RESPONSE=$(curl -s -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "antigravity-preview-09-2026",
"input": "What is the weather in Tokyo?",
"environment": "remote",
"tools": [
{"type": "code_execution"},
{
"type": "function",
"name": "get_weather",
"description": "Gets the current weather for a given location.",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string"}
},
"required": ["location"]
}
}
]
}')
# Extract interaction ID, environment ID, and call ID (requires jq)
INTERACTION_ID=$(echo $RESPONSE | jq -r '.id')
ENVIRONMENT_ID=$(echo $RESPONSE | jq -r '.environment_id')
CALL_ID=$(echo $RESPONSE | jq -r '.steps[] | select(.type=="function_call") | .id')
# 2. Turn 2: Send function result back using variables
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d "{
\"agent\": \"antigravity-preview-09-2026\",
\"previous_interaction_id\": \"$INTERACTION_ID\",
\"environment\": \"$ENVIRONMENT_ID\",
\"input\": [
{
\"type\": \"function_result\",
\"name\": \"get_weather\",
\"call_id\": \"$CALL_ID\",
\"result\": {
\"temperature\": 23,
\"unit\": \"celsius\"
}
}
]
}"
שרתי MCP
אתם יכולים לחבר את סוכן Antigravity לכלים חיצוניים על ידי רישום של שרתי Model Context Protocol (MCP) מרוחקים. הסוכן תומך בשרתי MCP מרוחקים באמצעות HTTP שניתן להזרמה.
כשרושמים שרת MCP, צריך לציין את השדות הבאים במערך tools:
| שדה | סוג | נדרש | תיאור |
|---|---|---|---|
type |
מחרוזת | כן | חייב להיות "mcp_server". |
name |
מחרוזת | כן | מזהה ייחודי של השרת. הערך חייב להיות אלפאנומרי (בהתאם ל-^[a-z0-9_-]+$) ובאותיות קטנות בלבד. |
url |
מחרוזת | כן | כתובת ה-URL של נקודת הקצה של שרת ה-MCP המרוחק. |
headers |
אובייקט | לא | כותרות מותאמות אישית (למשל, אימות) שנשלחות עם בקשות. |
allowed_tools |
מערך | לא | רשימה של שמות הכלים שמותר להפעיל. אם לא מציינים כלים, כל הכלים מותרים. |
Python
from google import genai
client = genai.Client()
# Register a remote HTTP MCP server
interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
input="What is the weather in Tokyo?",
environment="remote",
tools=[{
"type": "mcp_server",
"name": "weather", # Must be lowercase
"url": "https://gemini-api-demos.uc.r.appspot.com/mcp"
}]
)
print(interaction.output_text)
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "What is the weather in Tokyo?",
environment: "remote",
tools: [{
type: "mcp_server",
name: "weather", // Must be lowercase
url: "https://gemini-api-demos.uc.r.appspot.com/mcp"
}]
}, { timeout: 300000 });
console.log(interaction.output_text);
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
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.List;
Client client = new Client();
// Register a remote HTTP MCP server
CreateAgentInteraction params = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("What is the weather in Tokyo?"))
.environment(CreateAgentInteractionEnvironment.of("remote"))
.tools(List.of(
MCPServer.builder()
.name("weather") // Must be lowercase
.url("https://gemini-api-demos.uc.r.appspot.com/mcp")
.build()
))
.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 '{
"agent": "antigravity-preview-09-2026",
"input": "What is the weather in Tokyo?",
"environment": "remote",
"tools": [{
"type": "mcp_server",
"name": "weather",
"url": "https://gemini-api-demos.uc.r.appspot.com/mcp"
}]
}'
בחירת מודל
ב-antigravity-preview-09-2026, מודל ברירת המחדל הוא Gemini 3.8 Flash (gemini-3.8-flash). אם לא מציינים את agent_config, ברירת המחדל של הסוכן היא gemini-3.8-flash.
אתם יכולים להגדיר את מודל Gemini הבסיסי באמצעות agent_config כדי לבצע אופטימיזציה של המהירות, העלות או יכולת החשיבה הרציונלית.
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
input="Summarize the key differences between functional and object-oriented programming.",
environment="remote",
agent_config={
"type": "antigravity",
"model": "gemini-3.5-flash-lite",
},
)
print(interaction.output_text)
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "Summarize the key differences between functional and object-oriented programming.",
environment: "remote",
agent_config: {
type: "antigravity",
model: "gemini-3.5-flash-lite",
},
}, { timeout: 300000 });
console.log(interaction.output_text);
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.AntigravityAgentConfig;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
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();
CreateAgentInteraction params = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("Summarize the key differences between functional and object-oriented programming."))
.environment(CreateAgentInteractionEnvironment.of("remote"))
.agentConfig(
AntigravityAgentConfig.builder()
.model("gemini-3.5-flash-lite")
.build()
)
.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 '{
"agent": "antigravity-preview-09-2026",
"input": "Summarize the key differences between functional and object-oriented programming.",
"environment": "remote",
"agent_config": {
"type": "antigravity",
"model": "gemini-3.5-flash-lite"
}
}'
הערכים הנתמכים של agent_config.model הם:
| מודל | ערך בagent_config.model |
תיאור |
|---|---|---|
| Gemini 3.8 Flash (ברירת מחדל) | gemini-3.8-flash |
מודל מאוזן כברירת מחדל לניתוח, לתכנות ולשימוש בכלים. |
| Gemini 3.7 Flash | gemini-3.7-flash |
מודל Flash מהדור הקודם להסקת מסקנות, לתכנות ולתהליכי עבודה אג'נטיים. |
| Gemini 3.6 Flash | gemini-3.6-flash |
מודל Flash מאוזן לתהליכי עבודה אג'נטיים כלליים. |
| Gemini 3.5 Flash | gemini-3.5-flash |
מודל קל משקל לתהליכי עבודה כלליים. |
| Gemini 3.5 Flash-Lite | gemini-3.5-flash-lite |
מודל קל משקל שעבר אופטימיזציה לזמן אחזור נמוך ולמשימות שבהן העלות היא שיקול חשוב. |
כשיוצרים סוכן מנוהל באמצעות agents.create, מגדירים את המודל בדיוק באותו אופן על ידי העברת base_agent ו-agent_config. שימו לב שאי אפשר לשנות את המודל במועד האינטראקציה לסוכן מנוהל שנוצר באמצעות agents.create. המודל נעול למה שהוגדר כשהסוכן נוצר. כך אפשר לוודא שההתנהגות של הפעלת הכלים תהיה צפויה, שהניפוי באגים יהיה עקבי ושגבולות האבטחה יישמרו.
התאמה אישית של הסוכן
אפשר להרחיב את יכולות הסוכן Antigravity על ידי התאמה אישית של ההוראות, הכלים והסביבה שלו. הסוכן תומך בגישה מקורית למערכת הקבצים להתאמה אישית: אתם יכולים לטעון קבצים כמו AGENTS.md להוראות ולסקילים בתיקייה .agents/skills/ ישירות לארגז החול, או להעביר את ההגדרה בשורה במועד האינטראקציה. אפשר לחזור על ההגדרה בתוך השורה ואז לשמור אותה כסוכן מנוהל כשמוכנים.
לפרטים מלאים על בניית סוכנים בהתאמה אישית, אפשר לעיין במאמר בניית סוכנים מנוהלים.
ביצוע ברקע
משימות של סוכני AI שכוללות חשיבה רב-שלבית, הרצת קוד או פעולות על קבצים יכולות להימשך כמה דקות. כדי להפעיל את האינטראקציה באופן אסינכרוני, משתמשים ב-background=True. ה-API מחזיר מיד מזהה אינטראקציה שאתם שולחים לו בקשות עד שהסטטוס הוא completed או failed.
Python
import time
from google import genai
client = genai.Client()
# 1. Start the interaction in the background
interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
input="Run a complex analysis on the repository.",
environment="remote",
background=True,
)
print(f"Interaction started in background: {interaction.id}")
# 2. Poll for completion
while interaction.status == "in_progress":
time.sleep(5)
interaction = client.interactions.get(id=interaction.id)
if interaction.status == "completed":
print(interaction.output_text)
else:
print(f"Finished with status: {interaction.status}")
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "Run a complex analysis on the repository.",
environment: "remote",
background: true,
});
console.log(`Interaction started in background: ${interaction.id}`);
let result = interaction;
while (result.status === "in_progress") {
await new Promise(resolve => setTimeout(resolve, 5000));
result = await client.interactions.get(interaction.id);
}
if (result.status === "completed") {
console.log(result.output_text);
} else {
console.log(`Finished with status: ${result.status}`);
}
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
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;
Client client = new Client();
// 1. Start the interaction in the background
CreateAgentInteraction params = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("Run a complex analysis on the repository."))
.environment(CreateAgentInteractionEnvironment.of("remote"))
.background(true)
.build();
Interaction interaction = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
System.out.println("Interaction started in background: " + interaction.id().orElse(""));
// 2. Poll for completion
while (interaction.status().orElse(null) == InteractionStatus.IN_PROGRESS) {
Thread.sleep(5000);
interaction = client.interactions.get(new GetInteractionByIdRequest(interaction.id().orElse(""))).interaction().get();
}
if (interaction.status().orElse(null) == InteractionStatus.COMPLETED) {
System.out.println(interaction.outputText().orElse(""));
} else {
System.out.println("Finished with status: " + interaction.status().orElse(null));
}
REST
# 1. Start the interaction in the background
RESPONSE=$(curl -s -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Api-Revision: 2026-05-20" \
-d '{
"agent": "antigravity-preview-09-2026",
"input": "Run a complex analysis on the repository.",
"environment": "remote",
"background": true
}')
INTERACTION_ID=$(echo $RESPONSE | jq -r '.id')
# 2. Poll for results (repeat until status is "completed")
curl -s -X GET "https://generativelanguage.googleapis.com/v1beta/interactions/$INTERACTION_ID" \
-H "x-goog-api-key: $GEMINI_API_KEY"
כדי להריץ ברקע, צריך להשתמש ב-store=True, שמוגדר כברירת מחדל. כדי לקבל עדכוני התקדמות בזמן אמת במהלך הפעלה ברקע, אפשר לעיין במאמר בנושא הזרמת אינטראקציות ברקע.
אפשר לבטל אינטראקציה ברקע באמצעות השיטה cancel.
Python
client.interactions.cancel(id="INTERACTION_ID")
JavaScript
await client.interactions.cancel("INTERACTION_ID");
Java
import com.google.genai.Client;
Client client = new Client();
client.interactions.cancel("INTERACTION_ID");
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions/INTERACTION_ID:cancel" \
-H "x-goog-api-key: $GEMINI_API_KEY"
כשאינטראקציה ברקע כוללת כלים עם מצב (כמו הרצת קוד בסביבת ארגז חול), משתמשים ב-environment_id מהאינטראקציה שהושלמה כדי להמשיך באותה סביבה. כך הסוכן ימשיך מהמקום שבו הוא הפסיק, עם כל הקבצים והמצב הקודם.
Python
import time
from google import genai
client = genai.Client()
# First turn: run a task in the background
interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
input="Clone https://github.com/google/generative-ai-python and run its tests.",
environment="remote",
background=True,
)
while interaction.status == "in_progress":
time.sleep(5)
interaction = client.interactions.get(id=interaction.id)
# Second turn: continue in the same environment
followup = client.interactions.create(
agent="antigravity-preview-09-2026",
input="Fix any failing tests and re-run them.",
previous_interaction_id=interaction.id,
environment=interaction.environment_id,
background=True,
)
while followup.status == "in_progress":
time.sleep(5)
followup = client.interactions.get(id=followup.id)
print(followup.output_text)
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
// First turn: run a task in the background
let interaction = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "Clone https://github.com/google/generative-ai-python and run its tests.",
environment: "remote",
background: true,
});
while (interaction.status === "in_progress") {
await new Promise(resolve => setTimeout(resolve, 5000));
interaction = await client.interactions.get(interaction.id);
}
// Second turn: continue in the same environment
let followup = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "Fix any failing tests and re-run them.",
previous_interaction_id: interaction.id,
environment: interaction.environment_id,
background: true,
});
while (followup.status === "in_progress") {
await new Promise(resolve => setTimeout(resolve, 5000));
followup = await client.interactions.get(followup.id);
}
console.log(followup.output_text);
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
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;
Client client = new Client();
// First turn: run a task in the background
CreateAgentInteraction params = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("Clone https://github.com/google/generative-ai-python and run its tests."))
.environment(CreateAgentInteractionEnvironment.of("remote"))
.background(true)
.build();
Interaction interaction = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
while (interaction.status().orElse(null) == InteractionStatus.IN_PROGRESS) {
Thread.sleep(5000);
interaction = client.interactions.get(new GetInteractionByIdRequest(interaction.id().orElse(""))).interaction().get();
}
// Second turn: continue in the same environment
CreateAgentInteraction followupParams = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("Fix any failing tests and re-run them."))
.previousInteractionId(interaction.id().orElse(""))
.environment(CreateAgentInteractionEnvironment.of(interaction.environmentId().orElse("")))
.background(true)
.build();
Interaction followup = client.interactions.create(CreateInteractionRequestBody.of(followupParams)).interaction().get();
while (followup.status().orElse(null) == InteractionStatus.IN_PROGRESS) {
Thread.sleep(5000);
followup = client.interactions.get(new GetInteractionByIdRequest(followup.id().orElse(""))).interaction().get();
}
System.out.println(followup.outputText().orElse(""));
REST
# 1. Start first interaction in the background
RESPONSE=$(curl -s -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Api-Revision: 2026-05-20" \
-d '{
"agent": "antigravity-preview-09-2026",
"input": "Clone https://github.com/google/generative-ai-python and run its tests.",
"environment": "remote",
"background": true
}')
INTERACTION_ID=$(echo $RESPONSE | jq -r '.id')
# 2. Poll until completed (repeat until status is "completed")
RESULT=$(curl -s -X GET "https://generativelanguage.googleapis.com/v1beta/interactions/$INTERACTION_ID" \
-H "x-goog-api-key: $GEMINI_API_KEY")
ENVIRONMENT_ID=$(echo $RESULT | jq -r '.environment_id')
# 3. Continue in the same environment
curl -s -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Api-Revision: 2026-05-20" \
-d "{
\"agent\": \"antigravity-preview-09-2026\",
\"input\": \"Fix any failing tests and re-run them.\",
\"previous_interaction_id\": \"$INTERACTION_ID\",
\"environment\": \"$ENVIRONMENT_ID\",
\"background\": true
}"
סביבה
כל קריאה יוצרת ארגז חול של Linux או משתמשת בארגז חול קיים. הפרמטר environment מופיע בשלושה פורמטים:
| טופס | תיאור |
|---|---|
"remote" |
הקצאת ארגז חול חדש עם הגדרות ברירת מחדל. |
"env_abc123" |
אפשר לעשות שימוש חוזר בסביבה קיימת לפי המזהה שלה, ולשמור את כל הקבצים והמצב. |
{...} |
מלא EnvironmentConfig עם מקורות מותאמים אישית וכללי רשת. |
פרטים על מקורות (Git, GCS, inline), רשתות, מחזור חיים ומגבלות משאבים זמינים במאמר סביבות.
טריגרים
טריגרים מאפשרים לתזמן הפעלה אוטומטית של סוכן לפי לוח זמנים של cron. גורם מפעיל קושר בין סוכן, סביבה, הנחיה ולוח זמנים למשאב קבוע שמופעל ללא התערבות ידנית. כל הרצה משתמשת מחדש באותה סביבה, כך שקבצים שנוצרו בהרצה אחת נשמרים וגלויים להרצה הבאה.
יצירת טריגר
כדי ליצור טריגר, מציינים את לוח הזמנים של cron, את אזור הזמן ואת הגדרת האינטראקציה. הטריגר מתחיל בסטטוס active ויופעל בזמן ה-cron התואם הבא. שומרים את הערך id שמוחזר כדי לנהל את הטריגר בשיחות הבאות.
מכיוון שטריגר פועל ללא השגחה לפי לוח זמנים, צריך להפנות אל פרטי כניסה מאוחסנים ולא אל טוקן מוטבע. פרוקסי היציאה פותר את הבעיה בכל הפעלה, ואתם מסובבים את הסוד בלי לגעת בטריגר. גם כללי transform inline פועלים כאן, רק צריך לעדכן את הטריגר בכל פעם שהערך משתנה.
Python
from google import genai
client = genai.Client()
trigger = client.triggers.create(
schedule="0 9 * * *",
time_zone="America/Argentina/Buenos_Aires",
display_name="issue-solver",
interaction={
"agent": "antigravity-preview-09-2026",
"input": "Review open PRs in my-org/my-app for new comments and address feedback. Close issues whose PRs were merged. Then check for new issues labeled 'accepted', skip any already tracked in /workspace/solved-issues/, fix the rest, and open a PR for each. Save reports to /workspace/solved-issues/.",
"environment": {
"type": "remote",
"network": {
"allowlist": [
{
"domain": "api.github.com",
"credential": "github-production",
},
{"domain": "github.com"},
]
},
},
},
)
print(f"Trigger created: {trigger.id}")
print(f"Next run: {trigger.next_run_time}")
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const trigger = await client.triggers.create({
schedule: "0 9 * * *",
time_zone: "America/Argentina/Buenos_Aires",
display_name: "issue-solver",
interaction: {
agent: "antigravity-preview-09-2026",
input: [{
type: "text",
text: "Review open PRs in my-org/my-app for new comments and address feedback. Close issues whose PRs were merged. Then check for new issues labeled 'accepted', skip any already tracked in /workspace/solved-issues/, fix the rest, and open a PR for each. Save reports to /workspace/solved-issues/.",
}],
environment: {
type: "remote",
network: {
allowlist: [
{
domain: "api.github.com",
credential: "github-production",
},
{ domain: "github.com" },
],
},
},
},
});
console.log(`Trigger created: ${trigger.id}`);
console.log(`Next run: ${trigger.next_run_time}`);
Java
import com.google.genai.gaos.GenAI;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.Allowlist;
import com.google.genai.gaos.models.interactions.AllowlistEntry;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
import com.google.genai.gaos.models.interactions.Environment;
import com.google.genai.gaos.models.interactions.EnvironmentNetworkEgressAllowlist;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Network;
import com.google.genai.gaos.models.interactions.Transform;
import com.google.genai.gaos.models.shared.Security;
import com.google.genai.gaos.models.triggers.Interaction;
import com.google.genai.gaos.models.triggers.Trigger;
import com.google.genai.gaos.models.triggers.TriggerCreateParams;
import java.util.List;
import java.util.Map;
GenAI client = GenAI.builder()
.security(Security.builder().apiKey(System.getenv("GEMINI_API_KEY")).build())
.build();
Environment env = Environment.builder()
.network(Network.of(EnvironmentNetworkEgressAllowlist.of(
Allowlist.builder()
.allowlist(List.of(
AllowlistEntry.builder()
.domain("api.github.com")
.transform(Transform.of(Map.of(
"Authorization", "Bearer ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
)))
.build(),
AllowlistEntry.builder()
.domain("github.com")
.build()
))
.build()
)))
.build();
CreateAgentInteraction interactionTemplate = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("Review open PRs in my-org/my-app for new comments and address feedback. Close issues whose PRs were merged. Then check for new issues labeled 'accepted', skip any already tracked in /workspace/solved-issues/, fix the rest, and open a PR for each. Save reports to /workspace/solved-issues/."))
.environment(CreateAgentInteractionEnvironment.of(env))
.build();
TriggerCreateParams params = TriggerCreateParams.builder()
.schedule("0 9 * * *")
.timeZone("America/Argentina/Buenos_Aires")
.displayName("issue-solver")
.interaction(Interaction.of(interactionTemplate))
.build();
Trigger trigger = client.triggers().create(params).trigger().get();
System.out.println("Trigger created: " + trigger.id().orElse(""));
System.out.println("Next run: " + trigger.nextRunTime().orElse(null));
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/triggers" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"schedule": "0 9 * * *",
"time_zone": "America/Argentina/Buenos_Aires",
"display_name": "issue-solver",
"interaction": {
"agent": "antigravity-preview-09-2026",
"input": [{"type": "text", "text": "Review open PRs in my-org/my-app for new comments and address feedback. Close issues whose PRs were merged. Then check for new issues labeled accepted, skip any already tracked in /workspace/solved-issues/, fix the rest, and open a PR for each. Save reports to /workspace/solved-issues/."}],
"environment": {
"type": "remote",
"network": {
"allowlist": [
{
"domain": "api.github.com",
"credential": "github-production"
},
{"domain": "github.com"}
]
}
}
}
}'
הבקשה CreateTrigger מקבלת את השדות הבאים:
| שדה | סוג | נדרש | תיאור |
|---|---|---|---|
schedule |
מחרוזת | כן | ביטוי Cron (לדוגמה, 0 * * * * לשעה, 0 9 * * 1-5 לבוקר של יום חול). |
time_zone |
מחרוזת | כן | אזור זמן של IANA (למשל, UTC, America/Argentina/Buenos_Aires). |
display_name |
מחרוזת | לא | שם הטריגר שקריא לבני אדם. |
max_consecutive_failures |
מספר שלם | לא | מספר הכשלים המקסימלי לפני שהטריגר מושהה אוטומטית. ברירת מחדל: 5. |
execution_timeout_seconds |
מספר שלם | לא | זמן קצוב לתפוגה לכל הפעלה בשניות. ברירת מחדל: 600. |
interaction |
אובייקט | כן | CreateInteractionRequest שמגדיר את הסוכן, הקלט, הכלים והסביבה. |
התשובה כוללת את השדות העיקריים הבאים:
| שדה | סוג | תיאור |
|---|---|---|
id |
מחרוזת | מזהה ייחודי של הטריגר. משתמשים בערך הזה בכל הפעולות הבאות. |
status |
מחרוזת | המצב הנוכחי: active, paused או disabled. |
next_run_time |
מחרוזת | חותמת זמן בפורמט ISO 8601 של ההפעלה המתוזמנת הבאה. |
consecutive_failure_count |
מספר שלם | מספר הביצועים הרצופים שנכשלו מאז ההצלחה האחרונה. |
הצגת רשימת הטריגרים
אחזור כל הטריגרים שמשויכים לפרויקט.
Python
triggers = client.triggers.list()
for trigger in triggers.triggers:
print(f"{trigger.id}: {trigger.display_name} ({trigger.status})")
JavaScript
const triggers = await client.triggers.list();
for (const trigger of triggers.triggers) {
console.log(`${trigger.id}: ${trigger.display_name} (${trigger.status})`);
}
Java
import com.google.genai.gaos.GenAI;
import com.google.genai.gaos.models.shared.Security;
import com.google.genai.gaos.models.triggers.Trigger;
import java.util.List;
GenAI client = GenAI.builder()
.security(Security.builder().apiKey(System.getenv("GEMINI_API_KEY")).build())
.build();
List<Trigger> triggers = client.triggers().listDirect().listTriggersResponse().get().triggers().orElse(List.of());
for (Trigger trigger : triggers) {
System.out.println(trigger.id().orElse("") + ": " + trigger.displayName().orElse("") + " (" + trigger.status().orElse(null) + ")");
}
REST
curl -X GET "https://generativelanguage.googleapis.com/v1beta/triggers" \
-H "x-goog-api-key: $GEMINI_API_KEY"
קבלת טריגר
אחזור ההגדרה המלאה והמצב הנוכחי של טריגר יחיד.
Python
trigger = client.triggers.get(id="TRIGGER_ID")
print(f"Schedule: {trigger.schedule}")
print(f"Next run: {trigger.next_run_time}")
JavaScript
const trigger = await client.triggers.get("TRIGGER_ID");
console.log(`Schedule: ${trigger.schedule}`);
console.log(`Next run: ${trigger.next_run_time}`);
Java
import com.google.genai.gaos.GenAI;
import com.google.genai.gaos.models.shared.Security;
import com.google.genai.gaos.models.triggers.Trigger;
GenAI client = GenAI.builder()
.security(Security.builder().apiKey(System.getenv("GEMINI_API_KEY")).build())
.build();
Trigger trigger = client.triggers().get("TRIGGER_ID").trigger().get();
System.out.println("Schedule: " + trigger.schedule().orElse(""));
System.out.println("Next run: " + trigger.nextRunTime().orElse(null));
REST
curl -X GET "https://generativelanguage.googleapis.com/v1beta/triggers/TRIGGER_ID" \
-H "x-goog-api-key: $GEMINI_API_KEY"
השהיה והמשך
אתם יכולים להשהות טריגר כדי להפסיק את ההפעלות המתוזמנות, ולהמשיך אותו כדי להפעיל מחדש את התזמון. השהיה לא משפיעה על הפעלות ידניות.
Python
# Pause
client.triggers.update(id="TRIGGER_ID", status="paused")
# Resume
client.triggers.update(id="TRIGGER_ID", status="active")
JavaScript
// Pause
await client.triggers.update("TRIGGER_ID", { status: "paused" });
// Resume
await client.triggers.update("TRIGGER_ID", { status: "active" });
Java
import com.google.genai.gaos.GenAI;
import com.google.genai.gaos.models.shared.Security;
import com.google.genai.gaos.models.triggers.TriggerUpdate;
import com.google.genai.gaos.models.triggers.TriggerUpdateStatus;
GenAI client = GenAI.builder()
.security(Security.builder().apiKey(System.getenv("GEMINI_API_KEY")).build())
.build();
// Pause
client.triggers().update("TRIGGER_ID", TriggerUpdate.builder().status(TriggerUpdateStatus.PAUSED).build());
// Resume
client.triggers().update("TRIGGER_ID", TriggerUpdate.builder().status(TriggerUpdateStatus.ACTIVE).build());
REST
# Pause
curl -X PATCH "https://generativelanguage.googleapis.com/v1beta/triggers/TRIGGER_ID" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{"status": "paused"}'
# Resume
curl -X PATCH "https://generativelanguage.googleapis.com/v1beta/triggers/TRIGGER_ID" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{"status": "active"}'
מחיקת טריגר
להסיר טריגר באופן סופי. היסטוריית ההרצה הקודמת לא נמחקת.
Python
client.triggers.delete(id="TRIGGER_ID")
JavaScript
await client.triggers.delete("TRIGGER_ID");
Java
import com.google.genai.gaos.GenAI;
import com.google.genai.gaos.models.shared.Security;
GenAI client = GenAI.builder()
.security(Security.builder().apiKey(System.getenv("GEMINI_API_KEY")).build())
.build();
client.triggers().delete("TRIGGER_ID");
REST
curl -X DELETE "https://generativelanguage.googleapis.com/v1beta/triggers/TRIGGER_ID" \
-H "x-goog-api-key: $GEMINI_API_KEY"
הפעלת טריגר באופן מיידי
הפעלת טריגר על פי דרישה בלי לחכות למועד המתוזמן הבא. הפעולה הזו תתבצע גם אם ההפעלה של הטריגר מושהית.
Python
client.triggers.run(trigger_id="TRIGGER_ID")
JavaScript
await client.triggers.run("TRIGGER_ID");
Java
import com.google.genai.gaos.GenAI;
import com.google.genai.gaos.models.shared.Security;
GenAI client = GenAI.builder()
.security(Security.builder().apiKey(System.getenv("GEMINI_API_KEY")).build())
.build();
client.triggers().run("TRIGGER_ID");
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/triggers/TRIGGER_ID/executions" \
-H "x-goog-api-key: $GEMINI_API_KEY"
הצגת רשימה של הפעלות
עיון בהיסטוריית הביצוע של טריגר כל הרצה כוללת status, חותמות זמן, interaction_id שאפשר להשתמש בו כדי לאחזר את הפלט המלא של האינטראקציה וenvironment_id שמאשר שכל ההרצות משתמשות באותו ארגז חול.
Python
executions = client.triggers.list_executions(trigger_id="TRIGGER_ID")
for ex in executions.trigger_executions:
print(f"{ex.id}: {ex.status} ({ex.start_time} - {ex.end_time})")
# Fetch the full interaction for an execution
interaction = client.interactions.get(id=ex.interaction_id)
print(interaction.output_text)
JavaScript
const executions = await client.triggers.listExecutions("TRIGGER_ID");
for (const ex of executions.trigger_executions) {
console.log(`${ex.id}: ${ex.status} (${ex.start_time} - ${ex.end_time})`);
}
// Fetch the full interaction for an execution
const interaction = await client.interactions.get(ex.interaction_id);
console.log(interaction.output_text);
Java
import com.google.genai.gaos.GenAI;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.operations.GetInteractionByIdRequest;
import com.google.genai.gaos.models.shared.Security;
import com.google.genai.gaos.models.triggers.TriggerExecution;
import java.util.List;
GenAI client = GenAI.builder()
.security(Security.builder().apiKey(System.getenv("GEMINI_API_KEY")).build())
.build();
List<TriggerExecution> executions = client.triggers().listExecutions("TRIGGER_ID")
.listTriggerExecutionsResponse().get()
.triggerExecutions().orElse(List.of());
for (TriggerExecution ex : executions) {
System.out.println(ex.id().orElse("") + ": " + ex.status().orElse(null)
+ " (" + ex.startTime().orElse(null) + " - " + ex.endTime().orElse(null) + ")");
// Fetch the full interaction for an execution
if (ex.interactionId().isPresent()) {
Interaction interaction = client.interactions().get(new GetInteractionByIdRequest(ex.interactionId().get())).interaction().get();
System.out.println(interaction.outputText().orElse(""));
}
}
REST
curl -X GET "https://generativelanguage.googleapis.com/v1beta/triggers/TRIGGER_ID/executions" \
-H "x-goog-api-key: $GEMINI_API_KEY"
זמינות ומחירים
סוכן Antigravity זמין בגרסת Preview דרך Interactions API ב-Google AI Studio וב-Gemini API, גם בפרויקטים בתוכנית בחינם וגם בפרויקטים בתוכנית בתשלום.
התמחור מבוסס על מודל של תשלום לפי שימוש, על סמך הטוקנים של מודל Gemini הבסיסי והכלים שבהם הסוכן משתמש. בניגוד לבקשת צ'אט רגילה שמפיקה פלט יחיד, אינטראקציה של Antigravity היא תהליך עבודה מבוסס-סוכן. בקשה אחת מפעילה לולאה אוטונומית של ניתוח, הפעלת כלי, הפעלת קוד וניהול קבצים. פרויקטים בתוכנית ללא תשלום כוללים מכסת שימוש ומגבלת תעריף בחינם.
אינטראקציות אנטי-גרביטציה מפעילות לולאות אוטונומיות מרובות שלבים ויכולות לצרוך מספר משמעותי של טוקנים. הגדרת אמצעי בקרה על התקציב בבקשה כדי להגביל את השימוש בטוקנים. אפשר גם לעקוב אחרי ההתקדמות בזמן אמת באמצעות סטרימינג של SSE, או לבטל בקשות שפועלות.
אמצעי בקרה להגבלת השימוש בטוקנים
בנוסף לבחירת המודל, מגדירים את max_total_tokens בתוך agent_config (עם "type": "antigravity") כדי להגביל את המספר הכולל של הטוקנים (קלט + פלט + חשיבה) שאינטראקציה יכולה לצרוך.
טוקנים שמאוחסנים במטמון לא נכללים במגבלה הזו. כשהסוכן מגיע למגבלה, האינטראקציה נפסקת ומוחזרת עם status: "incomplete". ההגבלה היא על בסיס מאמץ מרבי: השימוש בפועל עשוי לחרוג ממנה מעט, בהתאם למועד שבו הסוכן בודק את התקציב בין השלבים.
מגדירים את התקציב בבקשה לאינטראקציה ב-agent_config לצד agent ו-input.
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
input="Analyze the dataset in /workspace/data.csv and generate a summary report.",
agent_config={
"type": "antigravity",
"max_total_tokens": 50000
},
environment={
"type": "remote",
"sources": [
{
"type": "inline",
"target": "/workspace/data.csv",
"content": "id,name,value\n1,alpha,100\n2,beta,200\n",
}
],
}
)
print(f"Status: {interaction.status}") # "incomplete" if budget was hit
print(f"Tokens used: {interaction.usage.total_tokens}")
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "Analyze the dataset in /workspace/data.csv and generate a summary report.",
agent_config: {
type: "antigravity",
max_total_tokens: 50000
},
environment: {
type: "remote",
sources: [
{
type: "inline",
target: "/workspace/data.csv",
content: "id,name,value\n1,alpha,100\n2,beta,200\n",
},
],
},
});
console.log(`Status: ${interaction.status}`);
console.log(`Tokens used: ${interaction.usage.total_tokens}`);
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.AntigravityAgentConfig;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
import com.google.genai.gaos.models.interactions.Environment;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Source;
import com.google.genai.gaos.models.interactions.SourceType;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.List;
Client client = new Client();
Environment env = Environment.builder()
.sources(List.of(
Source.builder()
.type(SourceType.INLINE)
.target("/workspace/data.csv")
.content("id,name,value\n1,alpha,100\n2,beta,200\n")
.build()
))
.build();
CreateAgentInteraction params = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("Analyze the dataset in /workspace/data.csv and generate a summary report."))
.agentConfig(
AntigravityAgentConfig.builder()
.maxTotalTokens("50000")
.build()
)
.environment(CreateAgentInteractionEnvironment.of(env))
.build();
Interaction interaction = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
System.out.println("Status: " + interaction.status().orElse(null)); // "incomplete" if budget was hit
interaction.usage().ifPresent(usage -> System.out.println("Tokens used: " + usage.totalTokens().orElse(0)));
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": "antigravity-preview-09-2026",
"input": "Analyze the dataset in /workspace/data.csv and generate a summary report.",
"agent_config": {
"type": "antigravity",
"max_total_tokens": 50000
},
"environment": {
"type": "remote",
"sources": [
{
"type": "inline",
"target": "/workspace/data.csv",
"content": "id,name,value\n1,alpha,100\n2,beta,200\n"
}
]
}
}'
המשך אינטראקציה לא שלמה
כשאינטראקציה חוזרת status: "incomplete", העבודה וההקשר של הנציג נשמרים. כדי להמשיך את האינטראקציה המקורית id, צריך לשלוח אינטראקציה חדשה עם הפניה אליה ואל environment_id. לאינטראקציה החדשה מוקצה תקציב משלה, max_total_tokens.
Python
# Continue from where the agent stopped
continuation = client.interactions.create(
agent="antigravity-preview-09-2026",
input="continue",
previous_interaction_id=interaction.id,
environment=interaction.environment_id,
agent_config={
"type": "antigravity",
"max_total_tokens": 50000
}
)
print(f"Status: {continuation.status}")
JavaScript
const continuation = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "continue",
previous_interaction_id: interaction.id,
environment: interaction.environment_id,
agent_config: {
type: "antigravity",
max_total_tokens: 50000
}
});
console.log(`Status: ${continuation.status}`);
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.AntigravityAgentConfig;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
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 interactionId = "INTERACTION_ID";
String environmentId = "ENVIRONMENT_ID";
// Continue from where the agent stopped
CreateAgentInteraction params = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("continue"))
.previousInteractionId(interactionId)
.environment(CreateAgentInteractionEnvironment.of(environmentId))
.agentConfig(
AntigravityAgentConfig.builder()
.maxTotalTokens("50000")
.build()
)
.build();
Interaction continuation = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
System.out.println("Status: " + continuation.status().orElse(null));
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": "antigravity-preview-09-2026",
"input": "continue",
"previous_interaction_id": "INTERACTION_ID",
"environment": "ENVIRONMENT_ID",
"agent_config": {
"type": "antigravity",
"max_total_tokens": 50000
}
}'
עלויות משוערות
העלויות משתנות בהתאם למורכבות המשימה. הסוכן קובע באופן אוטונומי כמה קריאות לכלים, הפעלות קוד ופעולות על קבצים נדרשות. האומדנים הבאים מבוססים על הרצות.
| קטגוריית משימה | טוקנים של קלט | טוקנים של פלט | עלות רגילה |
|---|---|---|---|
| מחקר וסינתזת מידע | 100,000 עד 500,000 | 10,000 עד 40,000 | 0.30$-1.00$ |
| יצירת מסמכים ותוכן | 100,000 עד 500,000 | 15,000 עד 50,000 | 0.30$-1.30$ |
| עיצוב תהליכים ומערכות | 100,000 עד 400,000 | 10,000 עד 30,000 | 0.25$-0.80$ |
| עיבוד וניתוח נתונים | 300,000 עד 3 מיליון | 30,000 עד 150,000 | 0.70 עד 3.25 דולר |
בדרך כלל, 50-70% מאסימוני הקלט נשמרים במטמון. בתהליכי עבודה מורכבים של סוכנים עם הרבה קריאות לכלים, יכולים להצטבר 3-5 מיליון טוקנים באינטראקציה אחת, והעלויות יכולות להגיע ל-5$בערך.
השימוש במחשוב בסביבה (CPU, זיכרון, הרצה בארגז חול) לא מחויב במהלך תקופת התצוגה המקדימה.
מגבלות
- סטטוס גרסת טרום-השקה: סוכן Antigravity ו-Interactions API. יכולים להיות שינויים בתכונות ובסכימות.
- הגדרת יצירה לא נתמכת: הפרמטרים הבאים לא נתמכים ומחזירים שגיאה 400:
temperature, top_p, top_k, stop_sequences, max_output_tokens. - פלט מובנה: סוכן Antigravity לא תומך בפלט מובנה.
- כלים שלא זמינים: אין עדיין תמיכה ב-
file_search, ב-computer_useוב-google_maps. - מגבלות של MCP מרוחק: אין תמיכה בתעבורת אירועים שנשלחים מהשרת (SSE) (צריך להשתמש ב-HTTP ניתן להזרמה). בנוסף, שם השרת
nameחייב להיות באותיות קטנות בלבד ואלפאנומרי (שימוש באותיות גדולות יפעיל שגיאה כללית400 Bad Request). - כלי למערכת הקבצים: אין כלי למערכת הקבצים כרגע. הוא חלק מ
environment. - דרישה של חנות: כדי להריץ את הסוכן באמצעות
background=True, צריךstore=True. - הפעלת פונקציות רק במצב stateful: הפעלת פונקציות נתמכת רק במצב stateful. כדי להמשיך את התור, צריך להשתמש ב-
previous_interaction_id. אי אפשר לשחזר את ההיסטוריה באופן ידני (מצב חסר מצב). - סוגים לא נתמכים של מודלים מולטימודאליים. בשלב הזה אין תמיכה בקלט של אודיו, וידאו ומסמכים. מותר להשתמש רק בטקסט ובתמונה.
המאמרים הבאים
- מדריך למתחילים: שיחות רב-שלביות וסטרימינג.
- יצירת סוכנים בהתאמה אישית: הוראות בהתאמה אישית, מיומנויות ושמירת סוכנים.
- סביבות: הגדרת ארגז חול, מקורות, רשת.
- Hooks: אכיפה של שערים לאבטחה ואימות של תופעות לוואי בתוך ארגז החול.
- Deep Research agent: משימות מחקר ארוכות.
- Interactions API: ממשק ה-API הבסיסי.