# Step 1: Create an interaction with a fresh remote environment.
RESPONSE=$(curl -s -X POST https://generativelanguage.googleapis.com/v1beta/interactions \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"agent": "antigravity-preview-05-2026",
"input": "Write a hello world script at /workspace/hello.py.",
"environment": "remote"
}')
INTERACTION_ID=$(echo $RESPONSE | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")
ENV_ID=$(echo $RESPONSE | python3 -c "import sys,json; print(json.load(sys.stdin)['environment_id'])")
# Step 2: Reuse the same environment in a follow-up interaction.
curl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d "{
\"agent\": \"antigravity-preview-05-2026\",
\"input\": \"Modify the script to accept a name argument and greet the user.\",
\"environment\": \"$ENV_ID\",
\"previous_interaction_id\": \"$INTERACTION_ID\"
}"
from google import genai
client = genai.Client()
# Step 1: Create an interaction with a fresh remote environment.
interaction = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Write a hello world script at /workspace/hello.py.",
environment="remote",
)
print(f"Environment ID: {interaction.environment_id}")
# Step 2: Reuse the same environment in a follow-up interaction.
interaction_2 = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Modify the script to accept a name argument and greet the user.",
environment=interaction.environment_id,
previous_interaction_id=interaction.id,
)
print(interaction_2.output_text)
import {GoogleGenAI} from '@google/genai';
const ai = new GoogleGenAI({});
// Step 1: Create an interaction with a fresh remote environment.
const interaction = await ai.interactions.create({
agent: 'antigravity-preview-05-2026',
input: 'Write a hello world script at /workspace/hello.py.',
environment: 'remote',
});
console.log(`Environment ID: ${interaction.environment_id}`);
// Step 2: Reuse the same environment in a follow-up interaction.
const interaction2 = await ai.interactions.create({
agent: 'antigravity-preview-05-2026',
input: 'Modify the script to accept a name argument and greet the user.',
environment: interaction.environment_id,
previous_interaction_id: interaction.id,
});
console.log(interaction2.output_text);
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.CreateInteractionResponse;
Client client = new Client();
// Step 1: Create an interaction with a fresh remote environment.
CreateAgentInteraction params1 =
CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-05-2026"))
.input(InteractionsInput.of("Write a hello world script at /workspace/hello.py."))
.environment(CreateAgentInteractionEnvironment.of("remote"))
.build();
CreateInteractionResponse response1 =
client.interactions.create(CreateInteractionRequestBody.of(params1));
Interaction interaction1 =
response1.interaction().orElseThrow(() -> new RuntimeException("No interaction returned"));
System.out.println("Environment ID: " + interaction1.environmentId().orElse(""));
// Step 2: Reuse the same environment in a follow-up interaction.
CreateAgentInteraction params2 =
CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-05-2026"))
.input(InteractionsInput.of("Modify the script to accept a name argument and greet the user."))
.environment(CreateAgentInteractionEnvironment.of(interaction1.environmentId().orElse("")))
.previousInteractionId(interaction1.id().orElse(null))
.build();
CreateInteractionResponse response2 =
client.interactions.create(CreateInteractionRequestBody.of(params2));
Interaction interaction2 =
response2.interaction().orElseThrow(() -> new RuntimeException("No interaction returned"));
System.out.println(interaction2.outputText().orElse(""));