Antigravity Agent

Agent ของ Antigravity เป็น Agent ที่ได้รับการจัดการแบบอเนกประสงค์ใน Gemini API การเรียก API ครั้งเดียวจะทำให้คุณมีเอเจนต์ที่ให้เหตุผล ดำเนินการโค้ด จัดการไฟล์ และท่องเว็บภายในแซนด์บ็อกซ์ Linux ที่ปลอดภัยของคุณเอง ซึ่งโฮสต์โดย Google

โดยขับเคลื่อนด้วย Gemini 3.5 Flash และใช้ Harness เดียวกับ Antigravity IDE พร้อมใช้งานผ่าน Interactions API และ Google AI Studio

Python

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    agent="antigravity-preview-05-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-05-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);

REST

curl -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-05-2026",
    "input": "Read Hacker News, summarize the top 10 stories, and save the results as a PDF.",
    "environment": "remote"
}'

ความสามารถ

แต่ละการเรียกใช้จะจัดสรรแซนด์บ็อกซ์ Linux และเริ่มลูปการใช้เครื่องมือ เอเจนต์จะวางแผน ดำเนินการ สังเกตผลลัพธ์ และทำซ้ำจนกว่าจะทำงานเสร็จ

  • การเรียกใช้โค้ด: เรียกใช้คำสั่ง Bash, Python และ Node.js ติดตั้งแพ็กเกจ เรียกใช้การทดสอบ สร้างแอป
  • การจัดการไฟล์: อ่าน เขียน แก้ไข ค้นหา และแสดงรายการไฟล์ในแซนด์บ็อกซ์ ไฟล์จะยังคงอยู่ในการโต้ตอบ
  • การเข้าถึงเว็บ: Google Search และการดึงข้อมูล URL
  • การบีบอัดบริบท: การบีบอัดบริบทอัตโนมัติ (ทริกเกอร์ที่โทเค็นประมาณ 135, 000 รายการ) เพื่อรองรับเซสชันการสนทนาไปมาที่ทำงานเป็นเวลานานโดยไม่สูญเสียบริบทหรือเกินขีดจำกัดโทเค็น

ดูการเริ่มต้นอย่างรวดเร็วสำหรับการใช้งานแบบหลายรอบและการสตรีม

เครื่องมือที่รองรับ

โดยค่าเริ่มต้น เอเจนต์จะมีสิทธิ์เข้าถึง code_execution, google_search และ url_context ระบบจะเปิดใช้เครื่องมือระบบไฟล์โดยอัตโนมัติเมื่อคุณระบุพารามิเตอร์ environment นอกจากนี้ คุณยังกำหนดฟังก์ชันที่กำหนดเองเพื่อเชื่อมต่อเอเจนต์กับ API และเครื่องมือของคุณเองได้ด้วย คุณต้องระบุพารามิเตอร์ tools ก็ต่อเมื่อปรับแต่งหรือจำกัดชุดเริ่มต้น หรือเมื่อเพิ่มฟังก์ชันที่กำหนดเอง

เครื่องมือ ประเภทค่า คำอธิบาย
การเรียกใช้โค้ด code_execution เรียกใช้คำสั่งเชลล์ (Bash, Python, Node) พร้อมการจับภาพ stdout/stderr
Google Search google_search ค้นหาเว็บสาธารณะ
บริบท URL url_context ดึงข้อมูลและอ่านหน้าเว็บ
ระบบไฟล์ (เปิดใช้ผ่าน environment) อ่าน เขียน แก้ไข ค้นหา และแสดงรายการไฟล์ในแซนด์บ็อกซ์ ไม่มีประเภทเครื่องมือแยกต่างหาก ระบบจะเปิดใช้โดยอัตโนมัติเมื่อตั้งค่า environment
ฟังก์ชันที่กำหนดเอง function กำหนดฟังก์ชันที่กำหนดเองซึ่ง Agent สามารถขอให้ดำเนินการได้ ดูการเรียกใช้ฟังก์ชัน

หากต้องการจำกัดเอเจนต์ให้ใช้เฉพาะเครื่องมือบางอย่าง ให้ส่งเฉพาะเครื่องมือที่คุณต้องการ

Python

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    agent="antigravity-preview-05-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-05-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);

REST

curl -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-05-2026",
    "input": "Search for the latest AI research papers on reasoning and summarize them.",
    "environment": "remote",
    "tools": [
        {"type": "google_search"},
        {"type": "url_context"}
    ]
}'

อินพุตหลายรูปแบบ

เอเจนต์ Antigravity รองรับอินพุตแบบหลายรูปแบบ ปัจจุบันรองรับเฉพาะอินพุต text และ image ต้องระบุรูปภาพเป็นสตริงที่เข้ารหัส Base64 ในบรรทัด (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-05-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-05-2026",
    input: [
        { type: "text", text: "Analyze this chart and summarize the trends." },
        {
            type: "image",
            data: base64Image,
            mime_type: "image/png",
        },
    ],
    environment: "remote",
}, { timeout: 300000 });

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" \
-H "Api-Revision: 2026-05-20" \
-d "{
    \"agent\": \"antigravity-preview-05-2026\",
    \"input\": [
        {\"type\": \"text\", \"text\": \"Analyze this chart and summarize the trends.\"},
        {
            \"type\": \"image\",
            \"mime_type\": \"image/png\",
            \"data\": \"$BASE64_IMAGE\"
        }
    ],
    \"environment\": \"remote\"
}"

การเรียกใช้ฟังก์ชัน

การเรียกใช้ฟังก์ชันช่วยให้คุณเชื่อมต่อ Agent ของ Antigravity กับ API และฐานข้อมูลภายนอกได้โดยการกำหนดเครื่องมือที่กำหนดเองซึ่งเอเจนต์สามารถเรียกใช้ได้ ดูแนวคิดทั่วไปได้ที่การเรียกฟังก์ชันด้วย Gemini API

ตัวอย่างต่อไปนี้แสดงการโต้ตอบ 2 รอบ ก่อนอื่นเอเจนต์จะขอการเรียกใช้ฟังก์ชัน get_weather ที่กำหนดเอง จากนั้นไคลเอ็นต์จะเรียกใช้ฟังก์ชันดังกล่าวและแสดงผลลัพธ์ในเทิร์นที่ 2

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-05-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_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-05-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-05-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_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-05-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}`);
}

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" \
  -H "Api-Revision: 2026-05-20" \
  -d '{
      "agent": "antigravity-preview-05-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" \
  -H "Api-Revision: 2026-05-20" \
  -d "{
      \"agent\": \"antigravity-preview-05-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\"
              }
          }
      ]
  }"

การปรับแต่ง Agent

คุณขยายความสามารถของเอเจนต์ Antigravity ได้โดยการปรับแต่งคำสั่ง เครื่องมือ และสภาพแวดล้อม เอเจนต์รองรับแนวทางการปรับแต่งที่ใช้ระบบไฟล์ดั้งเดิม โดยคุณสามารถติดตั้งไฟล์ เช่น AGENTS.md สำหรับวิธีการและทักษะภายใต้ .agents/skills/ ลงในแซนด์บ็อกซ์ได้โดยตรง หรือส่งการกำหนดค่าแบบอินไลน์ในเวลาที่โต้ตอบ คุณสามารถวนซ้ำการกำหนดค่าแบบอินไลน์ แล้วบันทึกเป็นเอเจนต์ที่มีการจัดการเมื่อพร้อม

โปรดดูรายละเอียดทั้งหมดเกี่ยวกับวิธีสร้างเอเจนต์ที่กำหนดเองที่หัวข้อการสร้างเอเจนต์ที่มีการจัดการ

สภาพแวดล้อม

การเรียกใช้แต่ละครั้งจะสร้างหรือนำแซนด์บ็อกซ์ Linux กลับมาใช้ใหม่ พารามิเตอร์ environment มี 3 รูปแบบ ได้แก่

แบบฟอร์ม คำอธิบาย
"remote" จัดสรรแซนด์บ็อกซ์ใหม่ด้วยการตั้งค่าเริ่มต้น
"env_abc123" นำสภาพแวดล้อมที่มีอยู่กลับมาใช้ใหม่โดยใช้รหัสเพื่อเก็บรักษาไฟล์และสถานะทั้งหมด
{...} EnvironmentConfigแบบเต็มพร้อมแหล่งที่มาและกฎเครือข่ายที่กำหนดเอง

ดูรายละเอียดเกี่ยวกับแหล่งที่มา (Git, GCS, อินไลน์), เครือข่าย, วงจร และขีดจำกัดของทรัพยากรได้ที่สภาพแวดล้อม

ความพร้อมให้บริการและการกำหนดราคา

Agent ของ Antigravity พร้อมให้บริการในเวอร์ชันตัวอย่างผ่าน Interactions API ใน Google AI Studio และ Gemini API

ราคาเป็นไปตามรูปแบบการจ่ายเมื่อใช้โดยอิงตามโทเค็นของโมเดล Gemini พื้นฐานและเครื่องมือที่เอเจนต์ใช้ การโต้ตอบ Antigravity เป็นเวิร์กโฟลว์แบบ Agentic ซึ่งต่างจากคำขอแชทมาตรฐานที่สร้างเอาต์พุตเดียว คำขอเดียวจะทริกเกอร์ลูปการให้เหตุผล การดำเนินการเครื่องมือ การเรียกใช้โค้ด และการจัดการไฟล์โดยอัตโนมัติ

ค่าใช้จ่ายโดยประมาณ

ค่าใช้จ่ายจะแตกต่างกันไปตามความซับซ้อนของงาน Agent จะพิจารณาโดยอัตโนมัติว่าต้องมีการเรียกใช้เครื่องมือ การดำเนินการโค้ด และการดำเนินการกับไฟล์กี่ครั้ง ค่าประมาณต่อไปนี้อิงตามการวิ่ง

หมวดหมู่งาน โทเค็นอินพุต โทเค็นเอาต์พุต ค่าใช้จ่ายโดยทั่วไป
การวิจัยและการสังเคราะห์ข้อมูล 100,000-500,000 10,000-40,000 $0.30–$1.00
การสร้างเอกสารและเนื้อหา 100,000-500,000 15,000-50,000 $0.30–$1.30
การออกแบบกระบวนการและระบบ 100,000-400,000 10,000-30,000 $0.25–$0.80
การประมวลผลและการวิเคราะห์ข้อมูล 300,000–3,000,000 30,000-150,000 $0.70–$3.25

โดยปกติแล้ว ระบบจะแคชโทเค็นอินพุต 50-70% เวิร์กโฟลว์ของเอเจนต์ที่ซับซ้อนซึ่งมีการเรียกใช้เครื่องมือหลายครั้งอาจสะสมโทเค็นได้ 3-5 ล้านโทเค็นในการโต้ตอบครั้งเดียว โดยมีค่าใช้จ่ายสูงสุดประมาณ$5

การประมวลผลสภาพแวดล้อม (CPU, หน่วยความจำ, การดำเนินการในแซนด์บ็อกซ์) จะไม่ได้รับการเรียกเก็บเงินในช่วงระยะเวลาแสดงตัวอย่าง

ข้อจำกัด

  • สถานะเวอร์ชันตัวอย่าง: Agent ของ Antigravity และ Interactions API อยู่ในเวอร์ชันตัวอย่าง ฟีเจอร์และสคีมาอาจมีการเปลี่ยนแปลง
  • การกำหนดค่าการสร้างที่ไม่รองรับ: ระบบไม่รองรับพารามิเตอร์ต่อไปนี้และจะแสดงข้อผิดพลาด 400: temperature, top_p, top_k, stop_sequences, max_output_tokens
  • เอาต์พุตที่มีโครงสร้าง: Agent ของ Antigravity ไม่รองรับเอาต์พุตที่มีโครงสร้าง
  • เครื่องมือที่ไม่พร้อมใช้งาน: ระบบยังไม่รองรับ file_search, computer_use, google_maps และ mcp
  • เครื่องมือระบบไฟล์: ขณะนี้ยังไม่มีเครื่องมือระบบไฟล์ ซึ่งเป็นส่วนหนึ่งของ environment
  • เบื้องหลัง: Agent ไม่รองรับการใช้ background=True และต้องใช้ store=True
  • การเรียกใช้ฟังก์ชันแบบมีสถานะเท่านั้น: รองรับการเรียกใช้ฟังก์ชันในโหมดมีสถานะเท่านั้น คุณต้องใช้ previous_interaction_id เพื่อดำเนินการต่อ และระบบไม่รองรับการสร้างประวัติขึ้นใหม่ด้วยตนเอง (โหมดไม่เก็บสถานะ)
  • ประเภทมัลติโมดัลที่ไม่รองรับ ขณะนี้ระบบยังไม่รองรับอินพุตเสียง วิดีโอ และเอกสาร อนุญาตให้ใช้ได้เฉพาะข้อความและรูปภาพ

ขั้นตอนถัดไป