एनवायरमेंट, मैनेज किए गए Linux सैंडबॉक्स होते हैं. ये एजेंट को कोड चलाने और फ़ाइलों को सेव करने के लिए, एक अलग जगह देते हैं. ये इंटरैक्शन के कॉन्टेक्स्ट से अलग होते हैं. इसलिए, एक ही एनवायरमेंट का इस्तेमाल कई इंटरैक्शन में किया जा सकता है. इसके अलावा, किसी भी समय नए सिरे से इंटरैक्शन शुरू किया जा सकता है.
यहां दिए गए उदाहरण में, नए रिमोट एनवायरमेंट के साथ इंटरैक्शन बनाने और उसका आईडी वापस पाने का तरीका बताया गया है:
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Install pandas and matplotlib, verify the imports, and print the versions.",
environment="remote",
)
print(f"Environment ID: {interaction.environment_id}")
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Install pandas and matplotlib, verify the imports, and print the versions.",
environment: "remote",
});
console.log(`Environment ID: ${interaction.environment_id}`);
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": "Install pandas and matplotlib, verify the imports, and print the versions.",
"environment": "remote"
}'
environment पैरामीटर
environment पैरामीटर में तीन तरह की वैल्यू दी जा सकती हैं:
| फ़ॉर्म | उदाहरण | कब इस्तेमाल करें |
|---|---|---|
"remote" |
environment="remote" |
नया सैंडबॉक्स उपलब्ध कराएं. |
| एनवायरमेंट आईडी | environment="env_abc123" |
सभी फ़ाइलों और पैकेज के साथ किसी मौजूदा सैंडबॉक्स का फिर से इस्तेमाल करें. |
| कॉन्फ़िगरेशन ऑब्जेक्ट | environment={...} |
सोर्स, नेटवर्क के नियमों या दोनों के साथ नया सैंडबॉक्स उपलब्ध कराएं. |
यहां दिए गए उदाहरणों में, environment पैरामीटर का इस्तेमाल करने के तीन तरीके दिखाए गए हैं.
Python
from google import genai
client = genai.Client()
# Fresh sandbox
interaction = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Write a hello world script.",
environment="remote",
)
# Reuse an existing sandbox
interaction_2 = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Modify the script to accept a name argument.",
environment=interaction.environment_id,
previous_interaction_id=interaction.id,
)
# New sandbox with sources
interaction_3 = client.interactions.create(
agent="antigravity-preview-05-2026",
input="List all files and summarize the project.",
environment={
"type": "remote",
"sources": [
{
"type": "repository",
"source": "https://github.com/octocat/Spoon-Knife",
"target": "/workspace/spoon-knife",
}
],
},
)
print(interaction.output_text)
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
// Fresh sandbox
const interaction = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Write a hello world script.",
environment: "remote",
});
// Reuse an existing sandbox
const interaction2 = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Modify the script to accept a name argument.",
environment: interaction.environment_id,
previous_interaction_id: interaction.id,
});
// New sandbox with sources
const interaction3 = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "List all files and summarize the project.",
environment: {
type: "remote",
sources: [
{
type: "repository",
source: "https://github.com/octocat/Spoon-Knife",
target: "/workspace/spoon-knife",
},
],
},
});
console.log(interaction.output_text);
REST
# Fresh sandbox
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": "Write a hello world script."}],
"environment": "remote"
}'
# Reuse an existing sandbox (replace $ENV_ID and $INTERACTION_ID with values from the previous response)
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\": \"Modify the script to accept a name argument.\"}],
\"environment\": \"$ENV_ID\",
\"previous_interaction_id\": \"$INTERACTION_ID\"
}"
# New sandbox with sources
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": "List all files and summarize the project."}],
"environment": {
"type": "remote",
"sources": [
{
"type": "repository",
"source": "https://github.com/octocat/Spoon-Knife",
"target": "/workspace/spoon-knife"
}
]
}
}'
एनवायरमेंट को कॉन्फ़िगर करना
एजेंट को यह बताकर कि आपको क्या इंस्टॉल करना है, एनवायरमेंट सेट अप किया जा सकता है.
यह डिपेंडेंसी रिज़ॉल्यूशन और समस्या हल करने की प्रोसेस को मैनेज करता है. एनवायरमेंट तैयार होने के बाद, environment_id को सेव करें और इसे फिर से इस्तेमाल करें.
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Install pandas, matplotlib, and seaborn. Verify all imports work and print the installed versions.",
environment="remote",
)
# Reuse the configured environment
interaction_2 = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Clone https://github.com/octocat/Spoon-Knife into /workspace/tools. Run the test suite and fix any missing dependencies.",
environment=interaction.environment_id,
previous_interaction_id=interaction.id,
)
# Reuse the configured environment
interaction_3 = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Using the tools in /workspace/tools, list the files.",
environment=interaction.environment_id,
previous_interaction_id=interaction_2.id,
)
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: "Install pandas, matplotlib, and seaborn. Verify all imports work and print the installed versions.",
environment: "remote",
});
const interaction2 = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Clone https://github.com/octocat/Spoon-Knife into /workspace/tools. Run the test suite and fix any missing dependencies.",
environment: interaction.environment_id,
previous_interaction_id: interaction.id,
});
const interaction3 = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Using the tools in /workspace/tools, list the files.",
environment: interaction.environment_id,
previous_interaction_id: interaction2.id,
});
console.log(interaction.output_text);
REST
# Create interaction
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": "Install pandas, matplotlib, and seaborn. Verify all imports work and print the installed versions.",
"environment": "remote"
}'
किसी सोर्स से माउंट करना
अगर आपको पता है कि एजेंट को किन फ़ाइलों की ज़रूरत है, तो उन्हें एक ही कॉल में माउंट करें. इसके लिए, बार-बार कॉल करने की ज़रूरत नहीं है. environment कॉन्फ़िगरेशन ऑब्जेक्ट, तीन टाइप वाली sources कलेक्शन को स्वीकार करता है:
| स्रोत प्रकार | type की कीमत का |
ब्यौरा | सीमा |
|---|---|---|---|
| Git डेटा स्टोर करने की जगह | repository |
यह किसी यूआरएल से, किसी रिपॉज़िटरी को target पर मौजूद सैंडबॉक्स में क्लोन करता है. |
500 एमबी |
| Cloud Storage | gcs |
Cloud Storage से किसी फ़ाइल या डायरेक्ट्री को target पर मौजूद सैंडबॉक्स में कॉपी करता है. |
2 GB |
| इनलाइन कॉन्टेंट | inline |
यह फ़ंक्शन, सैंडबॉक्स में मौजूद target पर किसी फ़ाइल में रॉ टेक्स्ट कॉन्टेंट लिखता है. |
हर फ़ाइल का साइज़ 1 एमबी और कुल साइज़ 2 एमबी से ज़्यादा नहीं होना चाहिए |
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-05-2026",
input="List all files under /workspace and describe what you find.",
environment={
"type": "remote",
"sources": [
{
"type": "repository",
"source": "https://github.com/octocat/Spoon-Knife",
"target": "/workspace/spoon-knife",
},
{
"type": "gcs",
"source": "gs://cloud-samples-data/bigquery/us-states/",
"target": "/workspace/gcs-data",
},
{
"type": "inline",
"content": "# Project Notes\n\n- Analyze state population data\n- Create visualizations\n",
"target": "/workspace/notes/readme.md",
},
],
},
)
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: "List all files under /workspace and describe what you find.",
environment: {
type: "remote",
sources: [
{
type: "repository",
source: "https://github.com/octocat/Spoon-Knife",
target: "/workspace/spoon-knife",
},
{
type: "gcs",
source: "gs://cloud-samples-data/bigquery/us-states/",
target: "/workspace/gcs-data",
},
{
type: "inline",
content: "# Project Notes\n\n- Analyze state population data\n- Create visualizations\n",
target: "/workspace/notes/readme.md",
},
],
},
});
console.log(interaction.output_text);
REST
# Create interaction with sources
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": "List all files under /workspace and describe what you find.",
"environment": {
"type": "remote",
"sources": [
{
"type": "repository",
"source": "https://github.com/octocat/Spoon-Knife",
"target": "/workspace/spoon-knife"
},
{
"type": "gcs",
"source": "gs://cloud-samples-data/bigquery/us-states/",
"target": "/workspace/gcs-data"
},
{
"type": "inline",
"content": "# Project Notes\n\n- Analyze state population data\n- Create visualizations\n",
"target": "/workspace/notes/readme.md"
}
]
}
}'
दोनों तरीकों को एक साथ इस्तेमाल किया जा सकता है: जाने-पहचाने सोर्स को डिक्लेरेटिव तरीके से माउंट करें. इसके बाद, पैकेज इंस्टॉल करने या सेटअप स्क्रिप्ट चलाने के लिए, फ़ॉलो-अप इंटरैक्शन का इस्तेमाल करें. कस्टम सोर्स जोड़ते समय, रूट (/) को टारगेट के तौर पर सेट नहीं किया जा सकता. आपको हमेशा कोई सब-डायरेक्ट्री तय करनी होगी.
निजी सोर्स
नेटवर्क कॉन्फ़िगरेशन में क्रेडेंशियल जोड़कर, निजी GitHub रिपॉज़िटरी या निजी Cloud Storage बकेट से भी डाउनलोड किया जा सकता है:
निजी Git रिपॉज़िटरी के लिए, Basic पुष्टि करने की सुविधा का इस्तेमाल करें. इसके लिए, GitHub Personal Access Token (PAT) का इस्तेमाल करें.
उपयोगकर्ता नाम के तौर पर x-oauth-basic का इस्तेमाल करके, टोकन को कोड में बदलें:
echo -n "x-oauth-basic:ghp_YourPATHere" | base64
Python
interaction = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Run the test for my backend app and fix any issue.",
environment={
"type": "remote",
"sources": [
{
"type": "repository",
"source": "https://github.com/your-org/backend",
"target": "/backend-app"
}
],
"network": {
"allowlist": [
{
"domain": "github.com",
"transform": {
"Authorization": "Basic YOUR_BASE64_TOKEN"
}
},
{
"domain": "*"
}
]
}
}
)
JavaScript
const interaction = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Run the test for my backend app and fix any issue.",
environment: {
type: "remote",
sources: [
{
type: "repository",
source: "https://github.com/your-org/backend",
target: "/backend-app"
}
],
network: {
allowlist: [
{
domain: "github.com",
transform: {
"Authorization": "Basic YOUR_BASE64_TOKEN"
}
},
{
domain: "*"
}
]
}
},
});
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": "Run the test for my backend app and fix any issue.",
"environment": {
"type": "remote",
"sources": [
{
"type": "repository",
"source": "https://github.com/your-org/backend",
"target": "/backend-app"
}
],
"network": {
"allowlist": [
{
"domain": "github.com",
"transform": {
"Authorization": "Basic YOUR_BASE64_TOKEN"
}
},
{
"domain": "*"
}
]
}
}
}'
निजी Cloud Storage बकेट के लिए, स्टैंडर्ड OAuth 2.0 बियरर टोकन का इस्तेमाल करें:
gcloud auth print-access-token
Python
interaction = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Analyze the discrepancies across the data in workspace",
environment={
"type": "remote",
"sources": [
{
"type": "gcs",
"source": "gs://my-private-bucket/data",
"target": "/workspace",
}
],
"network": {
"allowlist": [
{
"domain": "*.googleapis.com",
"transform": {
"Authorization": "Bearer YOUR_GCS_TOKEN"
}
},
{
"domain": "*"
}
]
}
},
)
JavaScript
const interaction = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Analyze the discrepancies across the data in workspace",
environment: {
type: "remote",
sources: [
{
type: "gcs",
source: "gs://my-private-bucket/data",
target: "/workspace",
}
],
network: {
allowlist: [
{
domain: "storage.googleapis.com",
transform: {
"Authorization": "Bearer YOUR_GCS_TOKEN"
}
},
{
domain: "*"
}
]
}
},
});
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": "Analyze the discrepancies across the data in workspace",
"environment": {
"type": "remote",
"sources": [
{
"type": "gcs",
"source": "gs://my-private-bucket/data",
"target": "/workspace"
}
],
"network": {
"allowlist": [
{
"domain": "storage.googleapis.com",
"transform": {
"Authorization": "Bearer YOUR_GCS_TOKEN"
}
},
{
"domain": "*"
}
]
}
}
}'
पहले से इंस्टॉल किया गया सॉफ़्टवेयर
सैंडबॉक्स, Ubuntu पर चलता है. इसमें रनटाइम और सामान्य पैकेज पहले से इंस्टॉल होते हैं. एजेंट, रनटाइम के दौरान pip
install या npm install का इस्तेमाल करके अतिरिक्त पैकेज इंस्टॉल कर सकता है. किसी इंटरैक्शन के दौरान इंस्टॉल किए गए पैकेज, उसी environment_id का दोबारा इस्तेमाल करने पर भी बने रहते हैं.
| कैटगरी | पहले से इंस्टॉल किए गए पैकेज |
|---|---|
| UNIX टूल | curl, wget, git, rsync, unzip, ripgrep, fd-find, gawk, bc, tree, which, lsof, htop, jq, iproute2, procps, gcloud CLI |
| Python 3.12 | numpy, pandas, requests, google-genai, beautifulsoup4, pyyaml, ast-grep-cli |
| Node.js 22 | create-next-app, create-vite, typescript |
नेटवर्क कॉन्फ़िगरेशन
डिफ़ॉल्ट रूप से, एनवायरमेंट में आउटबाउंड नेटवर्क का ऐक्सेस बिना किसी पाबंदी के होता है. network फ़ील्ड का इस्तेमाल करके, आउटबाउंड ट्रैफ़िक को कुछ डोमेन तक सीमित करें. हर नियम में, मैच करने वाले अनुरोधों में हेडर डालने के लिए, domain और transform ऑब्जेक्ट तय किया जाता है. transform ऑब्जेक्ट को तय करना ज़रूरी नहीं है. ये हेडर, हर इंटरैक्शन के हिसाब से अलग-अलग हो सकते हैं. साथ ही, इन्हें एक ही एनवायरमेंट के लिए अपडेट किया जा सकता है.
| फ़ील्ड | टाइप | ब्यौरा |
|---|---|---|
domain |
string |
मिलान करने के लिए डोमेन. सभी डोमेन के लिए, सटीक होस्टनेम या * का इस्तेमाल करें. |
transform |
object |
यह ऑब्जेक्ट, फ़्लैट की-वैल्यू पेयर वाला होता है.यह उन हेडर को दिखाता है जिन्हें मैचिंग अनुरोधों में इंजेक्ट करना है. उदाहरण के लिए, {"Authorization": "Bearer ..."}. |
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Fetch the latest issues from the GitHub API for my-org/my-repo.",
environment={
"type": "remote",
"network": {
"allowlist": [
{
"domain": "api.github.com",
"transform": {
"Authorization": "Bearer ghp_your_github_token"
},
},
{"domain": "pypi.org"},
{"domain": "*"},
]
},
},
)
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: "Fetch the latest issues from the GitHub API for my-org/my-repo.",
environment: {
type: "remote",
network: {
allowlist: [
{
domain: "api.github.com",
transform: {
"Authorization": "Bearer ghp_your_github_token"
},
},
{ domain: "pypi.org" },
{ domain: "*" },
]
}
},
});
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": [{"type": "text", "text": "Fetch the latest issues from the GitHub API for my-org/my-repo."}],
"environment": {
"type": "remote",
"network": {
"allowlist": [
{
"domain": "api.github.com",
"transform": {
"Authorization": "Bearer ghp_your_github_token"
}
},
{"domain": "pypi.org"},
{"domain": "*"}
]
}
}
}'
अनुमति वाली सूची सेट होने पर, सिर्फ़ सूची में शामिल डोमेन के अनुरोधों को अनुमति दी जाती है. सबडोमेन से मेल खाने के लिए, वाइल्डकार्ड (जैसे, {"domain":
"*.example.com"}) का इस्तेमाल किया जा सकता है.हालांकि, ध्यान दें कि इससे रूट डोमेन example.com से मेल नहीं खाया जाता. इसे अलग से जोड़ना होगा. अन्य सभी ट्रैफ़िक को अनुमति देने के लिए, {"domain": "*"} को कैच-ऑल एंट्री के तौर पर जोड़ें. जैसे, हेडर इंजेक्ट किए बिना, सूची में शामिल नहीं किए गए डोमेन को रूट करना.
क्रेडेंशियल
हेडर ट्रांसफ़ॉर्मेशन जोड़कर, अपने एजेंट के इस्तेमाल के लिए क्रेडेंशियल जोड़े जा सकते हैं. क्रेडेंशियल को इग्रेस प्रॉक्सी, संबंधित एचटीटीपी हेडर में इंजेक्ट करता है. इन्हें सैंडबॉक्स में कभी भी एनवायरमेंट वैरिएबल या फ़ाइलों के तौर पर नहीं दिखाया जाता.
Python
import subprocess
from google import genai
# Fetch a short-lived access token from your local gcloud CLI
gcloud_token = subprocess.check_output(
["gcloud", "auth", "print-access-token"], text=True
).strip()
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-05-2026",
input="List the files in gs://my-bucket/reports/ using the GCS JSON API.",
environment={
"type": "remote",
"network": {
"allowlist": [
{
"domain": "storage.googleapis.com",
"transform": {
"Authorization": f"Bearer {gcloud_token}"
},
}
]
},
},
)
print(interaction.output_text)
JavaScript
import { GoogleGenAI } from "@google/genai";
import { execSync } from "child_process";
const gcloudToken = execSync("gcloud auth print-access-token").toString().trim();
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "List the files in gs://my-bucket/reports/ using the GCS JSON API.",
environment: {
type: "remote",
network: {
allowlist: [
{
domain: "storage.googleapis.com",
transform: {
"Authorization": `Bearer ${gcloudToken}`
},
}
]
}
},
});
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": "List the files in gs://my-bucket/reports/ using the GCS JSON API.",
"environment": {
"type": "remote",
"network": {
"allowlist": [
{
"domain": "storage.googleapis.com",
"transform": {
"Authorization": "Bearer <YOUR_GCLOUD_TOKEN>"
}
}
]
}
}
}'
नेटवर्क ऐक्सेस करने की सुविधा बंद करना
आउटबाउंड नेटवर्क के सभी ऐक्सेस को ब्लॉक करने के लिए, network को disabled पर सेट करें:
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Analyze the local files only.",
environment={
"type": "remote",
"network": "disabled",
},
)
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: "Analyze the local files only.",
environment: {
type: "remote",
network: "disabled",
},
});
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": "Analyze the local files only.",
"environment": {
"type": "remote",
"network": "disabled"
}
}'
क्रेडेंशियल रीफ़्रेश करना
ऐक्सेस टोकन और कम समय के लिए इस्तेमाल की जा सकने वाली एपीआई कुंजियों जैसे क्रेडेंशियल की समयसीमा खत्म हो जाती है.
अगले इंटरैक्शन में, मौजूदा environment_id के साथ-साथ नया network कॉन्फ़िगरेशन पास करके, उन्हें रीफ़्रेश किया जा सकता है. नई नेटवर्क सेटिंग, पिछली सेटिंग की जगह ले लेती हैं. हालांकि, एनवायरमेंट के फ़ाइल सिस्टम की स्थिति (इंस्टॉल किए गए पैकेज, फ़ाइलें, रिपॉज़िटरी) में कोई बदलाव नहीं होता.
Python
from google import genai
client = genai.Client()
# First interaction: use an initial token
first = client.interactions.create(
agent="antigravity-preview-05-2026",
input="List the files in gs://my-bucket/reports/ using the GCS JSON API.",
environment={
"type": "remote",
"network": {
"allowlist": [
{
"domain": "storage.googleapis.com",
"transform": {
"Authorization": "Bearer INITIAL_TOKEN"
},
}
]
},
},
)
# Later: refresh the token on the same environment
result = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Now download the file reports/q1.csv from the same bucket.",
environment={
"type": "remote",
"environment_id": first.environment_id,
"network": {
"allowlist": [
{
"domain": "storage.googleapis.com",
"transform": {
"Authorization": "Bearer REFRESHED_TOKEN"
},
}
]
},
},
)
print(result.output_text)
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
// First interaction: use an initial token
const first = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "List the files in gs://my-bucket/reports/ using the GCS JSON API.",
environment: {
type: "remote",
network: {
allowlist: [
{
domain: "storage.googleapis.com",
transform: {
"Authorization": "Bearer INITIAL_TOKEN"
},
}
]
}
},
});
// Later: refresh the token on the same environment
const result = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Now download the file reports/q1.csv from the same bucket.",
environment: {
type: "remote",
environment_id: first.environment_id,
network: {
allowlist: [
{
domain: "storage.googleapis.com",
transform: {
"Authorization": "Bearer REFRESHED_TOKEN"
},
}
]
}
},
});
console.log(result.output_text);
REST
# Use the environment_id from a previous interaction
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": "Now download the file reports/q1.csv from the same bucket.",
"environment": {
"type": "remote",
"environment_id": "<ENVIRONMENT_ID_FROM_PREVIOUS_INTERACTION>",
"network": {
"allowlist": [
{
"domain": "storage.googleapis.com",
"transform": {
"Authorization": "Bearer REFRESHED_TOKEN"
}
}
]
}
}
}'
एनवायरमेंट का लाइफ़साइकल
एनवायरमेंट का लाइफ़साइकल इस तरह होता है:
| राज्य | व्यवहार |
|---|---|
| बनाया गया | यह तब उपलब्ध कराया जाता है, जब इंटरैक्शन में environment: "remote" या कॉन्फ़िगरेशन ऑब्जेक्ट के बारे में बताया गया हो. |
| चालू है | यह कुकी तब काम करती है, जब कोई इंटरैक्शन चल रहा हो. |
| इस्तेमाल में नहीं है | ऑटो-स्नैपशॉट की सुविधा चालू है और 15 मिनट तक कोई गतिविधि न होने पर यह बंद हो जाती है. |
| ऑफ़लाइन | पिछली बार ऐक्टिव रहने के बाद, सात दिनों तक सेव रहता है. इसका आईडी पास करके इसे फिर से शुरू किया जा सकता है. |
| मिटाया गया | सिस्टम से हटा दिया गया है. |
एनवायरमेंट से फ़ाइलें डाउनलोड करना
एजेंट, एक्ज़ीक्यूशन के दौरान सैंडबॉक्स में फ़ाइलें बनाता है. Files API का इस्तेमाल करके, पूरे एनवायरमेंट का स्नैपशॉट, tar फ़ाइल के तौर पर डाउनलोड किया जा सकता है:
Python
import os
import requests
import tarfile
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Write a file environments_test.txt with content 'Environments' inside the sandbox.",
environment="remote",
)
env_id = interaction.environment_id
api_key = os.environ.get("GEMINI_API_KEY")
response = requests.get(
f"https://generativelanguage.googleapis.com/v1beta/files/environment-{env_id}:download",
params={"alt": "media"},
headers={"x-goog-api-key": api_key},
allow_redirects=True,
)
with open("snapshot_env.tar", "wb") as f:
f.write(response.content)
os.makedirs("extracted_env_snapshot", exist_ok=True)
with tarfile.open("snapshot_env.tar") as tar:
tar.extractall(path="extracted_env_snapshot")
print(os.listdir("extracted_env_snapshot"))
JavaScript
import { GoogleGenAI } from "@google/genai";
import { execSync } from "child_process";
import * as fs from "fs";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Write a file environments_test.txt with content 'Environments' inside the sandbox.",
environment: "remote",
});
const envId = interaction.environment_id;
const apiKey = process.env.GEMINI_API_KEY || "";
const url = `https://generativelanguage.googleapis.com/v1beta/files/environment-${envId}:download?alt=media`;
const response = await fetch(url, {
headers: {
"x-goog-api-key": apiKey,
},
});
if (!response.ok) {
throw new Error(`Failed to download file: ${response.statusText}`);
}
const buffer = Buffer.from(await response.arrayBuffer());
fs.writeFileSync("snapshot_env.tar", buffer);
if (!fs.existsSync("extracted_env_snapshot")) {
fs.mkdirSync("extracted_env_snapshot");
}
execSync("tar -xf snapshot_env.tar -C extracted_env_snapshot");
console.log(fs.readdirSync("extracted_env_snapshot"));
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": "Write a file environments_test.txt with content '\''Environments'\'' inside the sandbox.",
"environment": "remote"
}'
# Step 2: Download snapshot (reusing environment ID from Step 1)
# curl -L -X GET "https://generativelanguage.googleapis.com/v1beta/files/environment-$ENV_ID:download?alt=media" \
# -H "x-goog-api-key: $API_KEY" \
# -o snapshot.tar
कीमत और संसाधन
हर एनवायरमेंट के लिए, संसाधनों का तय हिस्सा इस्तेमाल किया जाता है:
| संसाधन | मान |
|---|---|
| सीपीयू | 4 कोर |
| मेमोरी | 16 जीबी |
प्रीव्यू पीरियड के दौरान, एनवायरमेंट कंप्यूट (सीपीयू, मेमोरी, सैंडबॉक्स एक्ज़ीक्यूशन) के लिए बिल नहीं भेजा जाता. एजेंट टोकन की लागत के लिए, कीमत देखें.
सीमाएं
- प्रीव्यू का स्टेटस: एनवायरमेंट और मैनेज किए गए एजेंट, प्रीव्यू में हैं. सुविधाओं और स्कीमा में बदलाव हो सकता है.
- इनलाइन सोर्स का साइज़: इनलाइन सोर्स के लिए, हर फ़ाइल का साइज़ 1 एमबी से ज़्यादा नहीं होना चाहिए. साथ ही, सभी फ़ाइलों का कुल साइज़ 2 एमबी से ज़्यादा नहीं होना चाहिए.
- सोर्स का साइज़: Git रिपॉज़िटरी का साइज़ 500 एमबी और Cloud Storage रिपॉज़िटरी का साइज़ 2 जीबी से ज़्यादा नहीं होना चाहिए.
- एनवायरमेंट स्टार्टअप: नया एनवायरमेंट उपलब्ध कराने में ~5 सेकंड लगते हैं. सोर्स रिपॉज़िटरी बड़ी होने पर, इसमें ज़्यादा समय लग सकता है.
- फ़ाइल फ़ॉर्मैट: फ़िलहाल, एजेंट सिर्फ़ टेक्स्ट और इमेज फ़ाइलें पढ़ सकता है. फ़िलहाल, बाइनरी फ़ाइल का इस्तेमाल नहीं किया जा सकता.
- रूट से माउंट नहीं किया जा सकता: कस्टम सोर्स जोड़ते समय, रूट (
/) को टारगेट के तौर पर सेट नहीं किया जा सकता. आपको हमेशा कोई सब-डायरेक्ट्री तय करनी होगी.
आगे क्या करना है
- एजेंट की खास जानकारी: मैनेज किए जाने वाले एजेंट के मुख्य सिद्धांतों के बारे में जानें.
- क्विकस्टार्ट: एक से ज़्यादा बार बातचीत करने और स्ट्रीमिंग की सुविधा का इस्तेमाल शुरू करें.
- Antigravity Agent: डिफ़ॉल्ट एजेंट की सुविधाओं, टूल, और कीमत के बारे में जानें.
- कस्टम एजेंट बनाना:
AGENTS.mdऔरSKILL.mdका इस्तेमाल करके, अपने एजेंट तय करें.