Antigravity Agent

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

Agent นี้ขับเคลื่อนโดย Gemini 3.5 Flash และใช้ Harness เดียวกับ Antigravity IDE คุณสามารถใช้ Agent นี้ผ่าน 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 และเริ่มลูปการใช้เครื่องมือ Agent จะวางแผน ดำเนินการ สังเกตผลลัพธ์ และทำซ้ำจนกว่างานจะเสร็จสมบูรณ์

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

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

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

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

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

หากต้องการจำกัด 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 Agent รองรับอินพุตหลายรูปแบบ ปัจจุบันระบบรองรับเฉพาะอินพุต text และ image คุณต้องระบุรูปภาพเป็นสตริงที่มีการเข้ารหัสฐาน 64 แบบอินไลน์ (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 ด้วย system_instruction สำหรับพรอมต์แบบอินไลน์ หรือโดยการติดตั้งไฟล์คำแนะนำลงในสภาพแวดล้อม

Python

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    agent="antigravity-preview-05-2026",
    input="Analyze the uploaded CSV and create a report.",
    environment="remote",
    system_instruction="You are a data analyst. Always include visualizations and export results as PDF.",
)

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: "Analyze the uploaded CSV and create a report.",
    environment: "remote",
    system_instruction: "You are a data analyst. Always include visualizations and export results as PDF.",
}, { 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": "Analyze the uploaded CSV and create a report.",
    "environment": "remote",
    "system_instruction": "You are a data analyst. Always include visualizations and export results as PDF."
}'

Agent จะโหลดไฟล์คำแนะนำจากสภาพแวดล้อมโดยอัตโนมัติ

  • AGENTS.md: เพิ่มเป็นคำแนะนำระบบเมื่อพบใน .agents/ หรือรูทของพื้นที่ทำงาน
  • SKILL.md: โหลดจาก .agents/skills/ และลงทะเบียนเป็นความสามารถที่ Agent สามารถเรียกใช้ได้

เช่น

Python

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    agent="antigravity-preview-05-2026",
    input="Analyze the Q1 revenue data and create a slide deck.",
    environment={
        "type": "remote",
        "sources": [
            {
                "type": "inline",
                "target": ".agents/AGENTS.md",
                "content": "You are a data analyst. Always use matplotlib for charts.",
            },
            {
                "type": "inline",
                "target": ".agents/skills/slide-maker/SKILL.md",
                "content": "---\nname: slide-maker\n---\n# Slide Maker\nCreate HTML slide decks...",
            },
        ],
    },
)

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: "Analyze the Q1 revenue data and create a slide deck.",
    environment: {
        type: "remote",
        sources: [
            {
                type: "inline",
                target: ".agents/AGENTS.md",
                content: "You are a data analyst. Always use matplotlib for charts.",
            },
            {
                type: "inline",
                target: ".agents/skills/slide-maker/SKILL.md",
                content: "---\nname: slide-maker\n---\n# Slide Maker\nCreate HTML slide decks...",
            },
        ],
    },
}, { 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: $API_KEY" \
-d '{
    "agent": "antigravity-preview-05-2026",
    "input": "Analyze the Q1 revenue data and create a slide deck.",
    "environment": {
        "type": "remote",
        "sources": [
            {
                "type": "inline",
                "target": ".agents/AGENTS.md",
                "content": "You are a data analyst. Always use matplotlib for charts."
            },
            {
                "type": "inline",
                "target": ".agents/skills/slide-maker/SKILL.md",
                "content": "---\nname: slide-maker\n---\n# Slide Maker\nCreate HTML slide decks..."
            }
        ]
    }
}'

ดูรูปแบบการกำหนด Agent แบบเต็มและ Agent ที่ตั้งชื่อไว้ซึ่งนำกลับมาใช้ซ้ำได้ที่หัวข้อการสร้าง Agent ที่กำหนดเอง

สภาพแวดล้อม

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

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

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

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

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

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

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

ค่าใช้จ่ายจะแตกต่างกันไปตามความซับซ้อนของงาน 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% เวิร์กโฟลว์ของ Agent ที่ซับซ้อนซึ่งมีการเรียกใช้เครื่องมือจำนวนมากอาจสะสมโทเค็นได้ 3–5 ล้านรายการในการโต้ตอบครั้งเดียว โดยมีค่าใช้จ่ายสูงสุดประมาณ$5

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

ข้อจำกัด

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

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