# 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.gaos.models.interactions.AgentOption;
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.CreateInteractionResponse;
import com.google.genai.gaos.models.environments.Environment;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Step;
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(""));
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
gaos_interactions "google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
// Step 1: Create an interaction with a fresh remote environment.
body1 := operations.NewCreateInteractionRequestBody(gaos_interactions.CreateAgentInteraction{
Agent: gaos_interactions.AgentOption("antigravity-preview-05-2026"),
Input: genai.Ptr(gaos_interactions.NewInteractionsInput("Write a hello world script at /workspace/hello.py.")),
Environment: genai.Ptr(gaos_interactions.NewCreateAgentInteractionEnvironment("remote")),
})
res1, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{Body: body1})
if err != nil {
log.Fatal(err)
}
if res1.Interaction == nil || res1.Interaction.EnvironmentID == nil {
log.Fatal("No environment ID returned")
}
fmt.Printf("Environment ID: %s\n", *res1.Interaction.EnvironmentID)
// Step 2: Reuse the same environment in a follow-up interaction.
body2 := operations.NewCreateInteractionRequestBody(gaos_interactions.CreateAgentInteraction{
Agent: gaos_interactions.AgentOption("antigravity-preview-05-2026"),
Input: genai.Ptr(gaos_interactions.NewInteractionsInput("Modify the script to accept a name argument and greet the user.")),
Environment: genai.Ptr(gaos_interactions.NewCreateAgentInteractionEnvironment(*res1.Interaction.EnvironmentID)),
PreviousInteractionID: res1.Interaction.ID,
})
res2, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{Body: body2})
if err != nil {
log.Fatal(err)
}
if res2.Interaction != nil && res2.Interaction.OutputText != nil {
fmt.Println(*res2.Interaction.OutputText)
}
}