סביבות הן ארגזי חול מנוהלים של 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