Antigravity 에이전트
Antigravity 에이전트 (Antigravity Agent)
Antigravity 에이전트는 Gemini API의 범용 관리형 에이전트예요. API 호출 한 번만 하면 Google이 호스팅하는 나만의 안전한 Linux 샌드박스 안에서 추론하고, 코드를 실행하고, 파일을 관리하고, 웹을 탐색하는 에이전트를 얻을 수 있어요.
Gemini 3.8 Flash로 만들어졌고 Antigravity IDE와 같은 하네스를 사용해요. agent_config로 기본 Gemini 모델을 설정할 수 있고, Interactions API와 Google AI Studio에서 사용할 수 있어요.
출처: 문서
본문
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
input="Read Hacker News, summarize the top 10 stories, and save the results as a PDF.",
environment="remote",
)
print(interaction.output_text)
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "Read Hacker News, summarize the top 10 stories, and save the results as a PDF.",
environment: "remote",
}, { timeout: 300000 });
console.log(interaction.output_text);
Java
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;
Client client = new Client();
CreateAgentInteraction params = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("Read Hacker News, summarize the top 10 stories, and save the results as a PDF."))
.environment(CreateAgentInteractionEnvironment.of("remote"))
.build();
Interaction interaction = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
System.out.println(interaction.outputText().orElse(""));
Go
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"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)
}
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
Input: interactions.NewInteractionsInput("Read Hacker News, summarize the top 10 stories, and save the results as a PDF."),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment("remote")),
}),
})
if err != nil {
log.Fatal(err)
}
if res.Interaction.OutputText != nil {
fmt.Println(*res.Interaction.OutputText)
}
}
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-09-2026",
"input": "Read Hacker News, summarize the top 10 stories, and save the results as a PDF.",
"environment": "remote"
}'
기능 (Capabilities)
호출할 때마다 Linux 샌드박스를 준비하고 도구 사용 루프(tool-use loop)를 시작해요. 에이전트는 계획을 세우고, 행동하고, 결과를 관찰하고, 작업이 끝날 때까지 반복해요.
- 코드 실행(Code execution): Bash, Python, Node.js 명령어를 실행해요. 패키지를 설치하고, 테스트를 돌리고, 앱을 빌드할 수 있어요.
- 파일 관리(File management): 샌드박스 안에서 파일을 읽고, 쓰고, 편집하고, 검색하고, 나열해요. 파일은 상호작용(interaction) 간에도 유지돼요.
- 웹 접근(Web access): 데이터를 위해 Google Search와 URL 가져오기를 사용해요.
- 컨텍스트 압축(Context compaction): 자동 컨텍스트 압축(~135k 토큰에서 트리거)으로 컨텍스트를 잃거나 토큰 한도에 걸리지 않고 오래 지속되는 다중 턴 세션을 지원해요.
멀티 턴 사용과 스트리밍은 Quickstart 문서를 참고하세요.
지원되는 도구 (Supported tools)
기본적으로 에이전트는 code_execution, google_search, url_context에 접근할 수 있어요. environment 파라미터를 지정하면 파일시스템 도구가 자동으로 활성화돼요. 에이전트를 나만의 API와 도구에 연결하려면 **커스텀 함수(custom functions)**를 정의할 수도 있어요. 기본 도구 세트를 커스터마이징하거나 제한하거나, 커스텀 함수를 추가할 때만 tools 파라미터를 지정하면 돼요.
| 도구 | 타입 값 | 설명 |
|---|---|---|
| Code Execution | code_execution |
stdout/stderr 캡처와 함께 셸 명령어(bash, Python, Node)를 실행해요. |
| Google Search | google_search |
공개 웹을 검색해요. |
| URL Context | url_context |
웹 페이지를 가져와 읽어요. |
| Filesystem | (via environment로 활성화) |
샌드박스 안에서 파일을 읽고, 쓰고, 편집하고, 검색하고, 나열해요. environment를 설정하면 시스템이 이 도구들을 자동으로 활성화해요. |
| Custom Functions | function |
에이전트가 실행하도록 요청할 수 있는 커스텀 함수를 정의해요. Function calling 참고. |
| Remote MCP Server | mcp_server |
외부 Model Context Protocol (MCP) 서버를 도구로 등록해요. MCP servers 참고. |
동기식 Hooks를 사용해 원격 샌드박스 안에서 code_execution과 filesystem 도구 실행을 가로채고 검증할 수 있어요.
에이전트를 특정 도구로 제한하려면 필요한 도구만 전달하면 돼요.
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
input="Search for the latest AI research papers on reasoning and summarize them.",
environment="remote",
tools=[
{"type": "google_search"},
{"type": "url_context"},
],
)
print(interaction.output_text)
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "Search for the latest AI research papers on reasoning and summarize them.",
environment: "remote",
tools: [
{ type: "google_search" },
{ type: "url_context" },
],
}, { timeout: 300000 });
console.log(interaction.output_text);
Java
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.GoogleSearch;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.URLContext;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.List;
Client client = new Client();
CreateAgentInteraction params = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("Search for the latest AI research papers on reasoning and summarize them."))
.environment(CreateAgentInteractionEnvironment.of("remote"))
.tools(List.of(
GoogleSearch.builder().build(),
URLContext.builder().build()
))
.build();
Interaction interaction = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
System.out.println(interaction.outputText().orElse(""));
Go
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"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)
}
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
Input: interactions.NewInteractionsInput("Search for the latest AI research papers on reasoning and summarize them."),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment("remote")),
Tools: []interactions.Tool{
interactions.NewTool(interactions.GoogleSearch{}),
interactions.NewTool(interactions.URLContext{}),
},
}),
})
if err != nil {
log.Fatal(err)
}
if res.Interaction.OutputText != nil {
fmt.Println(*res.Interaction.OutputText)
}
}
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-09-2026",
"input": "Search for the latest AI research papers on reasoning and summarize them.",
"environment": "remote",
"tools": [
{"type": "google_search"},
{"type": "url_context"}
]
}'
멀티모달 입력 (Multimodal Input)
Antigravity 에이전트는 멀티모달 입력을 지원해요. 현재는 text와 image 입력만 지원해요. 이미지는 인라인 base64-encoded 문자열(data)로 제공해야 해요.
Python
import base64
from google import genai
client = genai.Client()
with open("path/to/chart.png", "rb") as f:
image_bytes = f.read()
interaction_inline = client.interactions.create(
agent="antigravity-preview-09-2026",
input=[
{"type": "text", "text": "Analyze this chart and summarize the trends."},
{
"type": "image",
"data": base64.b64encode(image_bytes).decode("utf-8"),
"mime_type": "image/png",
},
],
environment="remote",
)
JavaScript
import { GoogleGenAI } from "@google/genai";
import * as fs from "node:fs";
const client = new GoogleGenAI({});
const base64Image = fs.readFileSync("path/to/chart.png", { encoding: "base64" });
const interactionInline = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: [
{ type: "text", text: "Analyze this chart and summarize the trends." },
{
type: "image",
data: base64Image,
mime_type: "image/png",
},
],
environment: "remote",
}, { timeout: 300000 });
Java
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.ImageContent;
import com.google.genai.gaos.models.interactions.ImageContentMimeType;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.TextContent;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Base64;
import java.util.List;
Client client = new Client();
byte[] imageBytes = Files.readAllBytes(Paths.get("path/to/chart.png"));
String base64Image = Base64.getEncoder().encodeToString(imageBytes);
CreateAgentInteraction params = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.ofContent(List.of(
TextContent.builder().text("Analyze this chart and summarize the trends.").build(),
ImageContent.builder()
.data(base64Image)
.mimeType(ImageContentMimeType.IMAGE_PNG)
.build()
)))
.environment(CreateAgentInteractionEnvironment.of("remote"))
.build();
Interaction interactionInline = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
System.out.println(interactionInline.outputText().orElse(""));
Go
package main
import (
"context"
"encoding/base64"
"fmt"
"log"
"os"
"google.golang.org/genai"
"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)
}
imageBytes, err := os.ReadFile("path/to/chart.png")
if err != nil {
log.Fatal(err)
}
base64Image := base64.StdEncoding.EncodeToString(imageBytes)
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
Input: interactions.NewInteractionsInput([]interactions.Content{
interactions.NewContent(interactions.TextContent{
Text: "Analyze this chart and summarize the trends.",
}),
interactions.NewContent(interactions.ImageContent{
Data: genai.Ptr(base64Image),
MimeType: interactions.ImageContentMimeTypeImagePng.ToPointer(),
}),
}),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment("remote")),
}),
})
if err != nil {
log.Fatal(err)
}
if res.Interaction.OutputText != nil {
fmt.Println(*res.Interaction.OutputText)
}
}
REST
BASE64_IMAGE=$(base64 -w0 /path/to/chart.png)
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-09-2026\",
\"input\": [
{\"type\": \"text\", \"text\": \"Analyze this chart and summarize the trends.\"},
{
\"type\": \"image\",
\"mime_type\": \"image/png\",
\"data\": \"$BASE64_IMAGE\"
}
],
\"environment\": \"remote\"
}"
함수 호출 (Function calling)
Function calling을 쓰면 에이전트가 호출할 수 있는 커스텀 도구를 정의해 Antigravity 에이전트를 외부 API와 데이터베이스에 연결할 수 있어요. 일반적인 개념은 Gemini API의 Function calling 문서를 참고하세요.
아래 예시는 2턴 상호작용을 보여줘요. 에이전트가 먼저 커스텀 get_weather 함수 호출을 요청하고, 클라이언트가 이를 실행해 두 번째 턴에서 결과를 돌려주는 방식이에요.
Python
from google import genai
client = genai.Client()
# 1. Define the custom function
get_weather_tool = {
"type": "function",
"name": "get_weather",
"description": "Gets the current weather for a given location.",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and country, e.g. San Francisco, USA",
}
},
"required": ["location"],
},
}
# 2. Call the agent with the custom tool (Turn 1)
interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
input="What is the weather in Tokyo?",
environment="remote",
tools=[
{"type": "code_execution"}, # Enable default code execution
get_weather_tool, # Add custom function
],
)
# Check if the agent requested a function call
if interaction.status == "requires_action":
# Find function calls that do not have a matching function result.
# Filesystem tools (like write_to_file) are also represented as function calls
# but are executed automatically by the environment.
executed_calls = {step.call_id for step in interaction.steps if step.type == "function_result"}
pending_calls = [step for step in interaction.steps if step.type == "function_call" and step.id not in executed_calls]
if pending_calls:
fc_step = pending_calls[0]
print(f"Function to call: {fc_step.name} (ID: {fc_step.id})")
print(f"Arguments: {fc_step.arguments}")
# 3. Execute the function locally (simulated get_weather()) and send the result back (Turn 2)
function_result = {
"temperature": 23,
"unit": "celsius"
}
final_interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
previous_interaction_id=interaction.id, # Reference the interaction ID
environment=interaction.environment_id,
input=[
{
"type": "function_result",
"name": fc_step.name,
"call_id": fc_step.id,
"result": function_result,
}
],
)
print(final_interaction.output_text)
# Output: The current weather in Tokyo, Japan is 23°C (Celsius).
else:
print("No pending function calls.")
else:
print(f"Interaction completed with status: {interaction.status}")
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
// 1. Define the custom function
const get_weather_tool = {
type: "function",
name: "get_weather",
description: "Gets the current weather for a given location.",
parameters: {
type: "object",
properties: {
location: {
type: "string",
description: "The city and country, e.g. San Francisco, USA",
},
},
required: ["location"],
},
};
// 2. Call the agent with the custom tool (Turn 1)
const interaction = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "What is the weather in Tokyo?",
environment: "remote",
tools: [
{ type: "code_execution" },
get_weather_tool,
],
}, { timeout: 300000 });
if (interaction.status === "requires_action") {
// Find function calls that do not have a matching function result.
// Filesystem tools (like write_to_file) are also represented as function calls
// but are executed automatically by the environment.
const executedCalls = new Set(
interaction.steps
.filter(s => s.type === "function_result")
.map(s => s.call_id)
);
const pendingCalls = interaction.steps.filter(
s => s.type === "function_call" && !executedCalls.has(s.id)
);
if (pendingCalls.length > 0) {
const fcStep = pendingCalls[0];
console.log(`Function to call: ${fcStep.name} (ID: ${fcStep.id})`);
// 3. Execute the function locally (simulated get_weather()) and send the result back (Turn 2)
const functionResult = {
temperature: 23,
unit: "celsius"
};
const finalInteraction = await client.interactions.create({
agent: "antigravity-preview-09-2026",
previous_interaction_id: interaction.id, // Reference the interaction ID
environment: interaction.environment_id,
input: [
{
type: "function_result",
name: fcStep.name,
call_id: fcStep.id,
result: functionResult,
}
],
}, { timeout: 300000 });
console.log(finalInteraction.output_text);
} else {
console.log("No pending function calls.");
}
} else {
console.log(`Interaction completed with status: ${interaction.status}`);
}
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.CodeExecution;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
import com.google.genai.gaos.models.interactions.Function;
import com.google.genai.gaos.models.interactions.FunctionCallStep;
import com.google.genai.gaos.models.interactions.FunctionResultStep;
import com.google.genai.gaos.models.interactions.FunctionResultStepResultUnion;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionStatus;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Step;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
Client client = new Client();
// 1. Define the custom function
Function getWeatherTool = Function.builder()
.name("get_weather")
.description("Gets the current weather for a given location.")
.parameters(Map.of(
"type", "object",
"properties", Map.of(
"location", Map.of(
"type", "string",
"description", "The city and country, e.g. San Francisco, USA"
)
),
"required", List.of("location")
))
.build();
// 2. Call the agent with the custom tool (Turn 1)
CreateAgentInteraction params = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("What is the weather in Tokyo?"))
.environment(CreateAgentInteractionEnvironment.of("remote"))
.tools(List.of(
CodeExecution.builder().build(), // Enable default code execution
getWeatherTool // Add custom function
))
.build();
Interaction interaction = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
// Check if the agent requested a function call
if (interaction.status().orElse(null) == InteractionStatus.REQUIRES_ACTION) {
// Find function calls that do not have a matching function result.
List<Step> steps = interaction.steps().orElse(List.of());
Set<String> executedCalls = steps.stream()
.filter(step -> step instanceof FunctionResultStep)
.map(step -> ((FunctionResultStep) step).callId().orElse(""))
.collect(Collectors.toSet());
List<FunctionCallStep> pendingCalls = steps.stream()
.filter(step -> step instanceof FunctionCallStep)
.map(step -> (FunctionCallStep) step)
.filter(fc -> !executedCalls.contains(fc.id().orElse("")))
.collect(Collectors.toList());
if (!pendingCalls.isEmpty()) {
FunctionCallStep fcStep = pendingCalls.get(0);
System.out.println("Function to call: " + fcStep.name().orElse("") + " (ID: " + fcStep.id().orElse("") + ")");
System.out.println("Arguments: " + fcStep.arguments().orElse(Map.of()));
// 3. Execute the function locally (simulated get_weather()) and send the result back (Turn 2)
FunctionResultStep resultStep = FunctionResultStep.builder()
.name(fcStep.name().orElse(""))
.callId(fcStep.id().orElse(""))
.result(FunctionResultStepResultUnion.of("{\"temperature\": 23, \"unit\": \"celsius\"}"))
.build();
CreateAgentInteraction followupParams = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.previousInteractionId(interaction.id().orElse(""))
.environment(CreateAgentInteractionEnvironment.of(interaction.environmentId().orElse("")))
.input(InteractionsInput.ofStep(List.of(resultStep)))
.build();
Interaction finalInteraction = client.interactions.create(CreateInteractionRequestBody.of(followupParams)).interaction().get();
System.out.println(finalInteraction.outputText().orElse(""));
// Output: The current weather in Tokyo, Japan is 23°C (Celsius).
} else {
System.out.println("No pending function calls.");
}
} else {
System.out.println("Interaction completed with status: " + interaction.status().orElse(null));
}
Go
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"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)
}
// 1. Define the custom function
getWeatherTool := interactions.NewTool(interactions.Function{
Name: genai.Ptr("get_weather"),
Description: genai.Ptr("Gets the current weather for a given location."),
Parameters: map[string]any{
"type": "object",
"properties": map[string]any{
"location": map[string]any{
"type": "string",
"description": "The city and country, e.g. San Francisco, USA",
},
},
"required": []string{"location"},
},
})
// 2. Call the agent with the custom tool (Turn 1)
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
Input: interactions.NewInteractionsInput("What is the weather in Tokyo?"),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment("remote")),
Tools: []interactions.Tool{
interactions.NewTool(interactions.CodeExecution{}), // Enable default code execution
getWeatherTool, // Add custom function
},
}),
})
if err != nil {
log.Fatal(err)
}
interaction := res.Interaction
// Check if the agent requested a function call
if interaction.Status == interactions.InteractionStatusRequiresAction {
executedCalls := make(map[string]bool)
for _, step := range interaction.Steps {
if fr := step.FunctionResultStep; fr != nil {
executedCalls[fr.CallID] = true
}
}
var pendingCalls []*interactions.FunctionCallStep
for _, step := range interaction.Steps {
if fc := step.FunctionCallStep; fc != nil && !executedCalls[fc.ID] {
pendingCalls = append(pendingCalls, fc)
}
}
if len(pendingCalls) > 0 {
fcStep := pendingCalls[0]
fmt.Printf("Function to call: %s (ID: %s)\n", fcStep.Name, fcStep.ID)
fmt.Printf("Arguments: %v\n", fcStep.Arguments)
// 3. Execute the function locally (simulated get_weather()) and send the result back (Turn 2)
resultStep := interactions.FunctionResultStep{
Name: genai.Ptr(fcStep.Name),
CallID: fcStep.ID,
Result: interactions.NewFunctionResultStepResultUnion(`{"temperature": 23, "unit": "celsius"}`),
}
followupRes, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
PreviousInteractionID: interaction.ID,
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment(*interaction.EnvironmentID)),
Input: interactions.NewInteractionsInput([]interactions.Step{
interactions.NewStep(resultStep),
}),
}),
})
if err != nil {
log.Fatal(err)
}
if followupRes.Interaction.OutputText != nil {
fmt.Println(*followupRes.Interaction.OutputText)
}
} else {
fmt.Println("No pending function calls.")
}
} else {
fmt.Printf("Interaction completed with status: %s\n", interaction.Status)
}
}
REST
# 1. Turn 1: Request function call
RESPONSE=$(curl -s -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-09-2026",
"input": "What is the weather in Tokyo?",
"environment": "remote",
"tools": [
{"type": "code_execution"},
{
"type": "function",
"name": "get_weather",
"description": "Gets the current weather for a given location.",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string"}
},
"required": ["location"]
}
}
]
}')
# Extract interaction ID, environment ID, and call ID (requires jq)
INTERACTION_ID=$(echo $RESPONSE | jq -r '.id')
ENVIRONMENT_ID=$(echo $RESPONSE | jq -r '.environment_id')
CALL_ID=$(echo $RESPONSE | jq -r '.steps[] | select(.type=="function_call") | .id')
# 2. Turn 2: Send function result back using variables
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-09-2026\",
\"previous_interaction_id\": \"$INTERACTION_ID\",
\"environment\": \"$ENVIRONMENT_ID\",
\"input\": [
{
\"type\": \"function_result\",
\"name\": \"get_weather\",
\"call_id\": \"$CALL_ID\",
\"result\": {
\"temperature\": 23,
\"unit\": \"celsius\"
}
}
]
}"
MCP 서버 (MCP servers)
원격 Model Context Protocol (MCP) 서버를 등록하면 Antigravity 에이전트를 외부 도구에 연결할 수 있어요. 에이전트는 streamable HTTP를 통한 원격 MCP 서버를 지원해요.
MCP 서버를 등록할 때는 tools 배열에 다음 필드를 지정해야 해요.
| 필드 | 타입 | 필수 | 설명 |
|---|---|---|---|
type |
string | 예 | "mcp_server"여야 해요. |
name |
string | 예 | 서버의 고유 식별자예요. 반드시 소문자와 영숫자(^[a-z0-9_-]+$에 일치)여야 해요. |
url |
string | 예 | 원격 MCP 서버의 엔드포인트 URL이에요. |
headers |
object | 아니요 | 요청과 함께 보낼 커스텀 헤더(예: 인증)예요. |
allowed_tools |
array | 아니요 | 실행이 허용되는 도구 이름 목록이에요. 생략하면 모든 도구가 허용돼요. |
Python
from google import genai
client = genai.Client()
# Register a remote HTTP MCP server
interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
input="What is the weather in Tokyo?",
environment="remote",
tools=[{
"type": "mcp_server",
"name": "weather", # Must be lowercase
"url": "https://gemini-api-demos.uc.r.appspot.com/mcp"
}]
)
print(interaction.output_text)
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "What is the weather in Tokyo?",
environment: "remote",
tools: [{
type: "mcp_server",
name: "weather", // Must be lowercase
url: "https://gemini-api-demos.uc.r.appspot.com/mcp"
}]
}, { timeout: 300000 });
console.log(interaction.output_text);
Java
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.interactions.MCPServer;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.List;
Client client = new Client();
// Register a remote HTTP MCP server
CreateAgentInteraction params = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("What is the weather in Tokyo?"))
.environment(CreateAgentInteractionEnvironment.of("remote"))
.tools(List.of(
MCPServer.builder()
.name("weather") // Must be lowercase
.url("https://gemini-api-demos.uc.r.appspot.com/mcp")
.build()
))
.build();
Interaction interaction = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
System.out.println(interaction.outputText().orElse(""));
Go
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"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)
}
// Register a remote HTTP MCP server
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
Input: interactions.NewInteractionsInput("What is the weather in Tokyo?"),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment("remote")),
Tools: []interactions.Tool{
interactions.NewTool(interactions.MCPServer{
Name: genai.Ptr("weather"), // Must be lowercase
URL: genai.Ptr("https://gemini-api-demos.uc.r.appspot.com/mcp"),
}),
},
}),
})
if err != nil {
log.Fatal(err)
}
if res.Interaction.OutputText != nil {
fmt.Println(*res.Interaction.OutputText)
}
}
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-09-2026",
"input": "What is the weather in Tokyo?",
"environment": "remote",
"tools": [{
"type": "mcp_server",
"name": "weather",
"url": "https://gemini-api-demos.uc.r.appspot.com/mcp"
}]
}'
모델 선택 (Model selection)
antigravity-preview-09-2026의 기본 모델은 Gemini 3.8 Flash(gemini-3.8-flash)예요. agent_config를 생략하면 에이전트는 gemini-3.8-flash를 기본값으로 사용해요.
agent_config로 기본 Gemini 모델을 설정해 속도, 비용, 추론 능력에 맞게 최적화할 수 있어요.
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
input="Summarize the key differences between functional and object-oriented programming.",
environment="remote",
agent_config={
"type": "antigravity",
"model": "gemini-3.5-flash-lite",
},
)
print(interaction.output_text)
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "Summarize the key differences between functional and object-oriented programming.",
environment: "remote",
agent_config: {
type: "antigravity",
model: "gemini-3.5-flash-lite",
},
}, { timeout: 300000 });
console.log(interaction.output_text);
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.AntigravityAgentConfig;
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;
Client client = new Client();
CreateAgentInteraction params = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("Summarize the key differences between functional and object-oriented programming."))
.environment(CreateAgentInteractionEnvironment.of("remote"))
.agentConfig(
AntigravityAgentConfig.builder()
.model("gemini-3.5-flash-lite")
.build()
)
.build();
Interaction interaction = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
System.out.println(interaction.outputText().orElse(""));
Go
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"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)
}
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
Input: interactions.NewInteractionsInput("Summarize the key differences between functional and object-oriented programming."),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment("remote")),
AgentConfig: genai.Ptr(interactions.NewCreateAgentInteractionAgentConfig(interactions.AntigravityAgentConfig{
Model: genai.Ptr("gemini-3.5-flash-lite"),
})),
}),
})
if err != nil {
log.Fatal(err)
}
if res.Interaction.OutputText != nil {
fmt.Println(*res.Interaction.OutputText)
}
}
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-09-2026",
"input": "Summarize the key differences between functional and object-oriented programming.",
"environment": "remote",
"agent_config": {
"type": "antigravity",
"model": "gemini-3.5-flash-lite"
}
}'
agent_config.model에 지원되는 값은 다음과 같아요.
| 모델 | agent_config.model 값 |
설명 |
|---|---|---|
| Gemini 3.8 Flash (기본) | gemini-3.8-flash |
추론, 코딩, 도구 사용에 균형 잡힌 기본 모델이에요. |
| Gemini 3.7 Flash | gemini-3.7-flash |
추론, 코딩, 에이전트 워크플로를 위한 이전 세대 Flash 모델이에요. |
| Gemini 3.6 Flash | gemini-3.6-flash |
일반 에이전트 워크플로를 위한 균형 잡힌 Flash 모델이에요. |
| Gemini 3.5 Flash | gemini-3.5-flash |
일반 워크플로를 위한 경량 모델이에요. |
| Gemini 3.5 Flash-Lite | gemini-3.5-flash-lite |
낮은 지연 시간과 비용에 민감한 작업에 최적화된 경량 모델이에요. |
agents.create로 관리형 에이전트를 만들 때도 base_agent와 agent_config를 전달해 정확히 같은 방식으로 모델을 설정해요. agents.create로 만든 관리형 에이전트는 상호작용 시점에 모델을 재정의할 수 없다는 점에 주의하세요. 에이전트 생성 시 설정한 모델로 고정돼요. 이 덕분에 도구 호출 동작을 예측할 수 있고, 디버깅이 일관되며, 보안 경계를 지킬 수 있어요.
에이전트 커스터마이징 (Customizing the agent)
Antigravity 에이전트는 지침, 도구, 환경을 커스터마이징해 확장할 수 있어요. 에이전트는 파일시스템 기반의 커스터마이징 방식을 지원해요. 지침용 AGENTS.md나 .agents/skills/ 아래의 스킬 같은 파일을 샌드박스에 직접 마운트하거나, 상호작용 시점에 설정을 인라인으로 전달할 수 있어요. 설정을 인라인으로 반복 조정하다가 준비되면 관리형 에이전트로 저장하면 돼요.
커스텀 에이전트 구축 방법에 대한 자세한 내용은 Building Managed Agents 문서를 참고하세요.
백그라운드 실행 (Background execution)
다단계 추론, 코드 실행, 파일 작업이 포함된 에이전트 작업은 완료되는 데 몇 분이 걸릴 수 있어요. background=True를 사용하면 상호작용을 비동기로 실행해요. API는 즉시 상호작용 ID를 반환하고, 상태가 completed나 failed가 될 때까지 이 ID를 폴링하면 돼요.
Python
import time
from google import genai
client = genai.Client()
# 1. Start the interaction in the background
interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
input="Run a complex analysis on the repository.",
environment="remote",
background=True,
)
print(f"Interaction started in background: {interaction.id}")
# 2. Poll for completion
while interaction.status == "in_progress":
time.sleep(5)
interaction = client.interactions.get(id=interaction.id)
if interaction.status == "completed":
print(interaction.output_text)
else:
print(f"Finished with status: {interaction.status}")
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "Run a complex analysis on the repository.",
environment: "remote",
background: true,
});
console.log(`Interaction started in background: ${interaction.id}`);
let result = interaction;
while (result.status === "in_progress") {
await new Promise(resolve => setTimeout(resolve, 5000));
result = await client.interactions.get(interaction.id);
}
if (result.status === "completed") {
console.log(result.output_text);
} else {
console.log(`Finished with status: ${result.status}`);
}
Java
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.InteractionStatus;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.GetInteractionByIdRequest;
Client client = new Client();
// 1. Start the interaction in the background
CreateAgentInteraction params = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("Run a complex analysis on the repository."))
.environment(CreateAgentInteractionEnvironment.of("remote"))
.background(true)
.build();
Interaction interaction = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
System.out.println("Interaction started in background: " + interaction.id().orElse(""));
// 2. Poll for completion
while (interaction.status().orElse(null) == InteractionStatus.IN_PROGRESS) {
Thread.sleep(5000);
interaction = client.interactions.get(new GetInteractionByIdRequest(interaction.id().orElse(""))).interaction().get();
}
if (interaction.status().orElse(null) == InteractionStatus.COMPLETED) {
System.out.println(interaction.outputText().orElse(""));
} else {
System.out.println("Finished with status: " + interaction.status().orElse(null));
}
Go
package main
import (
"context"
"fmt"
"log"
"time"
"google.golang.org/genai"
"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)
}
// 1. Start the interaction in the background
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
Input: interactions.NewInteractionsInput("Run a complex analysis on the repository."),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment("remote")),
Background: genai.Ptr(true),
}),
})
if err != nil {
log.Fatal(err)
}
interaction := res.Interaction
fmt.Printf("Interaction started in background: %s\n", *interaction.ID)
// 2. Poll for completion
for interaction.Status == interactions.InteractionStatusInProgress {
time.Sleep(5 * time.Second)
getRes, err := client.Interactions.Get(ctx, operations.GetInteractionByIDRequest{
ID: *interaction.ID,
})
if err != nil {
log.Fatal(err)
}
interaction = getRes.Interaction
}
if interaction.Status == interactions.InteractionStatusCompleted {
if interaction.OutputText != nil {
fmt.Println(*interaction.OutputText)
}
} else {
fmt.Printf("Finished with status: %s\n", interaction.Status)
}
}
REST
# 1. Start the interaction in the background
RESPONSE=$(curl -s -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-09-2026",
"input": "Run a complex analysis on the repository.",
"environment": "remote",
"background": true
}')
INTERACTION_ID=$(echo $RESPONSE | jq -r '.id')
# 2. Poll for results (repeat until status is "completed")
curl -s -X GET "https://generativelanguage.googleapis.com/v1beta/interactions/$INTERACTION_ID" \
-H "x-goog-api-key: $GEMINI_API_KEY"
백그라운드 실행은 기본값인 store=True가 필요해요. 백그라운드 실행 중 실시간 진행 상황 업데이트는 Streaming background interactions 문서를 참고하세요.
실행 중인 백그라운드 상호작용은 cancel 메서드로 취소할 수 있어요.
Python
client.interactions.cancel(id="INTERACTION_ID")
JavaScript
await client.interactions.cancel("INTERACTION_ID");
Java
import com.google.genai.Client;
Client client = new Client();
client.interactions.cancel("INTERACTION_ID");
Go
package main
import (
"context"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
_, err = client.Interactions.Cancel(ctx, operations.CancelInteractionByIDRequest{
ID: "INTERACTION_ID",
})
if err != nil {
log.Fatal(err)
}
}
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions/INTERACTION_ID:cancel" \
-H "x-goog-api-key: $GEMINI_API_KEY"
백그라운드 실행과 멀티 턴
백그라운드 상호작용에 상태가 있는 도구(예: 샌드박스 안의 코드 실행)가 포함된 경우, 완료된 상호작용의 environment_id를 사용해 같은 환경에서 계속하세요. 이렇게 하면 에이전트가 모든 파일과 상태를 그대로 두고 중단한 지점부터 이어서 작업해요.
Python
import time
from google import genai
client = genai.Client()
# First turn: run a task in the background
interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
input="Clone https://github.com/google/generative-ai-python and run its tests.",
environment="remote",
background=True,
)
while interaction.status == "in_progress":
time.sleep(5)
interaction = client.interactions.get(id=interaction.id)
# Second turn: continue in the same environment
followup = client.interactions.create(
agent="antigravity-preview-09-2026",
input="Fix any failing tests and re-run them.",
previous_interaction_id=interaction.id,
environment=interaction.environment_id,
background=True,
)
while followup.status == "in_progress":
time.sleep(5)
followup = client.interactions.get(id=followup.id)
print(followup.output_text)
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
// First turn: run a task in the background
let interaction = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "Clone https://github.com/google/generative-ai-python and run its tests.",
environment: "remote",
background: true,
});
while (interaction.status === "in_progress") {
await new Promise(resolve => setTimeout(resolve, 5000));
interaction = await client.interactions.get(interaction.id);
}
// Second turn: continue in the same environment
let followup = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "Fix any failing tests and re-run them.",
previous_interaction_id: interaction.id,
environment: interaction.environment_id,
background: true,
});
while (followup.status === "in_progress") {
await new Promise(resolve => setTimeout(resolve, 5000));
followup = await client.interactions.get(followup.id);
}
console.log(followup.output_text);
Java
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.InteractionStatus;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.GetInteractionByIdRequest;
Client client = new Client();
// First turn: run a task in the background
CreateAgentInteraction params = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("Clone https://github.com/google/generative-ai-python and run its tests."))
.environment(CreateAgentInteractionEnvironment.of("remote"))
.background(true)
.build();
Interaction interaction = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
while (interaction.status().orElse(null) == InteractionStatus.IN_PROGRESS) {
Thread.sleep(5000);
interaction = client.interactions.get(new GetInteractionByIdRequest(interaction.id().orElse(""))).interaction().get();
}
// Second turn: continue in the same environment
CreateAgentInteraction followupParams = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("Fix any failing tests and re-run them."))
.previousInteractionId(interaction.id().orElse(""))
.environment(CreateAgentInteractionEnvironment.of(interaction.environmentId().orElse("")))
.background(true)
.build();
Interaction followup = client.interactions.create(CreateInteractionRequestBody.of(followupParams)).interaction().get();
while (followup.status().orElse(null) == InteractionStatus.IN_PROGRESS) {
Thread.sleep(5000);
followup = client.interactions.get(new GetInteractionByIdRequest(followup.id().orElse(""))).interaction().get();
}
System.out.println(followup.outputText().orElse(""));
Go
package main
import (
"context"
"fmt"
"log"
"time"
"google.golang.org/genai"
"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)
}
// First turn: run a task in the background
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
Input: interactions.NewInteractionsInput("Clone https://github.com/google/generative-ai-python and run its tests."),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment("remote")),
Background: genai.Ptr(true),
}),
})
if err != nil {
log.Fatal(err)
}
interaction := res.Interaction
for interaction.Status == interactions.InteractionStatusInProgress {
time.Sleep(5 * time.Second)
getRes, err := client.Interactions.Get(ctx, operations.GetInteractionByIDRequest{
ID: *interaction.ID,
})
if err != nil {
log.Fatal(err)
}
interaction = getRes.Interaction
}
// Second turn: continue in the same environment
followupRes, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
Input: interactions.NewInteractionsInput("Fix any failing tests and re-run them."),
PreviousInteractionID: interaction.ID,
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment(*interaction.EnvironmentID)),
Background: genai.Ptr(true),
}),
})
if err != nil {
log.Fatal(err)
}
followup := followupRes.Interaction
for followup.Status == interactions.InteractionStatusInProgress {
time.Sleep(5 * time.Second)
getRes, err := client.Interactions.Get(ctx, operations.GetInteractionByIDRequest{
ID: *followup.ID,
})
if err != nil {
log.Fatal(err)
}
followup = getRes.Interaction
}
if followup.OutputText != nil {
fmt.Println(*followup.OutputText)
}
}
REST
# 1. Start first interaction in the background
RESPONSE=$(curl -s -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-09-2026",
"input": "Clone https://github.com/google/generative-ai-python and run its tests.",
"environment": "remote",
"background": true
}')
INTERACTION_ID=$(echo $RESPONSE | jq -r '.id')
# 2. Poll until completed (repeat until status is "completed")
RESULT=$(curl -s -X GET "https://generativelanguage.googleapis.com/v1beta/interactions/$INTERACTION_ID" \
-H "x-goog-api-key: $GEMINI_API_KEY")
ENVIRONMENT_ID=$(echo $RESULT | jq -r '.environment_id')
# 3. Continue in the same environment
curl -s -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-09-2026\",
\"input\": \"Fix any failing tests and re-run them.\",
\"previous_interaction_id\": \"$INTERACTION_ID\",
\"environment\": \"$ENVIRONMENT_ID\",
\"background\": true
}"
환경 (Environments)
호출할 때마다 Linux 샌드박스를 새로 만들거나 재사용해요. environment 파라미터는 세 가지 형태를 가져요.
| 형태 | 설명 |
|---|---|
"remote" |
기본 설정으로 새 샌드박스를 준비해요. |
"env_abc123" |
ID로 기존 환경을 재사용하며 모든 파일과 상태를 보존해요. |
{...} |
커스텀 소스와 네트워크 규칙을 가진 전체 EnvironmentConfig예요. |
소스(Git, GCS, inline), 네트워킹, 수명 주기, 리소스 한도에 대한 자세한 내용은 Environments 문서를 참고하세요.
트리거 (Triggers)
트리거를 쓰면 cron 일정에 따라 에이전트가 자동으로 실행되도록 예약할 수 있어요. 트리거는 에이전트, 환경, 프롬프트, 일정을 하나의 지속적 리소스로 묶어서 사람이 개입하지 않아도 실행돼요. 실행할 때마다 같은 환경을 재사용하므로, 한 번 실행에서 만든 파일이 유지되어 다음 실행에서도 보여요.
트리거 만들기 (Create a trigger)
cron 일정, 시간대, 상호작용 설정을 지정해 트리거를 만들어요. 트리거는 active 상태로 시작하고 다음으로 일치하는 cron 시간에 실행돼요. 반환된 id를 저장해 다음 호출에서 트리거를 관리하세요.
트리거는 일정에 따라 사람 없이 실행되므로 인라인 토큰 대신 저장된 credential을 참조하세요. egress 프록시가 매 실행마다 이를 해석하고, 비밀을 교체해도 트리거를 건드릴 필요가 없어요. 인라인 transform 규칙도 여기에서 동작하지만, 값이 바뀔 때마다 트리거를 갱신해야 해요.
Python
from google import genai
client = genai.Client()
trigger = client.triggers.create(
schedule="0 9 * * *",
time_zone="America/Argentina/Buenos_Aires",
display_name="issue-solver",
interaction={
"agent": "antigravity-preview-09-2026",
"input": "Review open PRs in my-org/my-app for new comments and address feedback. Close issues whose PRs were merged. Then check for new issues labeled 'accepted', skip any already tracked in /workspace/solved-issues/, fix the rest, and open a PR for each. Save reports to /workspace/solved-issues/.",
"environment": {
"type": "remote",
"network": {
"allowlist": [
{
"domain": "api.github.com",
"credential": "github-production",
},
{"domain": "github.com"},
]
},
},
},
)
print(f"Trigger created: {trigger.id}")
print(f"Next run: {trigger.next_run_time}")
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const trigger = await client.triggers.create({
schedule: "0 9 * * *",
time_zone: "America/Argentina/Buenos_Aires",
display_name: "issue-solver",
interaction: {
agent: "antigravity-preview-09-2026",
input: [{
type: "text",
text: "Review open PRs in my-org/my-app for new comments and address feedback. Close issues whose PRs were merged. Then check for new issues labeled 'accepted', skip any already tracked in /workspace/solved-issues/, fix the rest, and open a PR for each. Save reports to /workspace/solved-issues/.",
}],
environment: {
type: "remote",
network: {
allowlist: [
{
domain: "api.github.com",
credential: "github-production",
},
{ domain: "github.com" },
],
},
},
},
});
console.log(`Trigger created: ${trigger.id}`);
console.log(`Next run: ${trigger.next_run_time}`);
Java
import com.google.genai.gaos.GenAI;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.Allowlist;
import com.google.genai.gaos.models.interactions.AllowlistEntry;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
import com.google.genai.gaos.models.interactions.Environment;
import com.google.genai.gaos.models.interactions.EnvironmentNetworkEgressAllowlist;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Network;
import com.google.genai.gaos.models.interactions.Transform;
import com.google.genai.gaos.models.shared.Security;
import com.google.genai.gaos.models.triggers.Interaction;
import com.google.genai.gaos.models.triggers.Trigger;
import com.google.genai.gaos.models.triggers.TriggerCreateParams;
import java.util.List;
import java.util.Map;
GenAI client = GenAI.builder()
.security(Security.builder().apiKey(System.getenv("GEMINI_API_KEY")).build())
.build();
Environment env = Environment.builder()
.network(Network.of(EnvironmentNetworkEgressAllowlist.of(
Allowlist.builder()
.allowlist(List.of(
AllowlistEntry.builder()
.domain("api.github.com")
.transform(Transform.of(Map.of(
"Authorization", "Bearer ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
)))
.build(),
AllowlistEntry.builder()
.domain("github.com")
.build()
))
.build()
)))
.build();
CreateAgentInteraction interactionTemplate = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("Review open PRs in my-org/my-app for new comments and address feedback. Close issues whose PRs were merged. Then check for new issues labeled 'accepted', skip any already tracked in /workspace/solved-issues/, fix the rest, and open a PR for each. Save reports to /workspace/solved-issues/."))
.environment(CreateAgentInteractionEnvironment.of(env))
.build();
TriggerCreateParams params = TriggerCreateParams.builder()
.schedule("0 9 * * *")
.timeZone("America/Argentina/Buenos_Aires")
.displayName("issue-solver")
.interaction(Interaction.of(interactionTemplate))
.build();
Trigger trigger = client.triggers().create(params).trigger().get();
System.out.println("Trigger created: " + trigger.id().orElse(""));
System.out.println("Next run: " + trigger.nextRunTime().orElse(null));
Go
package main
import (
"context"
"fmt"
"log"
"os"
"google.golang.org/genai"
interactionssdk "google.golang.org/genai/interactions"
"google.golang.org/genai/interactions/models/components"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
"google.golang.org/genai/interactions/models/triggers"
)
func main() {
ctx := context.Background()
sdk := interactionssdk.New(interactionssdk.WithSecurity(components.Security{
APIKey: genai.Ptr(os.Getenv("GEMINI_API_KEY")),
}))
env := interactions.Environment{
Network: genai.Ptr(interactions.NewNetwork(interactions.NewEnvironmentNetworkEgressAllowlist(interactions.Allowlist{
Allowlist: []interactions.AllowlistEntry{
{
Domain: "api.github.com",
Transform: genai.Ptr(interactions.NewTransform(map[string]string{
"Authorization": "Bearer ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
})),
},
{
Domain: "github.com",
},
},
}))),
}
interactionTemplate := interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
Input: interactions.NewInteractionsInput("Review open PRs in my-org/my-app for new comments and address feedback. Close issues whose PRs were merged. Then check for new issues labeled 'accepted', skip any already tracked in /workspace/solved-issues/, fix the rest, and open a PR for each. Save reports to /workspace/solved-issues/."),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment(env)),
}
res, err := sdk.Triggers.Create(ctx, operations.CreateTriggerRequest{
Body: triggers.TriggerCreateParams{
Schedule: "0 9 * * *",
TimeZone: "America/Argentina/Buenos_Aires",
DisplayName: genai.Ptr("issue-solver"),
Interaction: triggers.NewInteraction(interactionTemplate),
},
})
if err != nil {
log.Fatal(err)
}
trigger := res.Trigger
fmt.Printf("Trigger created: %s\n", trigger.ID)
fmt.Printf("Next run: %v\n", trigger.NextRunTime)
}
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/triggers" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"schedule": "0 9 * * *",
"time_zone": "America/Argentina/Buenos_Aires",
"display_name": "issue-solver",
"interaction": {
"agent": "antigravity-preview-09-2026",
"input": [{"type": "text", "text": "Review open PRs in my-org/my-app for new comments and address feedback. Close issues whose PRs were merged. Then check for new issues labeled accepted, skip any already tracked in /workspace/solved-issues/, fix the rest, and open a PR for each. Save reports to /workspace/solved-issues/."}],
"environment": {
"type": "remote",
"network": {
"allowlist": [
{
"domain": "api.github.com",
"credential": "github-production"
},
{"domain": "github.com"}
]
}
}
}
}'
CreateTrigger 요청은 다음 필드를 받아요.
| 필드 | 타입 | 필수 | 설명 |
|---|---|---|---|
schedule |
string | 예 | Cron 표현식(예: 매시간 0 * * * *, 평일 아침 0 9 * * 1-5). |
time_zone |
string | 예 | IANA 시간대(예: UTC, America/Argentina/Buenos_Aires). |
display_name |
string | 아니요 | 트리거의 사람이 읽을 수 있는 이름이에요. |
max_consecutive_failures |
integer | 아니요 | 트리거가 자동으로 일시 중지되기 전까지 허용되는 최대 실패 횟수예요. 기본값: 5. |
execution_timeout_seconds |
integer | 아니요 | 실행당 타임아웃(초)이에요. 기본값: 600. |
interaction |
object | 예 | 에이전트, 입력, 도구, 환경을 정의하는 CreateInteractionRequest예요. |
응답에는 다음과 같은 핵심 필드가 포함돼요.
| 필드 | 타입 | 설명 |
|---|---|---|
id |
string | 트리거의 고유 식별자예요. 이후 모든 작업에 이 값을 사용해요. |
status |
string | 현재 상태: active, paused 또는 disabled. |
next_run_time |
string | 다음 예약 실행의 ISO 8601 타임스탬프예요. |
consecutive_failure_count |
integer | 마지막 성공 이후 연속 실패한 실행 횟수예요. |
트리거 나열 (List triggers)
프로젝트와 연결된 모든 트리거를 조회해요.
Python
triggers = client.triggers.list()
for trigger in triggers.triggers:
print(f"{trigger.id}: {trigger.display_name} ({trigger.status})")
JavaScript
const triggers = await client.triggers.list();
for (const trigger of triggers.triggers) {
console.log(`${trigger.id}: ${trigger.display_name} (${trigger.status})`);
}
Java
import com.google.genai.gaos.GenAI;
import com.google.genai.gaos.models.shared.Security;
import com.google.genai.gaos.models.triggers.Trigger;
import java.util.List;
GenAI client = GenAI.builder()
.security(Security.builder().apiKey(System.getenv("GEMINI_API_KEY")).build())
.build();
List<Trigger> triggers = client.triggers().listDirect().listTriggersResponse().get().triggers().orElse(List.of());
for (Trigger trigger : triggers) {
System.out.println(trigger.id().orElse("") + ": " + trigger.displayName().orElse("") + " (" + trigger.status().orElse(null) + ")");
}
Go
package main
import (
"context"
"fmt"
"log"
"os"
"google.golang.org/genai"
interactionssdk "google.golang.org/genai/interactions"
"google.golang.org/genai/interactions/models/components"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
sdk := interactionssdk.New(interactionssdk.WithSecurity(components.Security{
APIKey: genai.Ptr(os.Getenv("GEMINI_API_KEY")),
}))
res, err := sdk.Triggers.List(ctx, operations.ListTriggersRequest{})
if err != nil {
log.Fatal(err)
}
if res.ListTriggersResponse != nil {
for _, trigger := range res.ListTriggersResponse.Triggers {
fmt.Printf("%s: %s (%v)\n", trigger.ID, *trigger.GetDisplayName(), trigger.Status)
}
}
}
REST
curl -X GET "https://generativelanguage.googleapis.com/v1beta/triggers" \
-H "x-goog-api-key: $GEMINI_API_KEY"
트리거 조회 (Get a trigger)
단일 트리거의 전체 설정과 현재 상태를 가져와요.
Python
trigger = client.triggers.get(id="TRIGGER_ID")
print(f"Schedule: {trigger.schedule}")
print(f"Next run: {trigger.next_run_time}")
JavaScript
const trigger = await client.triggers.get("TRIGGER_ID");
console.log(`Schedule: ${trigger.schedule}`);
console.log(`Next run: ${trigger.next_run_time}`);
Java
import com.google.genai.gaos.GenAI;
import com.google.genai.gaos.models.shared.Security;
import com.google.genai.gaos.models.triggers.Trigger;
GenAI client = GenAI.builder()
.security(Security.builder().apiKey(System.getenv("GEMINI_API_KEY")).build())
.build();
Trigger trigger = client.triggers().get("TRIGGER_ID").trigger().get();
System.out.println("Schedule: " + trigger.schedule().orElse(""));
System.out.println("Next run: " + trigger.nextRunTime().orElse(null));
Go
package main
import (
"context"
"fmt"
"log"
"os"
"google.golang.org/genai"
interactionssdk "google.golang.org/genai/interactions"
"google.golang.org/genai/interactions/models/components"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
sdk := interactionssdk.New(interactionssdk.WithSecurity(components.Security{
APIKey: genai.Ptr(os.Getenv("GEMINI_API_KEY")),
}))
res, err := sdk.Triggers.Get(ctx, operations.GetTriggerRequest{
ID: "TRIGGER_ID",
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Schedule: %s\n", res.Trigger.Schedule)
fmt.Printf("Next run: %v\n", res.Trigger.NextRunTime)
}
REST
curl -X GET "https://generativelanguage.googleapis.com/v1beta/triggers/TRIGGER_ID" \
-H "x-goog-api-key: $GEMINI_API_KEY"
일시 중지와 재개 (Pause and resume)
트리거를 일시 중지하면 예약 실행을 멈추고, 재개하면 일정을 다시 활성화해요. 일시 중지는 수동 실행에는 영향을 주지 않아요.
Python
# Pause
client.triggers.update(id="TRIGGER_ID", status="paused")
# Resume
client.triggers.update(id="TRIGGER_ID", status="active")
JavaScript
// Pause
await client.triggers.update("TRIGGER_ID", { status: "paused" });
// Resume
await client.triggers.update("TRIGGER_ID", { status: "active" });
Java
import com.google.genai.gaos.GenAI;
import com.google.genai.gaos.models.shared.Security;
import com.google.genai.gaos.models.triggers.TriggerUpdate;
import com.google.genai.gaos.models.triggers.TriggerUpdateStatus;
GenAI client = GenAI.builder()
.security(Security.builder().apiKey(System.getenv("GEMINI_API_KEY")).build())
.build();
// Pause
client.triggers().update("TRIGGER_ID", TriggerUpdate.builder().status(TriggerUpdateStatus.PAUSED).build());
// Resume
client.triggers().update("TRIGGER_ID", TriggerUpdate.builder().status(TriggerUpdateStatus.ACTIVE).build());
Go
package main
import (
"context"
"log"
"os"
"google.golang.org/genai"
interactionssdk "google.golang.org/genai/interactions"
"google.golang.org/genai/interactions/models/components"
"google.golang.org/genai/interactions/models/operations"
"google.golang.org/genai/interactions/models/triggers"
)
func main() {
ctx := context.Background()
sdk := interactionssdk.New(interactionssdk.WithSecurity(components.Security{
APIKey: genai.Ptr(os.Getenv("GEMINI_API_KEY")),
}))
// Pause
_, err := sdk.Triggers.Update(ctx, operations.UpdateTriggerRequest{
ID: "TRIGGER_ID",
Body: triggers.TriggerUpdate{
Status: triggers.TriggerUpdateStatusPaused.ToPointer(),
},
})
if err != nil {
log.Fatal(err)
}
// Resume
_, err = sdk.Triggers.Update(ctx, operations.UpdateTriggerRequest{
ID: "TRIGGER_ID",
Body: triggers.TriggerUpdate{
Status: triggers.TriggerUpdateStatusActive.ToPointer(),
},
})
if err != nil {
log.Fatal(err)
}
}
REST
# Pause
curl -X PATCH "https://generativelanguage.googleapis.com/v1beta/triggers/TRIGGER_ID" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{"status": "paused"}'
# Resume
curl -X PATCH "https://generativelanguage.googleapis.com/v1beta/triggers/TRIGGER_ID" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{"status": "active"}'
트리거 삭제 (Delete a trigger)
트리거를 영구히 제거해요. 과거 실행 기록은 삭제되지 않아요.
Python
client.triggers.delete(id="TRIGGER_ID")
JavaScript
await client.triggers.delete("TRIGGER_ID");
Java
import com.google.genai.gaos.GenAI;
import com.google.genai.gaos.models.shared.Security;
GenAI client = GenAI.builder()
.security(Security.builder().apiKey(System.getenv("GEMINI_API_KEY")).build())
.build();
client.triggers().delete("TRIGGER_ID");
Go
package main
import (
"context"
"log"
"os"
"google.golang.org/genai"
interactionssdk "google.golang.org/genai/interactions"
"google.golang.org/genai/interactions/models/components"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
sdk := interactionssdk.New(interactionssdk.WithSecurity(components.Security{
APIKey: genai.Ptr(os.Getenv("GEMINI_API_KEY")),
}))
_, err := sdk.Triggers.Delete(ctx, operations.DeleteTriggerRequest{
ID: "TRIGGER_ID",
})
if err != nil {
log.Fatal(err)
}
}
REST
curl -X DELETE "https://generativelanguage.googleapis.com/v1beta/triggers/TRIGGER_ID" \
-H "x-goog-api-key: $GEMINI_API_KEY"
트리거 즉시 실행 (Run a trigger immediately)
다음 예약 시각을 기다리지 않고 트리거를 주문형(on demand)으로 실행해요. 트리거가 일시 중지된 상태에서도 동작해요.
Python
client.triggers.run(trigger_id="TRIGGER_ID")
JavaScript
await client.triggers.run("TRIGGER_ID");
Java
import com.google.genai.gaos.GenAI;
import com.google.genai.gaos.models.shared.Security;
GenAI client = GenAI.builder()
.security(Security.builder().apiKey(System.getenv("GEMINI_API_KEY")).build())
.build();
client.triggers().run("TRIGGER_ID");
Go
package main
import (
"context"
"log"
"os"
"google.golang.org/genai"
interactionssdk "google.golang.org/genai/interactions"
"google.golang.org/genai/interactions/models/components"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
sdk := interactionssdk.New(interactionssdk.WithSecurity(components.Security{
APIKey: genai.Ptr(os.Getenv("GEMINI_API_KEY")),
}))
_, err := sdk.Triggers.Run(ctx, operations.RunTriggerRequest{
TriggerID: "TRIGGER_ID",
})
if err != nil {
log.Fatal(err)
}
}
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/triggers/TRIGGER_ID/executions" \
-H "x-goog-api-key: $GEMINI_API_KEY"
실행 목록 (List executions)
트리거의 실행 기록을 확인해요. 각 실행에는 status, 타임스탬프, 전체 상호작용 출력을 가져오는 데 쓸 interaction_id, 그리고 모든 실행이 같은 샌드박스를 공유함을 확인해 주는 environment_id가 포함돼요.
Python
executions = client.triggers.list_executions(trigger_id="TRIGGER_ID")
for ex in executions.trigger_executions:
print(f"{ex.id}: {ex.status} ({ex.start_time} - {ex.end_time})")
# Fetch the full interaction for an execution
interaction = client.interactions.get(id=ex.interaction_id)
print(interaction.output_text)
JavaScript
const executions = await client.triggers.listExecutions("TRIGGER_ID");
for (const ex of executions.trigger_executions) {
console.log(`${ex.id}: ${ex.status} (${ex.start_time} - ${ex.end_time})`);
}
// Fetch the full interaction for an execution
const interaction = await client.interactions.get(ex.interaction_id);
console.log(interaction.output_text);
Java
import com.google.genai.gaos.GenAI;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.operations.GetInteractionByIdRequest;
import com.google.genai.gaos.models.shared.Security;
import com.google.genai.gaos.models.triggers.TriggerExecution;
import java.util.List;
GenAI client = GenAI.builder()
.security(Security.builder().apiKey(System.getenv("GEMINI_API_KEY")).build())
.build();
List<TriggerExecution> executions = client.triggers().listExecutions("TRIGGER_ID")
.listTriggerExecutionsResponse().get()
.triggerExecutions().orElse(List.of());
for (TriggerExecution ex : executions) {
System.out.println(ex.id().orElse("") + ": " + ex.status().orElse(null)
+ " (" + ex.startTime().orElse(null) + " - " + ex.endTime().orElse(null) + ")");
// Fetch the full interaction for an execution
if (ex.interactionId().isPresent()) {
Interaction interaction = client.interactions().get(new GetInteractionByIdRequest(ex.interactionId().get())).interaction().get();
System.out.println(interaction.outputText().orElse(""));
}
}
Go
package main
import (
"context"
"fmt"
"log"
"os"
"google.golang.org/genai"
interactionssdk "google.golang.org/genai/interactions"
"google.golang.org/genai/interactions/models/components"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
sdk := interactionssdk.New(interactionssdk.WithSecurity(components.Security{
APIKey: genai.Ptr(os.Getenv("GEMINI_API_KEY")),
}))
res, err := sdk.Triggers.ListExecutions(ctx, operations.ListTriggerExecutionsRequest{
TriggerID: "TRIGGER_ID",
})
if err != nil {
log.Fatal(err)
}
if res.ListTriggerExecutionsResponse != nil {
for _, ex := range res.ListTriggerExecutionsResponse.TriggerExecutions {
fmt.Printf("%s: %v (%v - %v)\n", ex.ID, ex.Status, ex.StartTime, ex.EndTime)
// Fetch the full interaction for an execution
if ex.InteractionID != nil {
intRes, err := sdk.Interactions.Get(ctx, operations.GetInteractionByIDRequest{
ID: *ex.InteractionID,
})
if err != nil {
log.Fatal(err)
}
if intRes.Interaction.OutputText != nil {
fmt.Println(*intRes.Interaction.OutputText)
}
}
}
}
}
REST
curl -X GET "https://generativelanguage.googleapis.com/v1beta/triggers/TRIGGER_ID/executions" \
-H "x-goog-api-key: $GEMINI_API_KEY"
제공 범위와 가격 (Availability and pricing)
Antigravity 에이전트는 Google AI Studio와 Gemini API의 Interactions API를 통해 프리뷰로 사용할 수 있어요. 무료 티어와 유료 티어 프로젝트 모두에서 사용 가능해요.
가격은 기본 Gemini 모델 토큰과 에이전트가 사용하는 도구에 기반한 종량제(pay-as-you-go) 모델을 따르고 있어요. 단일 출력을 만드는 일반 채팅 요청과 달리, Antigravity 상호작용은 에이전트 워크플로예요. 단일 요청이 추론, 도구 실행, 코드 실행, 파일 관리의 자율 루프를 촉발해요. 무료 티어 프로젝트에는 무료 요금 한도와 사용량 쿼터가 포함돼요.
Antigravity 상호작용은 멀티 턴 자율 루프로 실행되며 상당한 토큰을 소비할 수 있어요. 요청에 예산 제어를 설정해 토큰 사용량을 제한하세요. SSE 스트리밍으로 진행 상황을 실시간으로 모니터링하거나, 실행 중인 요청을 취소할 수도 있어요.
예산 제어 (Budget controls)
모델 선택에 더해, agent_config 안에 max_total_tokens(와 "type": "antigravity")를 설정하면 상호작용이 소비할 총 토큰 수(입력 + 출력 + 사고)를 제한할 수 있어요. 캐시된 토큰은 이 한도에 포함되지 않아요. 에이전트가 한도에 도달하면 상호작용은 멈추고 status: "incomplete"로 반환돼요. 이 한도는 best-effort라서 에이전트가 단계 사이에 예산을 확인하는 시점에 따라 실제 사용량이 조금 초과될 수 있어요.
상호작용 요청의 agent_config에 agent와 input 옆에 예산을 설정하세요.
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
input="Analyze the dataset in /workspace/data.csv and generate a summary report.",
agent_config={
"type": "antigravity",
"max_total_tokens": 50000
},
environment={
"type": "remote",
"sources": [
{
"type": "inline",
"target": "/workspace/data.csv",
"content": "id,name,value\n1,alpha,100\n2,beta,200\n",
}
],
}
)
print(f"Status: {interaction.status}") # "incomplete" if budget was hit
print(f"Tokens used: {interaction.usage.total_tokens}")
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "Analyze the dataset in /workspace/data.csv and generate a summary report.",
agent_config: {
type: "antigravity",
max_total_tokens: 50000
},
environment: {
type: "remote",
sources: [
{
type: "inline",
target: "/workspace/data.csv",
content: "id,name,value\n1,alpha,100\n2,beta,200\n",
},
],
},
});
console.log(`Status: ${interaction.status}`);
console.log(`Tokens used: ${interaction.usage.total_tokens}`);
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.AntigravityAgentConfig;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
import com.google.genai.gaos.models.interactions.Environment;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Source;
import com.google.genai.gaos.models.interactions.SourceType;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.List;
Client client = new Client();
Environment env = Environment.builder()
.sources(List.of(
Source.builder()
.type(SourceType.INLINE)
.target("/workspace/data.csv")
.content("id,name,value\n1,alpha,100\n2,beta,200\n")
.build()
))
.build();
CreateAgentInteraction params = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("Analyze the dataset in /workspace/data.csv and generate a summary report."))
.agentConfig(
AntigravityAgentConfig.builder()
.maxTotalTokens("50000")
.build()
)
.environment(CreateAgentInteractionEnvironment.of(env))
.build();
Interaction interaction = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
System.out.println("Status: " + interaction.status().orElse(null)); // "incomplete" if budget was hit
interaction.usage().ifPresent(usage -> System.out.println("Tokens used: " + usage.totalTokens().orElse(0)));
Go
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"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)
}
env := interactions.Environment{
Sources: []interactions.Source{
{
Type: interactions.SourceTypeInline.ToPointer(),
Target: genai.Ptr("/workspace/data.csv"),
Content: genai.Ptr("id,name,value\n1,alpha,100\n2,beta,200\n"),
},
},
}
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
Input: interactions.NewInteractionsInput("Analyze the dataset in /workspace/data.csv and generate a summary report."),
AgentConfig: genai.Ptr(interactions.NewCreateAgentInteractionAgentConfig(interactions.AntigravityAgentConfig{
MaxTotalTokens: genai.Ptr(int64(50000)),
})),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment(env)),
}),
})
if err != nil {
log.Fatal(err)
}
interaction := res.Interaction
fmt.Printf("Status: %s\n", interaction.Status) // "incomplete" if budget was hit
if interaction.Usage != nil && interaction.Usage.TotalTokens != nil {
fmt.Printf("Tokens used: %d\n", *interaction.Usage.TotalTokens)
}
}
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-09-2026",
"input": "Analyze the dataset in /workspace/data.csv and generate a summary report.",
"agent_config": {
"type": "antigravity",
"max_total_tokens": 50000
},
"environment": {
"type": "remote",
"sources": [
{
"type": "inline",
"target": "/workspace/data.csv",
"content": "id,name,value\n1,alpha,100\n2,beta,200\n"
}
]
}
}'
불완전한 상호작용 이어가기 (Continuing an incomplete interaction)
상호작용이 status: "incomplete"로 반환되면 에이전트의 작업과 컨텍스트는 보존돼요. 원래 상호작용의 id와 environment_id를 참조하는 새 상호작용을 보내서 중단된 지점부터 이어가세요. 새 상호작용은 자체 max_total_tokens 예산을 가져요.
Python
# Continue from where the agent stopped
continuation = client.interactions.create(
agent="antigravity-preview-09-2026",
input="continue",
previous_interaction_id=interaction.id,
environment=interaction.environment_id,
agent_config={
"type": "antigravity",
"max_total_tokens": 50000
}
)
print(f"Status: {continuation.status}")
JavaScript
const continuation = await client.interactions.create({
agent: "antigravity-preview-09-2026",
input: "continue",
previous_interaction_id: interaction.id,
environment: interaction.environment_id,
agent_config: {
type: "antigravity",
max_total_tokens: 50000
}
});
console.log(`Status: ${continuation.status}`);
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.AntigravityAgentConfig;
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;
Client client = new Client();
String interactionId = "INTERACTION_ID";
String environmentId = "ENVIRONMENT_ID";
// Continue from where the agent stopped
CreateAgentInteraction params = CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(InteractionsInput.of("continue"))
.previousInteractionId(interactionId)
.environment(CreateAgentInteractionEnvironment.of(environmentId))
.agentConfig(
AntigravityAgentConfig.builder()
.maxTotalTokens("50000")
.build()
)
.build();
Interaction continuation = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
System.out.println("Status: " + continuation.status().orElse(null));
Go
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"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)
}
interactionID := "INTERACTION_ID"
environmentID := "ENVIRONMENT_ID"
// Continue from where the agent stopped
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
Input: interactions.NewInteractionsInput("continue"),
PreviousInteractionID: genai.Ptr(interactionID),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment(environmentID)),
AgentConfig: genai.Ptr(interactions.NewCreateAgentInteractionAgentConfig(interactions.AntigravityAgentConfig{
MaxTotalTokens: genai.Ptr(int64(50000)),
})),
}),
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Status: %s\n", res.Interaction.Status)
}
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-09-2026",
"input": "continue",
"previous_interaction_id": "INTERACTION_ID",
"environment": "ENVIRONMENT_ID",
"agent_config": {
"type": "antigravity",
"max_total_tokens": 50000
}
}'
예상 비용 (Estimated costs)
비용은 작업 복잡도에 따라 달라져요. 에이전트가 필요한 도구 호출, 코드 실행, 파일 작업 수를 자율적으로 결정해요. 아래 추정치는 실제 실행을 기반으로 한 값이에요.
| 작업 카테고리 | 입력 토큰 | 출력 토큰 | 일반 비용 |
|---|---|---|---|
| 연구 & 정보 종합 | 100k–500k | 10k–40k | $0.30–$1.00 |
| 문서 & 콘텐츠 생성 | 100k–500k | 15k–50k | $0.30–$1.30 |
| 프로세스 & 시스템 설계 | 100k–400k | 10k–30k | $0.25–$0.80 |
| 데이터 처리 & 분석 | 300k–3M | 30k–150k | $0.70–$3.25 |
입력 토큰의 50–70%는 보통 캐시돼요. 도구 호출이 많은 복잡한 에이전트 워크플로는 단일 상호작용에서 300만~500만 토큰을 쌓을 수 있고, 비용은 최대 ~$5까지 올라갈 수 있어요.
환경 컴퓨팅(CPU, 메모리, 샌드박스 실행)은 프리뷰 기간 동안 청구되지 않아요.
제한 사항 (Limitations)
- 프리뷰 상태: Antigravity 에이전트와 Interactions API. 기능과 스키마가 바뀔 수 있어요.
- 지원하지 않는 생성 설정: 다음 파라미터는 지원되지 않고 400 오류를 반환해요:
temperature,top_p,top_k,stop_sequences,max_output_tokens. - 구조화된 출력: Antigravity 에이전트는 구조화된 출력을 지원하지 않아요.
- 사용할 수 없는 도구:
file_search,computer_use,google_maps는 아직 지원되지 않아요. - 원격 MCP 제한: Server-Sent Events (SSE) 전송은 지원되지 않아요(Streamable HTTP를 사용하세요). 또한 서버
name은 반드시 소문자와 영숫자여야 해요(대문자를 쓰면 일반적인400 Bad Request오류가 발생해요). - 파일시스템 도구: 현재 별도 파일시스템 도구는 없어요.
environment의 일부예요. - 저장 요구 사항:
background=True를 사용한 에이전트 실행은store=True가 필요해요. - 상태가 있는 함수 호출만 지원: Function calling은 상태가 있는(stateful) 모드에서만 지원돼요. 턴을 이어가려면 반드시
previous_interaction_id를 사용해야 해요. 수동으로 기록을 재구성하는 방식(stateless 모드)은 지원되지 않아요. - 지원하지 않는 멀티모달 유형: 오디오, 비디오, 문서 입력은 현재 지원되지 않아요. 텍스트와 이미지만 허용돼요.
다음 단계 (What's next)
- Quickstart: 멀티 턴 대화와 스트리밍.
- Building Custom Agents: 커스텀 지침, 스킬, 에이전트 저장.
- Environments: 샌드박스 설정, 소스, 네트워킹.
- Hooks: 샌드박스 안에서 보안 게이트와 부작용 검증을 적용.
- Deep Research agent: 장문 연구 작업.
- Interactions API: 기본이 되는 API.
더 알아보기 (Learn more)
- Managed Agents Quickstart에서 첫 에이전트 호출을 만들어 보세요.
- Custom Agents로 나만의 에이전트를 구축해 보세요.
- 에이전트가 실행되는 Environments 설정을 살펴보세요.