Antigravity एजेंट, Gemini API पर अलग-अलग कामों के लिए इस्तेमाल किया जाने वाला मैनेज किया गया एजेंट है. एक एपीआई कॉल से आपको एक ऐसा एजेंट मिलता है जो तर्क देता है, कोड को लागू करता है, फ़ाइलों को मैनेज करता है, और Google की ओर से होस्ट किए गए आपके सुरक्षित Linux सैंडबॉक्स में वेब ब्राउज़ करता है.
यह Gemini 3.6 Flash पर काम करता है और Antigravity IDE की तरह ही एक ही तरह के हार्नेस का इस्तेमाल करता है. agent_config का इस्तेमाल करके, Gemini मॉडल को कॉन्फ़िगर किया जा सकता है. यह सुविधा, Interactions API और Google AI Studio के ज़रिए उपलब्ध है.
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-05-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-05-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);
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-05-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 Search और डेटा के लिए यूआरएल फ़ेच करना.
- कॉन्टेक्स्ट को छोटा करना: लंबे समय तक चलने वाले और सिलसिलेवार बातचीत वाले सेशन के लिए, कॉन्टेक्स्ट को अपने-आप छोटा करने की सुविधा (यह सुविधा ~135 हज़ार टोकन पर ट्रिगर होती है). इससे कॉन्टेक्स्ट नहीं बदलता और टोकन की सीमाएं भी नहीं टूटती हैं.
सिलसिलेवार बातचीत और स्ट्रीमिंग के लिए, क्विकस्टार्ट देखें.
इन टूल के साथ काम करता है
डिफ़ॉल्ट रूप से, एजेंट के पास code_execution, google_search, और url_context का ऐक्सेस होता है. environment पैरामीटर तय करने पर, फ़ाइल सिस्टम टूल अपने-आप चालू हो जाते हैं. अपने एपीआई और टूल से एजेंट को कनेक्ट करने के लिए, कस्टम फ़ंक्शन भी तय किए जा सकते हैं. डिफ़ॉल्ट सेट को पसंद के मुताबिक बनाने या उसे सीमित करने पर ही, tools पैरामीटर तय करना होता है. इसके अलावा, कस्टम फ़ंक्शन जोड़ते समय भी ऐसा करना होता है.
| टूल | वैल्यू टाइप करें | ब्यौरा |
|---|---|---|
| कोड एक्ज़ीक्यूट करना | code_execution |
stdout/stderr कैप्चर करने की सुविधा के साथ, शेल कमांड (bash, Python, Node) चलाएं. |
| Google Search | google_search |
सार्वजनिक वेब पर खोजें. |
| यूआरएल कॉन्टेक्स्ट | url_context |
वेब पेजों को फ़ेच और पढ़ सकता है. |
| फ़ाइल सिस्टम | (environment के ज़रिए चालू किया गया) |
सैंडबॉक्स में फ़ाइलें पढ़ने, लिखने, उनमें बदलाव करने, उन्हें खोजने, और उनकी सूची बनाने की अनुमति. environment सेट करने पर, सिस्टम इन टूल को अपने-आप चालू कर देता है. |
| कस्टम फ़ंक्शन | function |
ऐसे कस्टम फ़ंक्शन तय करें जिन्हें एजेंट लागू करने का अनुरोध कर सकता है. फ़ंक्शन कॉलिंग देखें. |
| रिमोट एमसीपी सर्वर | mcp_server |
बाहरी मॉडल कॉन्टेक्स्ट प्रोटोकॉल (एमसीपी) सर्वर को टूल के तौर पर रजिस्टर करें. एमसीपी सर्वर देखें. |
सिंक्रोनस हुक का इस्तेमाल करके, रिमोट सैंडबॉक्स में code_execution और filesystem टूल के एक्ज़ीक्यूशन को इंटरसेप्ट और पुष्टि की जा सकती है.
एजेंट को सिर्फ़ कुछ टूल का ऐक्सेस देने के लिए, सिर्फ़ उन टूल को पास करें जिनकी ज़रूरत है:
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-05-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-05-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);
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-05-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-05-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-05-2026",
input: [
{ type: "text", text: "Analyze this chart and summarize the trends." },
{
type: "image",
data: base64Image,
mime_type: "image/png",
},
],
environment: "remote",
}, { timeout: 300000 });
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-05-2026\",
\"input\": [
{\"type\": \"text\", \"text\": \"Analyze this chart and summarize the trends.\"},
{
\"type\": \"image\",
\"mime_type\": \"image/png\",
\"data\": \"$BASE64_IMAGE\"
}
],
\"environment\": \"remote\"
}"
फ़ंक्शन कॉलिंग
फ़ंक्शन कॉलिंग की सुविधा की मदद से, Antigravity एजेंट को बाहरी एपीआई और डेटाबेस से कनेक्ट किया जा सकता है. इसके लिए, आपको कस्टम टूल तय करने होंगे, जिन्हें एजेंट इस्तेमाल कर सकता है. सामान्य कॉन्सेप्ट के लिए, Gemini API के साथ फ़ंक्शन कॉलिंग देखें.
यहां दिए गए उदाहरण में, दो बार की बातचीत दिखाई गई है. एजेंट पहले कस्टम 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-05-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_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-05-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-05-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_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-05-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}`);
}
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