मैनेज किए जा रहे एजेंटों में एनवायरमेंट

एनवायरमेंट, मैनेज किए गए 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" \
-H "Api-Revision: 2026-05-20" \
-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" \
-H "Api-Revision: 2026-05-20" \
-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" \
-H "Api-Revision: 2026-05-20" \
-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" \
-H "Api-Revision: 2026-05-20" \
-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" \
-H "Api-Revision: 2026-05-20" \
-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 पर मौजूद सैंडबॉक्स में किसी फ़ाइल में रॉ टेक्स्ट कॉन्टेंट लिखता है. हर फ़ाइल के लिए एक एमबी, कुल दो एमबी

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" \
-H "Api-Revision: 2026-05-20" \
-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 डेटा स्टोर करने की जगहों के लिए, अपने GitHub Personal Access Token (PAT) के साथ Basic ऑथेंटिकेशन का इस्तेमाल करें. टोकन को 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" \
-H "Api-Revision: 2026-05-20" \
-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 Bearer टोकन का इस्तेमाल करें:

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" \
-H "Api-Revision: 2026-05-20" \
-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 ऑब्जेक्ट तय किया जाता है. ये हेडर, हर इंटरैक्शन के लिए अलग-अलग हो सकते हैं. साथ ही, इन्हें एक ही एनवायरमेंट के लिए अपडेट किया जा सकता है.

फ़ील्ड टाइप ब्यौरा
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" \
-H "Api-Revision: 2026-05-20" \
-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" \
-H "Api-Revision: 2026-05-20" \
-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" \
-H "Api-Revision: 2026-05-20" \
-d '{
    "agent": "antigravity-preview-05-2026",
    "input": "Analyze the local files only.",
    "environment": {
        "type": "remote",
        "network": "disabled"
    }
}'

एनवायरमेंट की लाइफ़साइकल

एनवायरमेंट की लाइफ़साइकल इस तरह होती है:

राज्य व्यवहार
बनाया गया जब कोई इंटरैक्शन, environment: "remote" या कॉन्फ़िगरेशन ऑब्जेक्ट तय करता है, तब यह उपलब्ध कराया जाता है.
चालू है इंटरैक्शन के दौरान चलता है.
कुछ समय से इस्तेमाल में नहीं है 15 मिनट तक कोई गतिविधि न होने पर, ऑटो-स्नैपशॉट लिया जाता है और यह बंद हो जाता है.
ऑफ़लाइन पिछली बार चालू होने के बाद, सात दिनों तक बना रहता है. इसकी आईडी पास करके, इसे फिर से शुरू किया जा सकता है.
मिटाया गया इसे सिस्टम से हटा दिया गया है.

एनवायरमेंट से फ़ाइलें डाउनलोड करना

एजेंट, एक्ज़ीक्यूशन के दौरान सैंडबॉक्स में फ़ाइलें बनाता है. Files API का इस्तेमाल करके, पूरे एनवायरमेंट का स्नैपशॉट, टार फ़ाइल के तौर पर डाउनलोड किया जा सकता है:

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" \
-H "Api-Revision: 2026-05-20" \
-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

कीमत और संसाधन

हर एनवायरमेंट, तय किए गए संसाधन के साथ चलता है:

संसाधन मान
सीपीयू चार कोर
मेमोरी 16 जीबी

प्रीव्यू की अवधि के दौरान, एनवायरमेंट कंप्यूट (सीपीयू, मेमोरी, सैंडबॉक्स एक्ज़ीक्यूशन) के लिए बिल नहीं भेजा जाता. एजेंट टोकन की लागत के बारे में जानने के लिए, कीमत देखें.

सीमाएं

  • प्रीव्यू की स्थिति: एनवायरमेंट और मैनेज किए गए एजेंट, प्रीव्यू में हैं. इनकी सुविधाओं और स्कीमा में बदलाव हो सकता है.
  • इनलाइन सोर्स का साइज़: इनलाइन सोर्स, हर फ़ाइल के लिए एक एमबी और सभी फ़ाइलों के लिए कुल दो एमबी तक सीमित हैं.
  • सोर्स का साइज़: Git डेटा स्टोर करने की जगहें 500 एमबी और Cloud Storage डेटा स्टोर करने की जगहें दो जीबी तक सीमित हैं.
  • एनवायरमेंट स्टार्टअप: नया एनवायरमेंट उपलब्ध कराने में, करीब पांच सेकंड लगते हैं. बड़े सोर्स वाले डेटा स्टोर करने की जगहों की वजह से, इसमें ज़्यादा समय लग सकता है.
  • फ़ाइल फ़ॉर्मैट: फ़िलहाल, एजेंट सिर्फ़ टेक्स्ट और इमेज फ़ाइलें पढ़ सकता है. बाइनरी फ़ाइलें पढ़ने की सुविधा अभी उपलब्ध नहीं है.
  • रूट से माउंट करने की सुविधा नहीं: कस्टम सोर्स जोड़ते समय, रूट (/) को टारगेट के तौर पर सेट नहीं किया जा सकता. इसके लिए, हमेशा सब-डायरेक्ट्री तय करनी होगी.

आगे क्या करना है

  • एजेंट की खास जानकारी: मैनेज किए गए एजेंट के मुख्य कॉन्सेप्ट के बारे में जानें.
  • क्विकस्टार्ट: कई राउंड वाले बातचीत और स्ट्रीमिंग की सुविधा के साथ एजेंट बनाना शुरू करें.
  • Antigravity Agent: डिफ़ॉल्ट एजेंट की क्षमताओं, टूल, और कीमत के बारे में जानें.
  • कस्टम एजेंट बनाना: AGENTS.md और SKILL.md का इस्तेमाल करके, अपने एजेंट तय करें.