# Step 1: Set up the environment interactively
RESPONSE=$(curl -s -X POST https://generativelanguage.googleapis.com/v1beta/interactions \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-H "Api-Revision: 2026-05-20" \
-d '{
"agent": "antigravity-preview-05-2026",
"input": "Write a basic Hello World template to /workspace/template.py.",
"environment": "remote"
}')
ENV_ID=$(echo $RESPONSE | python3 -c "import sys,json; print(json.load(sys.stdin)['environment_id'])")
# Step 2: Fork that environment into a named agent
curl -X POST https://generativelanguage.googleapis.com/v1beta/agents \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-H "Api-Revision: 2026-05-20" \
-d "{
\"id\": \"my-data-analyst\",
\"base_agent\": \"antigravity-preview-05-2026\",
\"system_instruction\": \"You are a data analyst. Use the template at /workspace/template.py for all reports.\",
\"base_environment\": \"$ENV_ID\"
}"
import uuid
from google import genai
client = genai.Client()
# Step 1: Set up the environment interactively.
interaction = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Write a basic Hello World template to /workspace/template.py.",
environment="remote",
)
# Step 2: Fork that environment into a named agent.
agent_id = f"my-data-analyst-{uuid.uuid4().hex[:8]}"
agent = client.agents.create(
id=agent_id,
base_agent="antigravity-preview-05-2026",
system_instruction="You are a data analyst. Use the template at /workspace/template.py for all reports.",
base_environment=interaction.environment_id,
)
print(f"Forked agent: {agent.id}")
import {GoogleGenAI} from '@google/genai';
const ai = new GoogleGenAI({});
// Step 1: Set up the environment interactively.
const interaction = await ai.interactions.create({
agent: 'antigravity-preview-05-2026',
input: 'Write a basic Hello World template to /workspace/template.py.',
environment: 'remote',
});
// Step 2: Fork that environment into a named agent.
const agentId = `my-data-analyst-${crypto.randomUUID().slice(0, 8)}`;
const agent = await ai.agents.create({
id: agentId,
base_agent: 'antigravity-preview-05-2026',
system_instruction: 'You are a data analyst. Use the template at /workspace/template.py for all reports.',
base_environment: interaction.environment_id,
});
console.log(`Forked agent: ${agent.id}`);