Repository Public
1The Antigravity agent is a general-purpose managed agent on the Gemini API. A single API call gives you an agent that reasons, executes code, manages files, and browses the web inside your own secure Linux sandbox, hosted by Google.23It is built with Gemini 3.8 Flash and uses the same harness as the Antigravity IDE. You can configure the underlying Gemini model using `agent_config`. Available through the [Interactions API](https://ai.google.dev/gemini-api/docs/interactions-overview) and [Google AI Studio](https://aistudio.google.com).45### Python67 from google import genai89 client = genai.Client()1011 interaction = client.interactions.create(12 agent="antigravity-preview-09-2026",13 input="Read Hacker News, summarize the top 10 stories, and save the results as a PDF.",14 environment="remote",15 )1617 print(interaction.output_text)1819### JavaScript2021 import { GoogleGenAI } from "@google/genai";2223 const client = new GoogleGenAI({});2425 const interaction = await client.interactions.create({26 agent: "antigravity-preview-09-2026",27 input: "Read Hacker News, summarize the top 10 stories, and save the results as a PDF.",28 environment: "remote",29 }, { timeout: 300000 });3031 console.log(interaction.output_text);3233### Java3435 import com.google.genai.Client;36 import com.google.genai.gaos.models.interactions.AgentOption;37 import com.google.genai.gaos.models.interactions.CreateAgentInteraction;38 import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;39 import com.google.genai.gaos.models.interactions.Interaction;40 import com.google.genai.gaos.models.interactions.InteractionsInput;41 import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;4243 Client client = new Client();4445 CreateAgentInteraction params = CreateAgentInteraction.builder()46 .agent(AgentOption.of("antigravity-preview-09-2026"))47 .input(InteractionsInput.of("Read Hacker News, summarize the top 10 stories, and save the results as a PDF."))48 .environment(CreateAgentInteractionEnvironment.of("remote"))49 .build();5051 Interaction interaction = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();52 System.out.println(interaction.outputText().orElse(""));5354### REST5556 curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \57 -H "Content-Type: application/json" \58 -H "x-goog-api-key: $GEMINI_API_KEY" \59 -d '{60 "agent": "antigravity-preview-09-2026",61 "input": "Read Hacker News, summarize the top 10 stories, and save the results as a PDF.",62 "environment": "remote"63 }'6465## Capabilities6667Each call can provision a Linux sandbox and starts a tool-use loop. The agent plans, acts, observes results, and repeats until the task is done.6869- **Code execution:** Run Bash, Python, and Node.js commands. Install packages, run tests, build apps.70- **File management:** Read, write, edit, search, and list files in the sandbox. Files persist across interactions.71- **Web access:** Google Search and URL fetching for data.72- **Context compaction:** Automatic context compaction (triggered at \~135k tokens) to support long-running, multi-turn sessions without losing context or hitting token limits.7374See the [Quickstart](https://ai.google.dev/gemini-api/docs/managed-agents-quickstart) for multi-turn usage and streaming.7576## Supported tools7778By default, the agent has access to `code_execution`, `google_search`, and `url_context`. Filesystem tools are enabled automatically when you specify the `environment` parameter. You can also define **custom functions** to connect the agent to your own APIs and tools. You only need to specify the `tools` parameter when customizing or restricting the default set, or when adding custom functions.7980| Tool | Type value | Description |81|---|---|---|82| Code Execution | `code_execution` | Run shell commands (bash, Python, Node) with stdout/stderr capture. |83| Google Search | `google_search` | Search the public web. |84| URL Context | `url_context` | Fetch and read web pages. |85| Filesystem | *(enabled via `environment`)* | Read, write, edit, search, and list files in the sandbox. The system enables these tools automatically when you set the `environment`. |86| Custom Functions | `function` | Define custom functions that the agent can request to execute. See [Function calling](https://ai.google.dev/gemini-api/docs/antigravity-agent#function-calling). |87| Remote MCP Server | `mcp_server` | Register external Model Context Protocol (MCP) servers as tools. See [MCP servers](https://ai.google.dev/gemini-api/docs/antigravity-agent#mcp-servers). |8889You can intercept and validate `code_execution` and `filesystem` tool execution right inside the remote sandbox using synchronous [Hooks](https://ai.google.dev/gemini-api/docs/agent-hooks).9091To limit the agent to specific tools, pass only the ones you need:9293### Python9495 from google import genai9697 client = genai.Client()9899 interaction = client.interactions.create(100 agent="antigravity-preview-09-2026",101 input="Search for the latest AI research papers on reasoning and summarize them.",102 environment="remote",103 tools=[104 {"type": "google_search"},105 {"type": "url_context"},106 ],107 )108109 print(interaction.output_text)110111### JavaScript112113 import { GoogleGenAI } from "@google/genai";114115 const client = new GoogleGenAI({});116117 const interaction = await client.interactions.create({118 agent: "antigravity-preview-09-2026",119 input: "Search for the latest AI research papers on reasoning and summarize them.",120 environment: "remote",121 tools: [122 { type: "google_search" },123 { type: "url_context" },124 ],125 }, { timeout: 300000 });126127 console.log(interaction.output_text);128129### Java130131 import com.google.genai.Client;132 import com.google.genai.gaos.models.interactions.AgentOption;133 import com.google.genai.gaos.models.interactions.CreateAgentInteraction;134 import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;135 import com.google.genai.gaos.models.interactions.GoogleSearch;136 import com.google.genai.gaos.models.interactions.Interaction;137 import com.google.genai.gaos.models.interactions.InteractionsInput;138 import com.google.genai.gaos.models.interactions.URLContext;139 import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;140 import java.util.List;141142 Client client = new Client();143144 CreateAgentInteraction params = CreateAgentInteraction.builder()145 .agent(AgentOption.of("antigravity-preview-09-2026"))146 .input(InteractionsInput.of("Search for the latest AI research papers on reasoning and summarize them."))147 .environment(CreateAgentInteractionEnvironment.of("remote"))148 .tools(List.of(149 GoogleSearch.builder().build(),150 URLContext.builder().build()151 ))152 .build();153154 Interaction interaction = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();155 System.out.println(interaction.outputText().orElse(""));156157### REST158159 curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \160 -H "Content-Type: application/json" \161 -H "x-goog-api-key: $GEMINI_API_KEY" \162 -d '{163 "agent": "antigravity-preview-09-2026",164 "input": "Search for the latest AI research papers on reasoning and summarize them.",165 "environment": "remote",166 "tools": [167 {"type": "google_search"},168 {"type": "url_context"}169 ]170 }'171172## Multimodal Input173174The Antigravity agent supports multimodal inputs. Currently, only `text` and `image` inputs are supported. Images must be supplied as inline base64-encoded strings (`data`).175176### Python177178 import base64179 from google import genai180181 client = genai.Client()182183 with open("path/to/chart.png", "rb") as f:184 image_bytes = f.read()185186 interaction_inline = client.interactions.create(187 agent="antigravity-preview-09-2026",188 input=[189 {"type": "text", "text": "Analyze this chart and summarize the trends."},190 {191 "type": "image",192 "data": base64.b64encode(image_bytes).decode("utf-8"),193 "mime_type": "image/png",194 },195 ],196 environment="remote",197 )198199### JavaScript200201202 import { GoogleGenAI } from "@google/genai";203204 import * as fs from "node:fs";205206 const client = new GoogleGenAI({});207 const base64Image = fs.readFileSync("path/to/chart.png", { encoding: "base64" });208209 const interactionInline = await client.interactions.create({210 agent: "antigravity-preview-09-2026",211 input: [212 { type: "text", text: "Analyze this chart and summarize the trends." },213 {214 type: "image",215 data: base64Image,216 mime_type: "image/png",217 },218 ],219 environment: "remote",220 }, { timeout: 300000 });221222### Java223224 import com.google.genai.Client;225 import com.google.genai.gaos.models.interactions.AgentOption;226 import com.google.genai.gaos.models.interactions.CreateAgentInteraction;227 import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;228 import com.google.genai.gaos.models.interactions.ImageContent;229 import com.google.genai.gaos.models.interactions.ImageContentMimeType;230 import com.google.genai.gaos.models.interactions.Interaction;231 import com.google.genai.gaos.models.interactions.InteractionsInput;232 import com.google.genai.gaos.models.interactions.TextContent;233 import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;234 import java.nio.file.Files;235 import java.nio.file.Paths;236 import java.util.Base64;237 import java.util.List;238239 Client client = new Client();240241 byte[] imageBytes = Files.readAllBytes(Paths.get("path/to/chart.png"));242 String base64Image = Base64.getEncoder().encodeToString(imageBytes);243244 CreateAgentInteraction params = CreateAgentInteraction.builder()245 .agent(AgentOption.of("antigravity-preview-09-2026"))246 .input(InteractionsInput.ofContent(List.of(247 TextContent.builder().text("Analyze this chart and summarize the trends.").build(),248 ImageContent.builder()249 .data(base64Image)250 .mimeType(ImageContentMimeType.IMAGE_PNG)251 .build()252 )))253 .environment(CreateAgentInteractionEnvironment.of("remote"))254 .build();255256 Interaction interactionInline = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();257 System.out.println(interactionInline.outputText().orElse(""));258259### REST260261 BASE64_IMAGE=$(base64 -w0 /path/to/chart.png)262263 curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \264 -H "Content-Type: application/json" \265 -H "x-goog-api-key: $GEMINI_API_KEY" \266 -d "{267 \"agent\": \"antigravity-preview-09-2026\",268 \"input\": [269 {\"type\": \"text\", \"text\": \"Analyze this chart and summarize the trends.\"},270 {271 \"type\": \"image\",272 \"mime_type\": \"image/png\",273 \"data\": \"$BASE64_IMAGE\"274 }275 ],276 \"environment\": \"remote\"277 }"278279## Function calling280281Function calling allows you to connect the Antigravity agent to external APIs and databases by defining custom tools the agent can invoke. For general concepts, see [Function calling with the Gemini API](https://ai.google.dev/gemini-api/docs/function-calling).282283The following example demonstrates a 2-turn interaction. The agent first requests a custom `get_weather` function call, and the client executes it and returns the result in the second turn.284285### Python286287 from google import genai288289 client = genai.Client()290291 # 1. Define the custom function292 get_weather_tool = {293 "type": "function",294 "name": "get_weather",295 "description": "Gets the current weather for a given location.",296 "parameters": {297 "type": "object",298 "properties": {299 "location": {300 "type": "string",301 "description": "The city and country, e.g. San Francisco, USA",302 }303 },304 "required": ["location"],305 },306 }307308 # 2. Call the agent with the custom tool (Turn 1)309 interaction = client.interactions.create(310 agent="antigravity-preview-09-2026",311 input="What is the weather in Tokyo?",312 environment="remote",313 tools=[314 {"type": "code_execution"}, # Enable default code execution315 get_weather_tool, # Add custom function316 ],317 )318319 # Check if the agent requested a function call320 if interaction.status == "requires_action":321 # Find function calls that do not have a matching function result.322 # Filesystem tools (like write_to_file) are also represented as function calls323 # but are executed automatically by the environment.324 executed_calls = {step.call_id for step in interaction.steps if step.type == "function_result"}325 pending_calls = [step for step in interaction.steps if step.type == "function_call" and step.id not in executed_calls]326327 if pending_calls:328 fc_step = pending_calls[0]329 print(f"Function to call: {fc_step.name} (ID: {fc_step.id})")330 print(f"Arguments: {fc_step.arguments}")331332 # 3. Execute the function locally (simulated get_weather()) and send the result back (Turn 2)333 function_result = {334 "temperature": 23,335 "unit": "celsius"336 }337338 final_interaction = client.interactions.create(339 agent="antigravity-preview-09-2026",340 previous_interaction_id=interaction.id, # Reference the interaction ID341 environment=interaction.environment_id,342 input=[343 {344 "type": "function_result",345 "name": fc_step.name,346 "call_id": fc_step.id,347 "result": function_result,348 }349 ],350 )351352 print(final_interaction.output_text)353 # Output: The current weather in Tokyo, Japan is 23°C (Celsius).354 else:355 print("No pending function calls.")356 else:357 print(f"Interaction completed with status: {interaction.status}")358359### JavaScript360361 import { GoogleGenAI } from "@google/genai";362363 const client = new GoogleGenAI({});364365 // 1. Define the custom function366 const get_weather_tool = {367 type: "function",368 name: "get_weather",369 description: "Gets the current weather for a given location.",370 parameters: {371 type: "object",372 properties: {373 location: {374 type: "string",375 description: "The city and country, e.g. San Francisco, USA",376 },377 },378 required: ["location"],379 },380 };381382 // 2. Call the agent with the custom tool (Turn 1)383 const interaction = await client.interactions.create({384 agent: "antigravity-preview-09-2026",385 input: "What is the weather in Tokyo?",386 environment: "remote",387 tools: [388 { type: "code_execution" },389 get_weather_tool,390 ],391 }, { timeout: 300000 });392393 if (interaction.status === "requires_action") {394 // Find function calls that do not have a matching function result.395 // Filesystem tools (like write_to_file) are also represented as function calls396 // but are executed automatically by the environment.397 const executedCalls = new Set(398 interaction.steps399 .filter(s => s.type === "function_result")400 .map(s => s.call_id)401 );402 const pendingCalls = interaction.steps.filter(403 s => s.type === "function_call" && !executedCalls.has(s.id)404 );405406 if (pendingCalls.length > 0) {407 const fcStep = pendingCalls[0];408 console.log(`Function to call: ${fcStep.name} (ID: ${fcStep.id})`);409410 // 3. Execute the function locally (simulated get_weather()) and send the result back (Turn 2)411 const functionResult = {412 temperature: 23,413 unit: "celsius"414 };415416 const finalInteraction = await client.interactions.create({417 agent: "antigravity-preview-09-2026",418 previous_interaction_id: interaction.id, // Reference the interaction ID419 environment: interaction.environment_id,420 input: [421 {422 type: "function_result",423 name: fcStep.name,424 call_id: fcStep.id,425 result: functionResult,426 }427 ],428 }, { timeout: 300000 });429430 console.log(finalInteraction.output_text);431 } else {432 console.log("No pending function calls.");433 }434 } else {435 console.log(`Interaction completed with status: ${interaction.status}`);436 }437438### Java439440 import com.google.genai.Client;441 import com.google.genai.gaos.models.interactions.AgentOption;442 import com.google.genai.gaos.models.interactions.CodeExecution;443 import com.google.genai.gaos.models.interactions.CreateAgentInteraction;444 import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;445 import com.google.genai.gaos.models.interactions.Function;446 import com.google.genai.gaos.models.interactions.FunctionCallStep;447 import com.google.genai.gaos.models.interactions.FunctionResultStep;448 import com.google.genai.gaos.models.interactions.FunctionResultStepResultUnion;449 import com.google.genai.gaos.models.interactions.Interaction;450 import com.google.genai.gaos.models.interactions.InteractionStatus;451 import com.google.genai.gaos.models.interactions.InteractionsInput;452 import com.google.genai.gaos.models.interactions.Step;453 import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;454 import java.util.List;455 import java.util.Map;456 import java.util.Set;457 import java.util.stream.Collectors;458459 Client client = new Client();460461 // 1. Define the custom function462 Function getWeatherTool = Function.builder()463 .name("get_weather")464 .description("Gets the current weather for a given location.")465 .parameters(Map.of(466 "type", "object",467 "properties", Map.of(468 "location", Map.of(469 "type", "string",470 "description", "The city and country, e.g. San Francisco, USA"471 )472 ),473 "required", List.of("location")474 ))475 .build();476477 // 2. Call the agent with the custom tool (Turn 1)478 CreateAgentInteraction params = CreateAgentInteraction.builder()479 .agent(AgentOption.of("antigravity-preview-09-2026"))480 .input(InteractionsInput.of("What is the weather in Tokyo?"))481 .environment(CreateAgentInteractionEnvironment.of("remote"))482 .tools(List.of(483 CodeExecution.builder().build(), // Enable default code execution484 getWeatherTool // Add custom function485 ))486 .build();487488 Interaction interaction = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();489490 // Check if the agent requested a function call491 if (interaction.status().orElse(null) == InteractionStatus.REQUIRES_ACTION) {492 // Find function calls that do not have a matching function result.493 List<Step> steps = interaction.steps().orElse(List.of());494 Set<String> executedCalls = steps.stream()495 .filter(step -> step instanceof FunctionResultStep)496 .map(step -> ((FunctionResultStep) step).callId().orElse(""))497 .collect(Collectors.toSet());498499 List<FunctionCallStep> pendingCalls = steps.stream()500 .filter(step -> step instanceof FunctionCallStep)501 .map(step -> (FunctionCallStep) step)502 .filter(fc -> !executedCalls.contains(fc.id().orElse("")))503 .collect(Collectors.toList());504505 if (!pendingCalls.isEmpty()) {506 FunctionCallStep fcStep = pendingCalls.get(0);507 System.out.println("Function to call: " + fcStep.name().orElse("") + " (ID: " + fcStep.id().orElse("") + ")");508 System.out.println("Arguments: " + fcStep.arguments().orElse(Map.of()));509510 // 3. Execute the function locally (simulated get_weather()) and send the result back (Turn 2)511 FunctionResultStep resultStep = FunctionResultStep.builder()512 .name(fcStep.name().orElse(""))513 .callId(fcStep.id().orElse(""))514 .result(FunctionResultStepResultUnion.of("{\"temperature\": 23, \"unit\": \"celsius\"}"))515 .build();516517 CreateAgentInteraction followupParams = CreateAgentInteraction.builder()518 .agent(AgentOption.of("antigravity-preview-09-2026"))519 .previousInteractionId(interaction.id().orElse(""))520 .environment(CreateAgentInteractionEnvironment.of(interaction.environmentId().orElse("")))521 .input(InteractionsInput.ofStep(List.of(resultStep)))522 .build();523524 Interaction finalInteraction = client.interactions.create(CreateInteractionRequestBody.of(followupParams)).interaction().get();525 System.out.println(finalInteraction.outputText().orElse(""));526 // Output: The current weather in Tokyo, Japan is 23°C (Celsius).527 } else {528 System.out.println("No pending function calls.");529 }530 } else {531 System.out.println("Interaction completed with status: " + interaction.status().orElse(null));532 }533534### REST535536 # 1. Turn 1: Request function call537 RESPONSE=$(curl -s -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \538 -H "Content-Type: application/json" \539 -H "x-goog-api-key: $GEMINI_API_KEY" \540 -d '{541 "agent": "antigravity-preview-09-2026",542 "input": "What is the weather in Tokyo?",543 "environment": "remote",544 "tools": [545 {"type": "code_execution"},546 {547 "type": "function",548 "name": "get_weather",549 "description": "Gets the current weather for a given location.",550 "parameters": {551 "type": "object",552 "properties": {553 "location": {"type": "string"}554 },555 "required": ["location"]556 }557 }558 ]559 }')560561 # Extract interaction ID, environment ID, and call ID (requires jq)562 INTERACTION_ID=$(echo $RESPONSE | jq -r '.id')563 ENVIRONMENT_ID=$(echo $RESPONSE | jq -r '.environment_id')564 CALL_ID=$(echo $RESPONSE | jq -r '.steps[] | select(.type=="function_call") | .id')565566 # 2. Turn 2: Send function result back using variables567 curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \568 -H "Content-Type: application/json" \569 -H "x-goog-api-key: $GEMINI_API_KEY" \570 -d "{571 \"agent\": \"antigravity-preview-09-2026\",572 \"previous_interaction_id\": \"$INTERACTION_ID\",573 \"environment\": \"$ENVIRONMENT_ID\",574 \"input\": [575 {576 \"type\": \"function_result\",577 \"name\": \"get_weather\",578 \"call_id\": \"$CALL_ID\",579 \"result\": {580 \"temperature\": 23,581 \"unit\": \"celsius\"582 }583 }584 ]585 }"586587## MCP servers588589You can connect the Antigravity agent to external tools by registering remote Model Context Protocol (MCP) servers. The agent supports remote MCP servers over streamable HTTP.590591When registering an MCP server, you must specify the following fields in the `tools` array:592593| Field | Type | Required | Description |594|---|---|---|---|595| `type` | string | Yes | Must be `"mcp_server"`. |596| `name` | string | Yes | A unique identifier for the server. Must be strictly lowercase and alphanumeric (matching `^[a-z0-9_-]+$`). |597| `url` | string | Yes | The endpoint URL of the remote MCP server. |598| `headers` | object | No | Custom headers (e.g., authentication) sent with requests. |599| `allowed_tools` | array | No | List of tool names allowed to be executed. If omitted, all tools are allowed. |600601### Python602603 from google import genai604605 client = genai.Client()606607 # Register a remote HTTP MCP server608 interaction = client.interactions.create(609 agent="antigravity-preview-09-2026",610 input="What is the weather in Tokyo?",611 environment="remote",612 tools=[{613 "type": "mcp_server",614 "name": "weather", # Must be lowercase615 "url": "https://gemini-api-demos.uc.r.appspot.com/mcp"616 }]617 )618619 print(interaction.output_text)620621### JavaScript622623 import { GoogleGenAI } from "@google/genai";624625 const client = new GoogleGenAI({});626627 const interaction = await client.interactions.create({628 agent: "antigravity-preview-09-2026",629 input: "What is the weather in Tokyo?",630 environment: "remote",631 tools: [{632 type: "mcp_server",633 name: "weather", // Must be lowercase634 url: "https://gemini-api-demos.uc.r.appspot.com/mcp"635 }]636 }, { timeout: 300000 });637638 console.log(interaction.output_text);639640### Java641642 import com.google.genai.Client;643 import com.google.genai.gaos.models.interactions.AgentOption;644 import com.google.genai.gaos.models.interactions.CreateAgentInteraction;645 import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;646 import com.google.genai.gaos.models.interactions.Interaction;647 import com.google.genai.gaos.models.interactions.InteractionsInput;648 import com.google.genai.gaos.models.interactions.MCPServer;649 import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;650 import java.util.List;651652 Client client = new Client();653654 // Register a remote HTTP MCP server655 CreateAgentInteraction params = CreateAgentInteraction.builder()656 .agent(AgentOption.of("antigravity-preview-09-2026"))657 .input(InteractionsInput.of("What is the weather in Tokyo?"))658 .environment(CreateAgentInteractionEnvironment.of("remote"))659 .tools(List.of(660 MCPServer.builder()661 .name("weather") // Must be lowercase662 .url("https://gemini-api-demos.uc.r.appspot.com/mcp")663 .build()664 ))665 .build();666667 Interaction interaction = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();668 System.out.println(interaction.outputText().orElse(""));669670### REST671672 curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \673 -H "Content-Type: application/json" \674 -H "x-goog-api-key: $GEMINI_API_KEY" \675 -d '{676 "agent": "antigravity-preview-09-2026",677 "input": "What is the weather in Tokyo?",678 "environment": "remote",679 "tools": [{680 "type": "mcp_server",681 "name": "weather",682 "url": "https://gemini-api-demos.uc.r.appspot.com/mcp"683 }]684 }'685686## Model selection687688For `antigravity-preview-09-2026`, the default model is **Gemini 3.8 Flash** (`gemini-3.8-flash`). If you omit `agent_config`, the agent defaults to `gemini-3.8-flash`.689690You can configure the underlying Gemini model using `agent_config` to optimize for speed, cost, or reasoning capability.691692### Python693694 from google import genai695696 client = genai.Client()697698 interaction = client.interactions.create(699 agent="antigravity-preview-09-2026",700 input="Summarize the key differences between functional and object-oriented programming.",701 environment="remote",702 agent_config={703 "type": "antigravity",704 "model": "gemini-3.5-flash-lite",705 },706 )707708 print(interaction.output_text)709710### JavaScript711712 import { GoogleGenAI } from "@google/genai";713714 const client = new GoogleGenAI({});715716 const interaction = await client.interactions.create({717 agent: "antigravity-preview-09-2026",718 input: "Summarize the key differences between functional and object-oriented programming.",719 environment: "remote",720 agent_config: {721 type: "antigravity",722 model: "gemini-3.5-flash-lite",723 },724 }, { timeout: 300000 });725726 console.log(interaction.output_text);727728### Java729730 import com.google.genai.Client;731 import com.google.genai.gaos.models.interactions.AgentOption;732 import com.google.genai.gaos.models.interactions.AntigravityAgentConfig;733 import com.google.genai.gaos.models.interactions.CreateAgentInteraction;734 import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;735 import com.google.genai.gaos.models.interactions.Interaction;736 import com.google.genai.gaos.models.interactions.InteractionsInput;737 import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;738739 Client client = new Client();740741 CreateAgentInteraction params = CreateAgentInteraction.builder()742 .agent(AgentOption.of("antigravity-preview-09-2026"))743 .input(InteractionsInput.of("Summarize the key differences between functional and object-oriented programming."))744 .environment(CreateAgentInteractionEnvironment.of("remote"))745 .agentConfig(746 AntigravityAgentConfig.builder()747 .model("gemini-3.5-flash-lite")748 .build()749 )750 .build();751752 Interaction interaction = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();753 System.out.println(interaction.outputText().orElse(""));754755### REST756757 curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \758 -H "Content-Type: application/json" \759 -H "x-goog-api-key: $GEMINI_API_KEY" \760 -d '{761 "agent": "antigravity-preview-09-2026",762 "input": "Summarize the key differences between functional and object-oriented programming.",763 "environment": "remote",764 "agent_config": {765 "type": "antigravity",766 "model": "gemini-3.5-flash-lite"767 }768 }'769770The supported values for `agent_config.model` are:771772| Model | Value in `agent_config.model` | Description |773|---|---|---|774| **Gemini 3.8 Flash** (default) | `gemini-3.8-flash` | Default balanced model for reasoning, coding, and tool use. |775| **Gemini 3.7 Flash** | `gemini-3.7-flash` | Previous generation Flash model for reasoning, coding, and agentic workflows. |776| **Gemini 3.6 Flash** | `gemini-3.6-flash` | Balanced Flash model for general agentic workflows. |777| **Gemini 3.5 Flash** | `gemini-3.5-flash` | Lightweight model for general workflows. |778| **Gemini 3.5 Flash-Lite** | `gemini-3.5-flash-lite` | Lightweight model optimized for low latency and cost-sensitive tasks. |779780When creating a managed agent with `agents.create`, you configure the model in the exact same way by passing `base_agent` and `agent_config`. Notice that you cannot override the model at interaction time for a managed agent created with `agents.create`. The model is locked to what was set when the agent was created. This ensures predictable tool calling behavior, consistent debugging, and adherence to security boundaries.781782## Customizing the agent783784You can extend the Antigravity agent by customizing its instructions, tools, and environment. The agent supports a filesystem-native approach to customization: you can mount files like `AGENTS.md` for instructions and skills under `.agents/skills/` directly into the sandbox, or pass configuration inline at interaction time. You can iterate on your configuration inline and then save it as a managed agent when you are ready.785786For full details on how to build custom agents, see [Building Managed Agents](https://ai.google.dev/gemini-api/docs/custom-agents).787788## Background execution789790Agent tasks that involve multi-step reasoning, code execution, or file operations can take minutes to complete. Use `background=True` to run the interaction asynchronously. The API returns immediately with an interaction ID that you poll until the status is `completed` or `failed`.791792### Python793794 import time795 from google import genai796797 client = genai.Client()798799 # 1. Start the interaction in the background800 interaction = client.interactions.create(801 agent="antigravity-preview-09-2026",802 input="Run a complex analysis on the repository.",803 environment="remote",804 background=True,805 )806807 print(f"Interaction started in background: {interaction.id}")808809 # 2. Poll for completion810 while interaction.status == "in_progress":811 time.sleep(5)812 interaction = client.interactions.get(id=interaction.id)813814 if interaction.status == "completed":815 print(interaction.output_text)816 else:817 print(f"Finished with status: {interaction.status}")818819### JavaScript820821 import { GoogleGenAI } from "@google/genai";822823 const client = new GoogleGenAI({});824825 const interaction = await client.interactions.create({826 agent: "antigravity-preview-09-2026",827 input: "Run a complex analysis on the repository.",828 environment: "remote",829 background: true,830 });831832 console.log(`Interaction started in background: ${interaction.id}`);833834 let result = interaction;835 while (result.status === "in_progress") {836 await new Promise(resolve => setTimeout(resolve, 5000));837 result = await client.interactions.get(interaction.id);838 }839840 if (result.status === "completed") {841 console.log(result.output_text);842 } else {843 console.log(`Finished with status: ${result.status}`);844 }845846### Java847848 import com.google.genai.Client;849 import com.google.genai.gaos.models.interactions.AgentOption;850 import com.google.genai.gaos.models.interactions.CreateAgentInteraction;851 import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;852 import com.google.genai.gaos.models.interactions.Interaction;853 import com.google.genai.gaos.models.interactions.InteractionStatus;854 import com.google.genai.gaos.models.interactions.InteractionsInput;855 import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;856 import com.google.genai.gaos.models.operations.GetInteractionByIdRequest;857858 Client client = new Client();859860 // 1. Start the interaction in the background861 CreateAgentInteraction params = CreateAgentInteraction.builder()862 .agent(AgentOption.of("antigravity-preview-09-2026"))863 .input(InteractionsInput.of("Run a complex analysis on the repository."))864 .environment(CreateAgentInteractionEnvironment.of("remote"))865 .background(true)866 .build();867868 Interaction interaction = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();869 System.out.println("Interaction started in background: " + interaction.id().orElse(""));870871 // 2. Poll for completion872 while (interaction.status().orElse(null) == InteractionStatus.IN_PROGRESS) {873 Thread.sleep(5000);874 interaction = client.interactions.get(new GetInteractionByIdRequest(interaction.id().orElse(""))).interaction().get();875 }876877 if (interaction.status().orElse(null) == InteractionStatus.COMPLETED) {878 System.out.println(interaction.outputText().orElse(""));879 } else {880 System.out.println("Finished with status: " + interaction.status().orElse(null));881 }882883### REST884885 # 1. Start the interaction in the background886 RESPONSE=$(curl -s -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \887 -H "Content-Type: application/json" \888 -H "x-goog-api-key: $GEMINI_API_KEY" \889 -H "Api-Revision: 2026-05-20" \890 -d '{891 "agent": "antigravity-preview-09-2026",892 "input": "Run a complex analysis on the repository.",893 "environment": "remote",894 "background": true895 }')896897 INTERACTION_ID=$(echo $RESPONSE | jq -r '.id')898899 # 2. Poll for results (repeat until status is "completed")900 curl -s -X GET "https://generativelanguage.googleapis.com/v1beta/interactions/$INTERACTION_ID" \901 -H "x-goog-api-key: $GEMINI_API_KEY"902903Background execution requires `store=True`, which is the default. For real-time progress updates during background execution, see [Streaming background interactions](https://ai.google.dev/gemini-api/docs/background-execution#streaming-pattern).904905You can cancel a running background interaction using the `cancel` method.906907### Python908909 client.interactions.cancel(id="INTERACTION_ID")910911### JavaScript912913 await client.interactions.cancel("INTERACTION_ID");914915### Java916917 import com.google.genai.Client;918919 Client client = new Client();920 client.interactions.cancel("INTERACTION_ID");921922### REST923924 curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions/INTERACTION_ID:cancel" \925 -H "x-goog-api-key: $GEMINI_API_KEY"926927**Multi-turn with background execution**928929When a background interaction involves stateful tools (like code execution in a sandbox), use the `environment_id` from the completed interaction to continue in the same environment. This ensures the agent picks up where it left off with all files and state intact.930931### Python932933 import time934 from google import genai935936 client = genai.Client()937938 # First turn: run a task in the background939 interaction = client.interactions.create(940 agent="antigravity-preview-09-2026",941 input="Clone https://github.com/google/generative-ai-python and run its tests.",942 environment="remote",943 background=True,944 )945946 while interaction.status == "in_progress":947 time.sleep(5)948 interaction = client.interactions.get(id=interaction.id)949950 # Second turn: continue in the same environment951 followup = client.interactions.create(952 agent="antigravity-preview-09-2026",953 input="Fix any failing tests and re-run them.",954 previous_interaction_id=interaction.id,955 environment=interaction.environment_id,956 background=True,957 )958959 while followup.status == "in_progress":960 time.sleep(5)961 followup = client.interactions.get(id=followup.id)962963 print(followup.output_text)964965### JavaScript966967 import { GoogleGenAI } from "@google/genai";968969 const client = new GoogleGenAI({});970971 // First turn: run a task in the background972 let interaction = await client.interactions.create({973 agent: "antigravity-preview-09-2026",974 input: "Clone https://github.com/google/generative-ai-python and run its tests.",975 environment: "remote",976 background: true,977 });978979 while (interaction.status === "in_progress") {980 await new Promise(resolve => setTimeout(resolve, 5000));981 interaction = await client.interactions.get(interaction.id);982 }983984 // Second turn: continue in the same environment985 let followup = await client.interactions.create({986 agent: "antigravity-preview-09-2026",987 input: "Fix any failing tests and re-run them.",988 previous_interaction_id: interaction.id,989 environment: interaction.environment_id,990 background: true,991 });992993 while (followup.status === "in_progress") {994 await new Promise(resolve => setTimeout(resolve, 5000));995 followup = await client.interactions.get(followup.id);996 }997998 console.log(followup.output_text);9991000### Java10011002 import com.google.genai.Client;1003 import com.google.genai.gaos.models.interactions.AgentOption;1004 import com.google.genai.gaos.models.interactions.CreateAgentInteraction;1005 import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;1006 import com.google.genai.gaos.models.interactions.Interaction;1007 import com.google.genai.gaos.models.interactions.InteractionStatus;1008 import com.google.genai.gaos.models.interactions.InteractionsInput;1009 import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;1010 import com.google.genai.gaos.models.operations.GetInteractionByIdRequest;10111012 Client client = new Client();10131014 // First turn: run a task in the background1015 CreateAgentInteraction params = CreateAgentInteraction.builder()1016 .agent(AgentOption.of("antigravity-preview-09-2026"))1017 .input(InteractionsInput.of("Clone https://github.com/google/generative-ai-python and run its tests."))1018 .environment(CreateAgentInteractionEnvironment.of("remote"))1019 .background(true)1020 .build();10211022 Interaction interaction = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();10231024 while (interaction.status().orElse(null) == InteractionStatus.IN_PROGRESS) {1025 Thread.sleep(5000);1026 interaction = client.interactions.get(new GetInteractionByIdRequest(interaction.id().orElse(""))).interaction().get();1027 }10281029 // Second turn: continue in the same environment1030 CreateAgentInteraction followupParams = CreateAgentInteraction.builder()1031 .agent(AgentOption.of("antigravity-preview-09-2026"))1032 .input(InteractionsInput.of("Fix any failing tests and re-run them."))1033 .previousInteractionId(interaction.id().orElse(""))1034 .environment(CreateAgentInteractionEnvironment.of(interaction.environmentId().orElse("")))1035 .background(true)1036 .build();10371038 Interaction followup = client.interactions.create(CreateInteractionRequestBody.of(followupParams)).interaction().get();10391040 while (followup.status().orElse(null) == InteractionStatus.IN_PROGRESS) {1041 Thread.sleep(5000);1042 followup = client.interactions.get(new GetInteractionByIdRequest(followup.id().orElse(""))).interaction().get();1043 }10441045 System.out.println(followup.outputText().orElse(""));10461047### REST10481049 # 1. Start first interaction in the background1050 RESPONSE=$(curl -s -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \1051 -H "Content-Type: application/json" \1052 -H "x-goog-api-key: $GEMINI_API_KEY" \1053 -H "Api-Revision: 2026-05-20" \1054 -d '{1055 "agent": "antigravity-preview-09-2026",1056 "input": "Clone https://github.com/google/generative-ai-python and run its tests.",1057 "environment": "remote",1058 "background": true1059 }')10601061 INTERACTION_ID=$(echo $RESPONSE | jq -r '.id')10621063 # 2. Poll until completed (repeat until status is "completed")1064 RESULT=$(curl -s -X GET "https://generativelanguage.googleapis.com/v1beta/interactions/$INTERACTION_ID" \1065 -H "x-goog-api-key: $GEMINI_API_KEY")10661067 ENVIRONMENT_ID=$(echo $RESULT | jq -r '.environment_id')10681069 # 3. Continue in the same environment1070 curl -s -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \1071 -H "Content-Type: application/json" \1072 -H "x-goog-api-key: $GEMINI_API_KEY" \1073 -H "Api-Revision: 2026-05-20" \1074 -d "{1075 \"agent\": \"antigravity-preview-09-2026\",1076 \"input\": \"Fix any failing tests and re-run them.\",1077 \"previous_interaction_id\": \"$INTERACTION_ID\",1078 \"environment\": \"$ENVIRONMENT_ID\",1079 \"background\": true1080 }"10811082## Environments10831084Each call creates or reuses a Linux sandbox. The `environment` parameter takes three forms:10851086| Form | Description |1087|---|---|1088| `"remote"` | Provision a fresh sandbox with default settings. |1089| `"env_abc123"` | Reuse an existing environment by ID, preserving all files and state. |1090| `{...}` | Full `EnvironmentConfig` with custom sources and network rules. |10911092See [Environments](https://ai.google.dev/gemini-api/docs/agent-environment) for details on sources (Git, GCS, inline), networking, lifecycle, and resource limits.10931094## Triggers10951096Triggers let you schedule an agent to run automatically on a cron schedule. A trigger binds an agent, environment, prompt, and schedule into a persistent resource that fires without manual intervention. Each execution reuses the same environment, so files created in one run persist and are visible to the next.10971098### Create a trigger10991100Create a trigger by specifying a cron schedule, time zone, and the interaction configuration. The trigger starts in `active` status and will fire on the next matching cron time. Save the returned `id` to manage the trigger in subsequent calls.11011102Because a trigger runs unattended on a schedule, reference a stored [credential](https://ai.google.dev/gemini-api/docs/agent-credentials) rather than an inline token. The egress proxy resolves it on every run, and you rotate the secret without touching the trigger. Inline `transform` rules work here too, they just need you to update the trigger whenever the value changes.11031104### Python11051106 from google import genai11071108 client = genai.Client()11091110 trigger = client.triggers.create(1111 schedule="0 9 * * *",1112 time_zone="America/Argentina/Buenos_Aires",1113 display_name="issue-solver",1114 interaction={1115 "agent": "antigravity-preview-09-2026",1116 "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/.",1117 "environment": {1118 "type": "remote",1119 "network": {1120 "allowlist": [1121 {1122 "domain": "api.github.com",1123 "credential": "github-production",1124 },1125 {"domain": "github.com"},1126 ]1127 },1128 },1129 },1130 )11311132 print(f"Trigger created: {trigger.id}")1133 print(f"Next run: {trigger.next_run_time}")11341135### JavaScript11361137 import { GoogleGenAI } from "@google/genai";11381139 const client = new GoogleGenAI({});11401141 const trigger = await client.triggers.create({1142 schedule: "0 9 * * *",1143 time_zone: "America/Argentina/Buenos_Aires",1144 display_name: "issue-solver",1145 interaction: {1146 agent: "antigravity-preview-09-2026",1147 input: [{1148 type: "text",1149 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/.",1150 }],1151 environment: {1152 type: "remote",1153 network: {1154 allowlist: [1155 {1156 domain: "api.github.com",1157 credential: "github-production",1158 },1159 { domain: "github.com" },1160 ],1161 },1162 },1163 },1164 });11651166 console.log(`Trigger created: ${trigger.id}`);1167 console.log(`Next run: ${trigger.next_run_time}`);11681169### Java11701171 import com.google.genai.gaos.GenAI;1172 import com.google.genai.gaos.models.interactions.AgentOption;1173 import com.google.genai.gaos.models.interactions.Allowlist;1174 import com.google.genai.gaos.models.interactions.AllowlistEntry;1175 import com.google.genai.gaos.models.interactions.CreateAgentInteraction;1176 import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;1177 import com.google.genai.gaos.models.interactions.Environment;1178 import com.google.genai.gaos.models.interactions.EnvironmentNetworkEgressAllowlist;1179 import com.google.genai.gaos.models.interactions.InteractionsInput;1180 import com.google.genai.gaos.models.interactions.Network;1181 import com.google.genai.gaos.models.interactions.Transform;1182 import com.google.genai.gaos.models.shared.Security;1183 import com.google.genai.gaos.models.triggers.Interaction;1184 import com.google.genai.gaos.models.triggers.Trigger;1185 import com.google.genai.gaos.models.triggers.TriggerCreateParams;1186 import java.util.List;1187 import java.util.Map;11881189 GenAI client = GenAI.builder()1190 .security(Security.builder().apiKey(System.getenv("GEMINI_API_KEY")).build())1191 .build();11921193 Environment env = Environment.builder()1194 .network(Network.of(EnvironmentNetworkEgressAllowlist.of(1195 Allowlist.builder()1196 .allowlist(List.of(1197 AllowlistEntry.builder()1198 .domain("api.github.com")1199 .transform(Transform.of(Map.of(1200 "Authorization", "Bearer ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"1201 )))1202 .build(),1203 AllowlistEntry.builder()1204 .domain("github.com")1205 .build()1206 ))1207 .build()1208 )))1209 .build();12101211 CreateAgentInteraction interactionTemplate = CreateAgentInteraction.builder()1212 .agent(AgentOption.of("antigravity-preview-09-2026"))1213 .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/."))1214 .environment(CreateAgentInteractionEnvironment.of(env))1215 .build();12161217 TriggerCreateParams params = TriggerCreateParams.builder()1218 .schedule("0 9 * * *")1219 .timeZone("America/Argentina/Buenos_Aires")1220 .displayName("issue-solver")1221 .interaction(Interaction.of(interactionTemplate))1222 .build();12231224 Trigger trigger = client.triggers().create(params).trigger().get();1225 System.out.println("Trigger created: " + trigger.id().orElse(""));1226 System.out.println("Next run: " + trigger.nextRunTime().orElse(null));12271228### REST12291230 curl -X POST "https://generativelanguage.googleapis.com/v1beta/triggers" \1231 -H "Content-Type: application/json" \1232 -H "x-goog-api-key: $GEMINI_API_KEY" \1233 -d '{1234 "schedule": "0 9 * * *",1235 "time_zone": "America/Argentina/Buenos_Aires",1236 "display_name": "issue-solver",1237 "interaction": {1238 "agent": "antigravity-preview-09-2026",1239 "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/."}],1240 "environment": {1241 "type": "remote",1242 "network": {1243 "allowlist": [1244 {1245 "domain": "api.github.com",1246 "credential": "github-production"1247 },1248 {"domain": "github.com"}1249 ]1250 }1251 }1252 }1253 }'12541255The `CreateTrigger` request accepts the following fields:12561257| Field | Type | Required | Description |1258|---|---|---|---|1259| `schedule` | string | Yes | Cron expression (e.g., `0 * * * *` for hourly, `0 9 * * 1-5` for weekday mornings). |1260| `time_zone` | string | Yes | IANA time zone (e.g., `UTC`, `America/Argentina/Buenos_Aires`). |1261| `display_name` | string | No | Human-readable name for the trigger. |1262| `max_consecutive_failures` | integer | No | Max failures before the trigger is automatically paused. Default: 5. |1263| `execution_timeout_seconds` | integer | No | Timeout per execution in seconds. Default: 600. |1264| `interaction` | object | Yes | A `CreateInteractionRequest` defining the agent, input, tools, and environment. |12651266The response includes the following key fields:12671268| Field | Type | Description |1269|---|---|---|1270| `id` | string | Unique identifier for the trigger. Use this in all subsequent operations. |1271| `status` | string | Current state: `active`, `paused`, or `disabled`. |1272| `next_run_time` | string | ISO 8601 timestamp of the next scheduled execution. |1273| `consecutive_failure_count` | integer | Number of consecutive failed executions since the last success. |12741275### List triggers12761277Retrieve all triggers associated with your project.12781279### Python12801281 triggers = client.triggers.list()1282 for trigger in triggers.triggers:1283 print(f"{trigger.id}: {trigger.display_name} ({trigger.status})")12841285### JavaScript12861287 const triggers = await client.triggers.list();1288 for (const trigger of triggers.triggers) {1289 console.log(`${trigger.id}: ${trigger.display_name} (${trigger.status})`);1290 }12911292### Java12931294 import com.google.genai.gaos.GenAI;1295 import com.google.genai.gaos.models.shared.Security;1296 import com.google.genai.gaos.models.triggers.Trigger;1297 import java.util.List;12981299 GenAI client = GenAI.builder()1300 .security(Security.builder().apiKey(System.getenv("GEMINI_API_KEY")).build())1301 .build();13021303 List<Trigger> triggers = client.triggers().listDirect().listTriggersResponse().get().triggers().orElse(List.of());1304 for (Trigger trigger : triggers) {1305 System.out.println(trigger.id().orElse("") + ": " + trigger.displayName().orElse("") + " (" + trigger.status().orElse(null) + ")");1306 }13071308### REST13091310 curl -X GET "https://generativelanguage.googleapis.com/v1beta/triggers" \1311 -H "x-goog-api-key: $GEMINI_API_KEY"13121313### Get a trigger13141315Fetch the full configuration and current state of a single trigger.13161317### Python13181319 trigger = client.triggers.get(id="TRIGGER_ID")1320 print(f"Schedule: {trigger.schedule}")1321 print(f"Next run: {trigger.next_run_time}")13221323### JavaScript13241325 const trigger = await client.triggers.get("TRIGGER_ID");1326 console.log(`Schedule: ${trigger.schedule}`);1327 console.log(`Next run: ${trigger.next_run_time}`);13281329### Java13301331 import com.google.genai.gaos.GenAI;1332 import com.google.genai.gaos.models.shared.Security;1333 import com.google.genai.gaos.models.triggers.Trigger;13341335 GenAI client = GenAI.builder()1336 .security(Security.builder().apiKey(System.getenv("GEMINI_API_KEY")).build())1337 .build();13381339 Trigger trigger = client.triggers().get("TRIGGER_ID").trigger().get();1340 System.out.println("Schedule: " + trigger.schedule().orElse(""));1341 System.out.println("Next run: " + trigger.nextRunTime().orElse(null));13421343### REST13441345 curl -X GET "https://generativelanguage.googleapis.com/v1beta/triggers/TRIGGER_ID" \1346 -H "x-goog-api-key: $GEMINI_API_KEY"13471348### Pause and resume13491350You can pause a trigger to stop scheduled executions, and resume it to reactivate the schedule. Pausing does not affect manual executions.13511352### Python13531354 # Pause1355 client.triggers.update(id="TRIGGER_ID", status="paused")13561357 # Resume1358 client.triggers.update(id="TRIGGER_ID", status="active")13591360### JavaScript13611362 // Pause1363 await client.triggers.update("TRIGGER_ID", { status: "paused" });13641365 // Resume1366 await client.triggers.update("TRIGGER_ID", { status: "active" });13671368### Java13691370 import com.google.genai.gaos.GenAI;1371 import com.google.genai.gaos.models.shared.Security;1372 import com.google.genai.gaos.models.triggers.TriggerUpdate;1373 import com.google.genai.gaos.models.triggers.TriggerUpdateStatus;13741375 GenAI client = GenAI.builder()1376 .security(Security.builder().apiKey(System.getenv("GEMINI_API_KEY")).build())1377 .build();13781379 // Pause1380 client.triggers().update("TRIGGER_ID", TriggerUpdate.builder().status(TriggerUpdateStatus.PAUSED).build());13811382 // Resume1383 client.triggers().update("TRIGGER_ID", TriggerUpdate.builder().status(TriggerUpdateStatus.ACTIVE).build());13841385### REST13861387 # Pause1388 curl -X PATCH "https://generativelanguage.googleapis.com/v1beta/triggers/TRIGGER_ID" \1389 -H "Content-Type: application/json" \1390 -H "x-goog-api-key: $GEMINI_API_KEY" \1391 -d '{"status": "paused"}'13921393 # Resume1394 curl -X PATCH "https://generativelanguage.googleapis.com/v1beta/triggers/TRIGGER_ID" \1395 -H "Content-Type: application/json" \1396 -H "x-goog-api-key: $GEMINI_API_KEY" \1397 -d '{"status": "active"}'13981399### Delete a trigger14001401Permanently remove a trigger. Past execution history is not deleted.14021403### Python14041405 client.triggers.delete(id="TRIGGER_ID")14061407### JavaScript14081409 await client.triggers.delete("TRIGGER_ID");14101411### Java14121413 import com.google.genai.gaos.GenAI;1414 import com.google.genai.gaos.models.shared.Security;14151416 GenAI client = GenAI.builder()1417 .security(Security.builder().apiKey(System.getenv("GEMINI_API_KEY")).build())1418 .build();14191420 client.triggers().delete("TRIGGER_ID");14211422### REST14231424 curl -X DELETE "https://generativelanguage.googleapis.com/v1beta/triggers/TRIGGER_ID" \1425 -H "x-goog-api-key: $GEMINI_API_KEY"14261427### Run a trigger immediately14281429Fire a trigger on demand without waiting for the next scheduled time. This works even if the trigger is paused.14301431### Python14321433 client.triggers.run(trigger_id="TRIGGER_ID")14341435### JavaScript14361437 await client.triggers.run("TRIGGER_ID");14381439### Java14401441 import com.google.genai.gaos.GenAI;1442 import com.google.genai.gaos.models.shared.Security;14431444 GenAI client = GenAI.builder()1445 .security(Security.builder().apiKey(System.getenv("GEMINI_API_KEY")).build())1446 .build();14471448 client.triggers().run("TRIGGER_ID");14491450### REST14511452 curl -X POST "https://generativelanguage.googleapis.com/v1beta/triggers/TRIGGER_ID/executions" \1453 -H "x-goog-api-key: $GEMINI_API_KEY"14541455### List executions14561457View the execution history for a trigger. Each execution includes a `status`, timestamps, an `interaction_id` you can use to fetch the full interaction output, and an `environment_id` confirming that all runs share the same sandbox.14581459### Python14601461 executions = client.triggers.list_executions(trigger_id="TRIGGER_ID")1462 for ex in executions.trigger_executions:1463 print(f"{ex.id}: {ex.status} ({ex.start_time} - {ex.end_time})")14641465 # Fetch the full interaction for an execution1466 interaction = client.interactions.get(id=ex.interaction_id)1467 print(interaction.output_text)14681469### JavaScript14701471 const executions = await client.triggers.listExecutions("TRIGGER_ID");1472 for (const ex of executions.trigger_executions) {1473 console.log(`${ex.id}: ${ex.status} (${ex.start_time} - ${ex.end_time})`);1474 }14751476 // Fetch the full interaction for an execution1477 const interaction = await client.interactions.get(ex.interaction_id);1478 console.log(interaction.output_text);14791480### Java14811482 import com.google.genai.gaos.GenAI;1483 import com.google.genai.gaos.models.interactions.Interaction;1484 import com.google.genai.gaos.models.operations.GetInteractionByIdRequest;1485 import com.google.genai.gaos.models.shared.Security;1486 import com.google.genai.gaos.models.triggers.TriggerExecution;1487 import java.util.List;14881489 GenAI client = GenAI.builder()1490 .security(Security.builder().apiKey(System.getenv("GEMINI_API_KEY")).build())1491 .build();14921493 List<TriggerExecution> executions = client.triggers().listExecutions("TRIGGER_ID")1494 .listTriggerExecutionsResponse().get()1495 .triggerExecutions().orElse(List.of());14961497 for (TriggerExecution ex : executions) {1498 System.out.println(ex.id().orElse("") + ": " + ex.status().orElse(null)1499 + " (" + ex.startTime().orElse(null) + " - " + ex.endTime().orElse(null) + ")");15001501 // Fetch the full interaction for an execution1502 if (ex.interactionId().isPresent()) {1503 Interaction interaction = client.interactions().get(new GetInteractionByIdRequest(ex.interactionId().get())).interaction().get();1504 System.out.println(interaction.outputText().orElse(""));1505 }1506 }15071508### REST15091510 curl -X GET "https://generativelanguage.googleapis.com/v1beta/triggers/TRIGGER_ID/executions" \1511 -H "x-goog-api-key: $GEMINI_API_KEY"15121513## Availability and pricing15141515Antigravity agent is available in preview through the1516[Interactions API](https://ai.google.dev/gemini-api/docs/interactions-overview) in Google AI Studio1517and the Gemini API for both free tier and paid tier projects.15181519Pricing follows a [pay-as-you-go model](https://ai.google.dev/gemini-api/docs/pricing#pricing-for-agents)1520based on the underlying Gemini model tokens and the tools the agent uses. Unlike a1521standard chat request that produces a single output, an Antigravity interaction is an1522agentic workflow. A single request triggers an autonomous loop of reasoning, tool1523execution, code running, and file management. Free tier projects include a free rate limit1524and usage quota.15251526Antigravity interactions run multi-turn autonomous loops and can consume1527significant tokens. Set [budget controls](https://ai.google.dev/gemini-api/docs/antigravity-agent#budget-controls) on your request to1528limit token usage. You can also monitor progress in real time with1529[SSE streaming](https://ai.google.dev/gemini-api/docs/streaming), or cancel running requests.15301531### Budget controls15321533In addition to [model selection](https://ai.google.dev/gemini-api/docs/antigravity-agent#model-selection), set `max_total_tokens` inside `agent_config` (with `"type": "antigravity"`) to limit1534the total number of tokens (input + output + thinking) an interaction can consume.1535Cached tokens do not count toward this limit. When the agent reaches the limit, the1536interaction stops and returns with `status: "incomplete"`. The limit is best-effort:1537actual usage may slightly exceed it depending on when the agent checks the budget1538between steps.15391540Set the budget on the interaction request in `agent_config` alongside `agent` and `input`.15411542### Python15431544 from google import genai15451546 client = genai.Client()15471548 interaction = client.interactions.create(1549 agent="antigravity-preview-09-2026",1550 input="Analyze the dataset in /workspace/data.csv and generate a summary report.",1551 agent_config={1552 "type": "antigravity",1553 "max_total_tokens": 500001554 },1555 environment={1556 "type": "remote",1557 "sources": [1558 {1559 "type": "inline",1560 "target": "/workspace/data.csv",1561 "content": "id,name,value\n1,alpha,100\n2,beta,200\n",1562 }1563 ],1564 }1565 )1566 print(f"Status: {interaction.status}") # "incomplete" if budget was hit1567 print(f"Tokens used: {interaction.usage.total_tokens}")15681569### JavaScript15701571 import { GoogleGenAI } from "@google/genai";15721573 const client = new GoogleGenAI({});15741575 const interaction = await client.interactions.create({1576 agent: "antigravity-preview-09-2026",1577 input: "Analyze the dataset in /workspace/data.csv and generate a summary report.",1578 agent_config: {1579 type: "antigravity",1580 max_total_tokens: 500001581 },1582 environment: {1583 type: "remote",1584 sources: [1585 {1586 type: "inline",1587 target: "/workspace/data.csv",1588 content: "id,name,value\n1,alpha,100\n2,beta,200\n",1589 },1590 ],1591 },1592 });1593 console.log(`Status: ${interaction.status}`);1594 console.log(`Tokens used: ${interaction.usage.total_tokens}`);15951596### Java15971598 import com.google.genai.Client;1599 import com.google.genai.gaos.models.interactions.AgentOption;1600 import com.google.genai.gaos.models.interactions.AntigravityAgentConfig;1601 import com.google.genai.gaos.models.interactions.CreateAgentInteraction;1602 import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;1603 import com.google.genai.gaos.models.interactions.Environment;1604 import com.google.genai.gaos.models.interactions.Interaction;1605 import com.google.genai.gaos.models.interactions.InteractionsInput;1606 import com.google.genai.gaos.models.interactions.Source;1607 import com.google.genai.gaos.models.interactions.SourceType;1608 import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;1609 import java.util.List;16101611 Client client = new Client();16121613 Environment env = Environment.builder()1614 .sources(List.of(1615 Source.builder()1616 .type(SourceType.INLINE)1617 .target("/workspace/data.csv")1618 .content("id,name,value\n1,alpha,100\n2,beta,200\n")1619 .build()1620 ))1621 .build();16221623 CreateAgentInteraction params = CreateAgentInteraction.builder()1624 .agent(AgentOption.of("antigravity-preview-09-2026"))1625 .input(InteractionsInput.of("Analyze the dataset in /workspace/data.csv and generate a summary report."))1626 .agentConfig(1627 AntigravityAgentConfig.builder()1628 .maxTotalTokens("50000")1629 .build()1630 )1631 .environment(CreateAgentInteractionEnvironment.of(env))1632 .build();16331634 Interaction interaction = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();1635 System.out.println("Status: " + interaction.status().orElse(null)); // "incomplete" if budget was hit1636 interaction.usage().ifPresent(usage -> System.out.println("Tokens used: " + usage.totalTokens().orElse(0)));16371638### REST16391640 curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \1641 -H "Content-Type: application/json" \1642 -H "x-goog-api-key: $GEMINI_API_KEY" \1643 -d '{1644 "agent": "antigravity-preview-09-2026",1645 "input": "Analyze the dataset in /workspace/data.csv and generate a summary report.",1646 "agent_config": {1647 "type": "antigravity",1648 "max_total_tokens": 500001649 },1650 "environment": {1651 "type": "remote",1652 "sources": [1653 {1654 "type": "inline",1655 "target": "/workspace/data.csv",1656 "content": "id,name,value\n1,alpha,100\n2,beta,200\n"1657 }1658 ]1659 }1660 }'16611662#### Continuing an incomplete interaction16631664When an interaction returns `status: "incomplete"`, the agent's work and context1665are preserved. Send a new interaction referencing the original interaction `id` and1666`environment_id` to pick up where it left off. The new interaction gets its own1667`max_total_tokens` budget.16681669### Python16701671 # Continue from where the agent stopped1672 continuation = client.interactions.create(1673 agent="antigravity-preview-09-2026",1674 input="continue",1675 previous_interaction_id=interaction.id,1676 environment=interaction.environment_id,1677 agent_config={1678 "type": "antigravity",1679 "max_total_tokens": 500001680 }1681 )1682 print(f"Status: {continuation.status}")16831684### JavaScript16851686 const continuation = await client.interactions.create({1687 agent: "antigravity-preview-09-2026",1688 input: "continue",1689 previous_interaction_id: interaction.id,1690 environment: interaction.environment_id,1691 agent_config: {1692 type: "antigravity",1693 max_total_tokens: 500001694 }1695 });1696 console.log(`Status: ${continuation.status}`);16971698### Java16991700 import com.google.genai.Client;1701 import com.google.genai.gaos.models.interactions.AgentOption;1702 import com.google.genai.gaos.models.interactions.AntigravityAgentConfig;1703 import com.google.genai.gaos.models.interactions.CreateAgentInteraction;1704 import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;1705 import com.google.genai.gaos.models.interactions.Interaction;1706 import com.google.genai.gaos.models.interactions.InteractionsInput;1707 import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;17081709 Client client = new Client();1710 String interactionId = "INTERACTION_ID";1711 String environmentId = "ENVIRONMENT_ID";17121713 // Continue from where the agent stopped1714 CreateAgentInteraction params = CreateAgentInteraction.builder()1715 .agent(AgentOption.of("antigravity-preview-09-2026"))1716 .input(InteractionsInput.of("continue"))1717 .previousInteractionId(interactionId)1718 .environment(CreateAgentInteractionEnvironment.of(environmentId))1719 .agentConfig(1720 AntigravityAgentConfig.builder()1721 .maxTotalTokens("50000")1722 .build()1723 )1724 .build();17251726 Interaction continuation = client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();1727 System.out.println("Status: " + continuation.status().orElse(null));17281729### REST17301731 curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \1732 -H "Content-Type: application/json" \1733 -H "x-goog-api-key: $GEMINI_API_KEY" \1734 -d '{1735 "agent": "antigravity-preview-09-2026",1736 "input": "continue",1737 "previous_interaction_id": "INTERACTION_ID",1738 "environment": "ENVIRONMENT_ID",1739 "agent_config": {1740 "type": "antigravity",1741 "max_total_tokens": 500001742 }1743 }'17441745### Estimated costs17461747Costs vary based on task complexity. The agent autonomously determines how many tool calls, code executions, and file operations are needed. The following estimates are based on runs.17481749| Task category | Input tokens | Output tokens | Typical cost |1750|---|---|---|---|1751| **Research \& information synthesis** | 100k--500k | 10k--40k | $0.30--$1.00 |1752| **Document \& content generation** | 100k--500k | 15k--50k | $0.30--$1.30 |1753| **Process \& system design** | 100k--400k | 10k--30k | $0.25--$0.80 |1754| **Data processing \& analysis** | 300k--3M | 30k--150k | $0.70--$3.25 |1755175650--70% of input tokens are typically cached. Complex agentic workflows with many tool calls can accumulate 3--5 million tokens in a single interaction, with costs up to \~$5.17571758**Environment compute** (CPU, memory, sandbox execution) is **not billed** during the preview period.17591760## Limitations17611762- **Preview status:** The Antigravity agent and the Interactions API. Features and schemas may change.1763- **Unsupported generation config:** The following parameters are not supported and return a 400 error: `temperature`, `top_p`, `top_k`, `stop_sequences`, `max_output_tokens`.1764- **Structured output:** The Antigravity agent does not support structured outputs.1765- **Unavailable tools:** `file_search`, `computer_use`, and `google_maps` are not yet supported.1766- **Remote MCP limitations:** Server-Sent Events (SSE) transport is not supported (use Streamable HTTP). Additionally, the server `name` must be strictly lowercase and alphanumeric (using uppercase letters triggers a generic `400 Bad Request` error).1767- **Filesystem tool:** There is no filesystem tool at the moment. It is part of the `environment`.1768- **Store requirement:** Agent execution using `background=True` requires `store=True`.1769- **Stateful only function calling:** Function calling is only supported in stateful mode. You must use `previous_interaction_id` to continue the turn; reconstructing history manually (stateless mode) is not supported.1770- **Unsupported multimodal types.** Audio, video, and document inputs are not supported at the moment. Only text and image are allowed.17711772## What's next17731774- [Quickstart](https://ai.google.dev/gemini-api/docs/managed-agents-quickstart): multi-turn conversations and streaming.1775- [Building Custom Agents](https://ai.google.dev/gemini-api/docs/custom-agents): custom instructions, skills, and saving agents.1776- [Environments](https://ai.google.dev/gemini-api/docs/agent-environment): sandbox configuration, sources, networking.1777- [Hooks](https://ai.google.dev/gemini-api/docs/agent-hooks): enforce security gates and side-effect validation inside the sandbox.1778- [Deep Research agent](https://ai.google.dev/gemini-api/docs/deep-research): long-form research tasks.1779- [Interactions API](https://ai.google.dev/gemini-api/docs/interactions-overview): the underlying API.