Antigravity エージェントは、Gemini API の汎用マネージド エージェントです。1 回の API 呼び出しで、Google がホストする独自の安全な Linux サンドボックス内で、推論、コードの実行、ファイルの管理、ウェブの閲覧を行うエージェントを取得できます。
Gemini 3.5 Flash を搭載し、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" \
-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 検索とデータ用の URL の取得。
- コンテキストの圧縮: コンテキストを失ったり、トークン上限に達したりすることなく、長時間実行されるマルチターンのセッションをサポートするための自動コンテキスト圧縮(約 135, 000 トークンでトリガーされます)。
マルチターンの使用とストリーミングについては、クイックスタートをご覧ください。
サポートされているツール
デフォルトでは、エージェントは code_execution、google_search、url_context にアクセスできます。environment パラメータを指定すると、ファイルシステム ツールが自動的に有効になります。カスタム関数を定義して、エージェントを独自の API やツールに接続することもできます。tools パラメータは、デフォルト セットをカスタマイズまたは制限する場合、またはカスタム関数を追加する場合にのみ指定する必要があります。
| ツール | Type 値 | 説明 |
|---|---|---|
| コードを実行する | code_execution |
stdout/stderr キャプチャを使用してシェル コマンド(bash、Python、Node)を実行します。 |
| Google 検索 | google_search |
公開ウェブを検索する。 |
| URL コンテキスト | url_context |
ウェブページを取得して読み取ります。 |
| ファイルシステム | (environment で有効) |
サンドボックス内のファイルの読み取り、書き込み、編集、検索、一覧表示。個別のツールタイプはありません。environment が設定されている場合は自動的に有効になります。 |
| カスタム関数 | function |
エージェントが実行をリクエストできるカスタム関数を定義します。関数呼び出しをご覧ください。 |
| リモート MCP サーバー | mcp_server |
外部の Model Context Protocol(MCP)サーバーをツールとして登録します。MCP サーバーをご覧ください。 |
エージェントを特定のツールに制限するには、必要なツールのみを渡します。
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" \
-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" \
-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\"
}"
関数呼び出し
関数呼び出しを使用すると、エージェントが呼び出すことができるカスタムツールを定義して、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" \
-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" \
-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\"
}
}
]
}"
MCP サーバー
リモート Model Context Protocol(MCP)サーバーを登録することで、Antigravity エージェントを外部ツールに接続できます。エージェントは、ストリーミング可能な HTTP 経由のリモート MCP サーバーをサポートしています。
MCP サーバーを登録するときは、tools 配列で次のフィールドを指定する必要があります。
| フィールド | 型 | 必須 / 省略可 | 説明 |
|---|---|---|---|
type |
文字列 | ○ | "mcp_server" を指定します。 |
name |
文字列 | ○ | サーバーの固有識別子。小文字の英数字(^[a-z0-9_-]+$ と一致)にする必要があります。 |
url |
文字列 | ○ | リモート MCP サーバーのエンドポイント URL。 |
headers |
オブジェクト | いいえ | リクエストとともに送信されるカスタム ヘッダー(認証など)。 |
allowed_tools |
配列 | いいえ | 実行を許可するツール名のリスト。省略すると、すべてのツールが許可されます。 |
Python
from google import genai
client = genai.Client()
# Register a remote HTTP MCP server
interaction = client.interactions.create(
agent="antigravity-preview-05-2026",
input="What is the weather in Tokyo?",
environment="remote",
tools=[{
"type": "mcp_server",
"name": "weather", # Must be lowercase
"url": "https://gemini-api-demos.uc.r.appspot.com/mcp"
}]
)
print(interaction.output_text)
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "What is the weather in Tokyo?",
environment: "remote",
tools: [{
type: "mcp_server",
name: "weather", // Must be lowercase
url: "https://gemini-api-demos.uc.r.appspot.com/mcp"
}]
}, { timeout: 300000 });
console.log(interaction.output_text);
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "antigravity-preview-05-2026",
"input": "What is the weather in Tokyo?",
"environment": "remote",
"tools": [{
"type": "mcp_server",
"name": "weather",
"url": "https://gemini-api-demos.uc.r.appspot.com/mcp"
}]
}'
エージェントをカスタマイズする
Antigravity エージェントは、指示、ツール、環境をカスタマイズすることで拡張できます。エージェントは、ファイル システム ネイティブなカスタマイズ方法をサポートしています。手順やスキルなどのファイルを AGENTS.md から .agents/skills/ に直接マウントしてサンドボックスに組み込んだり、やり取り時に構成をインラインで渡したりできます。構成をインラインで反復処理し、準備ができたらマネージド エージェントとして保存できます。
カスタム エージェントの構築方法の詳細については、Managed Agents の構築をご覧ください。
バックグラウンド実行
複数ステップの推論、コード実行、ファイル オペレーションを伴うエージェント タスクは、完了までに数分かかることがあります。background=True を使用して、インタラクションを非同期で実行します。API はすぐに戻り、ステータスが completed または failed になるまでポーリングするインタラクション ID を返します。
Python
import time
from google import genai
client = genai.Client()
# 1. Start the interaction in the background
interaction = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Run a complex analysis on the repository.",
environment="remote",
background=True,
)
print(f"Interaction started in background: {interaction.id}")
# 2. Poll for completion
while interaction.status == "in_progress":
time.sleep(5)
interaction = client.interactions.get(id=interaction.id)
if interaction.status == "completed":
print(interaction.output_text)
else:
print(f"Finished with status: {interaction.status}")
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Run a complex analysis on the repository.",
environment: "remote",
background: true,
});
console.log(`Interaction started in background: ${interaction.id}`);
let result = interaction;
while (result.status === "in_progress") {
await new Promise(resolve => setTimeout(resolve, 5000));
result = await client.interactions.get(interaction.id);
}
if (result.status === "completed") {
console.log(result.output_text);
} else {
console.log(`Finished with status: ${result.status}`);
}
REST
# 1. Start the interaction in the background
RESPONSE=$(curl -s -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Api-Revision: 2026-05-20" \
-d '{
"agent": "antigravity-preview-05-2026",
"input": "Run a complex analysis on the repository.",
"environment": "remote",
"background": true
}')
INTERACTION_ID=$(echo $RESPONSE | jq -r '.id')
# 2. Poll for results (repeat until status is "completed")
curl -s -X GET "https://generativelanguage.googleapis.com/v1beta/interactions/$INTERACTION_ID" \
-H "x-goog-api-key: $GEMINI_API_KEY"
バックグラウンド実行には store=True が必要です。これはデフォルトです。バックグラウンド実行中の進行状況のリアルタイム更新については、バックグラウンド操作のストリーミングをご覧ください。
実行中のバックグラウンド インタラクションは、cancel メソッドを使用してキャンセルできます。
Python
client.interactions.cancel(id="INTERACTION_ID")
JavaScript
await client.interactions.cancel("INTERACTION_ID");
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions/INTERACTION_ID:cancel" \
-H "x-goog-api-key: $GEMINI_API_KEY"
バックグラウンドでのインタラクションにステートフル ツール(サンドボックスでのコード実行など)が含まれる場合は、完了したインタラクションの environment_id を使用して、同じ環境で続行します。これにより、エージェントはすべてのファイルと状態をそのままにして、中断したところから再開できます。
Python
import time
from google import genai
client = genai.Client()
# First turn: run a task in the background
interaction = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Clone https://github.com/google/generative-ai-python and run its tests.",
environment="remote",
background=True,
)
while interaction.status == "in_progress":
time.sleep(5)
interaction = client.interactions.get(id=interaction.id)
# Second turn: continue in the same environment
followup = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Fix any failing tests and re-run them.",
previous_interaction_id=interaction.id,
environment=interaction.environment_id,
background=True,
)
while followup.status == "in_progress":
time.sleep(5)
followup = client.interactions.get(id=followup.id)
print(followup.output_text)
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
// First turn: run a task in the background
let interaction = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Clone https://github.com/google/generative-ai-python and run its tests.",
environment: "remote",
background: true,
});
while (interaction.status === "in_progress") {
await new Promise(resolve => setTimeout(resolve, 5000));
interaction = await client.interactions.get(interaction.id);
}
// Second turn: continue in the same environment
let followup = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Fix any failing tests and re-run them.",
previous_interaction_id: interaction.id,
environment: interaction.environment_id,
background: true,
});
while (followup.status === "in_progress") {
await new Promise(resolve => setTimeout(resolve, 5000));
followup = await client.interactions.get(followup.id);
}
console.log(followup.output_text);
REST
# 1. Start first interaction in the background
RESPONSE=$(curl -s -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Api-Revision: 2026-05-20" \
-d '{
"agent": "antigravity-preview-05-2026",
"input": "Clone https://github.com/google/generative-ai-python and run its tests.",
"environment": "remote",
"background": true
}')
INTERACTION_ID=$(echo $RESPONSE | jq -r '.id')
# 2. Poll until completed (repeat until status is "completed")
RESULT=$(curl -s -X GET "https://generativelanguage.googleapis.com/v1beta/interactions/$INTERACTION_ID" \
-H "x-goog-api-key: $GEMINI_API_KEY")
ENVIRONMENT_ID=$(echo $RESULT | jq -r '.environment_id')
# 3. Continue in the same environment
curl -s -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Api-Revision: 2026-05-20" \
-d "{
\"agent\": \"antigravity-preview-05-2026\",
\"input\": \"Fix any failing tests and re-run them.\",
\"previous_interaction_id\": \"$INTERACTION_ID\",
\"environment\": \"$ENVIRONMENT_ID\",
\"background\": true
}"
環境
呼び出しごとに Linux サンドボックスが作成または再利用されます。environment パラメータには次の 3 つの形式があります。
| フォーム | 説明 |
|---|---|
"remote" |
デフォルト設定で新しいサンドボックスをプロビジョニングします。 |
"env_abc123" |
ID で既存の環境を再利用し、すべてのファイルと状態を保持します。 |
{...} |
カスタムソースとネットワーク ルールを使用した完全な EnvironmentConfig。 |
ソース(Git、GCS、インライン)、ネットワーキング、ライフサイクル、リソースの上限については、環境をご覧ください。
トリガー
トリガーを使用すると、cron スケジュールでエージェントが自動的に実行されるようにスケジュールを設定できます。トリガーは、エージェント、環境、プロンプト、スケジュールを、手動で介入しなくても起動する永続リソースにバインドします。各実行で同じ環境が再利用されるため、1 回の実行で作成されたファイルは保持され、次の実行で表示されます。
トリガーを作成する
cron スケジュール、タイムゾーン、インタラクション構成を指定して、トリガーを作成します。トリガーは active ステータスで開始され、次に一致する cron 時間に起動します。返された id を保存して、後続の呼び出しでトリガーを管理します。
Python
from google import genai
client = genai.Client()
trigger = client.triggers.create(
schedule="0 9 * * *",
time_zone="America/Argentina/Buenos_Aires",
display_name="issue-solver",
interaction={
"agent": "antigravity-preview-05-2026",
"input": "Review open PRs in my-org/my-app for new comments and address feedback. Close issues whose PRs were merged. Then check for new issues labeled 'accepted', skip any already tracked in /workspace/solved-issues/, fix the rest, and open a PR for each. Save reports to /workspace/solved-issues/.",
"environment": {
"type": "remote",
"network": {
"allowlist": [
{
"domain": "api.github.com",
"transform": {
"Authorization": "Bearer ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
},
},
{"domain": "github.com"},
]
},
},
},
)
print(f"Trigger created: {trigger.id}")
print(f"Next run: {trigger.next_run_time}")
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const trigger = await client.triggers.create({
schedule: "0 9 * * *",
time_zone: "America/Argentina/Buenos_Aires",
display_name: "issue-solver",
interaction: {
agent: "antigravity-preview-05-2026",
input: [{
type: "text",
text: "Review open PRs in my-org/my-app for new comments and address feedback. Close issues whose PRs were merged. Then check for new issues labeled 'accepted', skip any already tracked in /workspace/solved-issues/, fix the rest, and open a PR for each. Save reports to /workspace/solved-issues/.",
}],
environment: {
type: "remote",
network: {
allowlist: [
{
domain: "api.github.com",
transform: {
"Authorization": "Bearer ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
},
},
{ domain: "github.com" },
],
},
},
},
});
console.log(`Trigger created: ${trigger.id}`);
console.log(`Next run: ${trigger.next_run_time}`);
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/triggers" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"schedule": "0 9 * * *",
"time_zone": "America/Argentina/Buenos_Aires",
"display_name": "issue-solver",
"interaction": {
"agent": "antigravity-preview-05-2026",
"input": [{"type": "text", "text": "Review open PRs in my-org/my-app for new comments and address feedback. Close issues whose PRs were merged. Then check for new issues labeled accepted, skip any already tracked in /workspace/solved-issues/, fix the rest, and open a PR for each. Save reports to /workspace/solved-issues/."}],
"environment": {
"type": "remote",
"network": {
"allowlist": [
{
"domain": "api.github.com",
"transform": {
"Authorization": "Bearer ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
},
{"domain": "github.com"}
]
}
}
}
}'
CreateTrigger リクエストは次のフィールドを受け入れます。
| フィールド | 型 | 必須 / 省略可 | 説明 |
|---|---|---|---|
schedule |
文字列 | ○ | cron 式(例: 0 * * * * は毎時、0 9 * * 1-5 は平日の午前)。 |
time_zone |
文字列 | ○ | IANA タイムゾーン(UTC、America/Argentina/Buenos_Aires など)。 |
display_name |
文字列 | いいえ | 人が読める形式のトリガー名。 |
max_consecutive_failures |
integer | いいえ | トリガーが自動的に一時停止するまでの最大失敗数。デフォルト: 5。 |
execution_timeout_seconds |
integer | いいえ | 実行あたりのタイムアウト(秒単位)。デフォルト: 600。 |
interaction |
オブジェクト | ○ | エージェント、入力、ツール、環境を定義する CreateInteractionRequest。 |
レスポンスには次のキーフィールドが含まれます。
| フィールド | タイプ | 説明 |
|---|---|---|
id |
文字列 | トリガーの一意の識別子。以降のすべてのオペレーションで使用します。 |
status |
文字列 | 現在の状態: active、paused、disabled。 |
next_run_time |
文字列 | 次にスケジュールされている実行の ISO 8601 タイムスタンプ。 |
consecutive_failure_count |
integer | 最後に成功してから連続して失敗した実行の数。 |
トリガーの一覧表示
プロジェクトに関連付けられているすべてのトリガーを取得します。
Python
triggers = client.triggers.list()
for trigger in triggers.triggers:
print(f"{trigger.id}: {trigger.display_name} ({trigger.status})")
JavaScript
const triggers = await client.triggers.list();
for (const trigger of triggers.triggers) {
console.log(`${trigger.id}: ${trigger.display_name} (${trigger.status})`);
}
REST
curl -X GET "https://generativelanguage.googleapis.com/v1beta/triggers" \
-H "x-goog-api-key: $GEMINI_API_KEY"
トリガーを取得する
単一のトリガーの完全な構成と現在の状態を取得します。
Python
trigger = client.triggers.get(id="TRIGGER_ID")
print(f"Schedule: {trigger.schedule}")
print(f"Next run: {trigger.next_run_time}")
JavaScript
const trigger = await client.triggers.get("TRIGGER_ID");
console.log(`Schedule: ${trigger.schedule}`);
console.log(`Next run: ${trigger.next_run_time}`);
REST
curl -X GET "https://generativelanguage.googleapis.com/v1beta/triggers/TRIGGER_ID" \
-H "x-goog-api-key: $GEMINI_API_KEY"
一時停止と再開
トリガーを一時停止してスケジュールされた実行を停止し、トリガーを再開してスケジュールを再び有効にできます。一時停止は手動実行には影響しません。
Python
# Pause
client.triggers.update(id="TRIGGER_ID", status="paused")
# Resume
client.triggers.update(id="TRIGGER_ID", status="active")
JavaScript
// Pause
await client.triggers.update("TRIGGER_ID", { status: "paused" });
// Resume
await client.triggers.update("TRIGGER_ID", { status: "active" });
REST
# Pause
curl -X PATCH "https://generativelanguage.googleapis.com/v1beta/triggers/TRIGGER_ID" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{"status": "paused"}'
# Resume
curl -X PATCH "https://generativelanguage.googleapis.com/v1beta/triggers/TRIGGER_ID" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{"status": "active"}'
トリガーの削除
トリガーを完全に削除します。過去の実行履歴は削除されません。
Python
client.triggers.delete(id="TRIGGER_ID")
JavaScript
await client.triggers.delete("TRIGGER_ID");
REST
curl -X DELETE "https://generativelanguage.googleapis.com/v1beta/triggers/TRIGGER_ID" \
-H "x-goog-api-key: $GEMINI_API_KEY"
トリガーをすぐに実行する
次のスケジュールされた時刻を待たずに、オンデマンドでトリガーを起動します。これは、トリガーが一時停止されている場合でも機能します。
Python
client.triggers.run(trigger_id="TRIGGER_ID")
JavaScript
await client.triggers.run("TRIGGER_ID");
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/triggers/TRIGGER_ID/executions" \
-H "x-goog-api-key: $GEMINI_API_KEY"
実行の一覧表示
トリガーの実行履歴を表示します。各実行には、status、タイムスタンプ、完全なインタラクション出力を取得するために使用できる interaction_id、すべての実行が同じサンドボックスを共有していることを確認する environment_id が含まれます。
Python
executions = client.triggers.list_executions(trigger_id="TRIGGER_ID")
for ex in executions.trigger_executions:
print(f"{ex.id}: {ex.status} ({ex.start_time} - {ex.end_time})")
# Fetch the full interaction for an execution
interaction = client.interactions.get(id=ex.interaction_id)
print(interaction.output_text)
JavaScript
const executions = await client.triggers.listExecutions("TRIGGER_ID");
for (const ex of executions.trigger_executions) {
console.log(`${ex.id}: ${ex.status} (${ex.start_time} - ${ex.end_time})`);
}
// Fetch the full interaction for an execution
const interaction = await client.interactions.get(ex.interaction_id);
console.log(interaction.output_text);
REST
curl -X GET "https://generativelanguage.googleapis.com/v1beta/triggers/TRIGGER_ID/executions" \
-H "x-goog-api-key: $GEMINI_API_KEY"
提供状況と価格
Antigravity エージェントは、Google AI Studio の Interactions API と Gemini API を通じて、無料枠と有料枠の両方のプロジェクトでプレビュー版として利用できます。
料金は、基盤となる Gemini モデルのトークンとエージェントが使用するツールに基づく従量課金制モデルに従います。単一の出力を生成する標準的なチャット リクエストとは異なり、Antigravity インタラクションはエージェント ワークフローです。1 つのリクエストで、推論、ツール実行、コード実行、ファイル管理の自律ループがトリガーされます。無料枠プロジェクトには、無料のレート上限と使用量割り当てが含まれています。
Antigravity インタラクションは、マルチターンの自律ループを実行し、大量のトークンを消費する可能性があります。リクエストに予算管理を設定して、トークンの使用量を制限します。SSE ストリーミングで進行状況をリアルタイムでモニタリングしたり、実行中のリクエストをキャンセルしたりすることもできます。
予算管理
agent_config("type": "antigravity" を含む)内で max_total_tokens を設定して、インタラクションが消費できるトークン(入力 + 出力 + 思考)の合計数を制限します。キャッシュに保存されたトークンは、この上限にカウントされません。エージェントが上限に達すると、インタラクションが停止し、status: "incomplete" で戻ります。この上限はベスト エフォートです。エージェントがステップ間の予算をチェックするタイミングによっては、実際の使用量が上限をわずかに超えることがあります。
agent_config のインタラクション リクエストで、agent と input とともに予算を設定します。
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Analyze the dataset in /workspace/data.csv and generate a summary report.",
agent_config={
"type": "antigravity",
"max_total_tokens": 50000
},
environment={
"type": "remote",
"sources": [
{
"type": "inline",
"target": "/workspace/data.csv",
"content": "id,name,value\n1,alpha,100\n2,beta,200\n",
}
],
}
)
print(f"Status: {interaction.status}") # "incomplete" if budget was hit
print(f"Tokens used: {interaction.usage.total_tokens}")
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Analyze the dataset in /workspace/data.csv and generate a summary report.",
agent_config: {
type: "antigravity",
max_total_tokens: 50000
},
environment: {
type: "remote",
sources: [
{
type: "inline",
target: "/workspace/data.csv",
content: "id,name,value\n1,alpha,100\n2,beta,200\n",
},
],
},
});
console.log(`Status: ${interaction.status}`);
console.log(`Tokens used: ${interaction.usage.total_tokens}`);
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "antigravity-preview-05-2026",
"input": "Analyze the dataset in /workspace/data.csv and generate a summary report.",
"agent_config": {
"type": "antigravity",
"max_total_tokens": 50000
},
"environment": {
"type": "remote",
"sources": [
{
"type": "inline",
"target": "/workspace/data.csv",
"content": "id,name,value\n1,alpha,100\n2,beta,200\n"
}
]
}
}'
未完了のやり取りを継続する
インタラクションが status: "incomplete" を返すと、エージェントの作業とコンテキストが保持されます。元のインタラクション id と environment_id を参照する新しいインタラクションを送信して、中断したところから再開します。新しいインタラクションには独自の max_total_tokens 予算が割り当てられます。
Python
# Continue from where the agent stopped
continuation = client.interactions.create(
agent="antigravity-preview-05-2026",
input="continue",
previous_interaction_id=interaction.id,
environment=interaction.environment_id,
agent_config={
"type": "antigravity",
"max_total_tokens": 50000
}
)
print(f"Status: {continuation.status}")
JavaScript
const continuation = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "continue",
previous_interaction_id: interaction.id,
environment: interaction.environment_id,
agent_config: {
type: "antigravity",
max_total_tokens: 50000
}
});
console.log(`Status: ${continuation.status}`);
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "antigravity-preview-05-2026",
"input": "continue",
"previous_interaction_id": "INTERACTION_ID",
"environment": "ENVIRONMENT_ID",
"agent_config": {
"type": "antigravity",
"max_total_tokens": 50000
}
}'
推定費用
費用はタスクの複雑さによって異なります。エージェントは、必要なツール呼び出し、コード実行、ファイル オペレーションの数を自律的に決定します。以下の推定値はランニングに基づいています。
| タスクのカテゴリ | 入力トークン | 出力トークン | 一般的な費用 |
|---|---|---|---|
| 調査と情報の統合 | 10 万~ 50 万 | 10,000 ~ 40,000 | $0.30 ~$1.00 |
| ドキュメントとコンテンツの生成 | 10 万~ 50 万 | 15,000 ~ 50,000 | $0.30 ~$1.30 |
| プロセスとシステムの設計 | 10 万~ 40 万 | 10,000 ~ 30,000 | $0.25 ~$0.80 |
| データ処理と分析 | 30 万~ 300 万回 | 30,000 ~ 150,000 | $0.70 ~$3.25 |
通常、入力トークンの 50 ~ 70% がキャッシュに保存されます。多くのツール呼び出しを含む複雑なエージェント ワークフローでは、1 回のインタラクションで 300 万~ 500 万個のトークンが蓄積され、費用は最大約 5 ドルになります。
プレビュー期間中は、環境コンピューティング(CPU、メモリ、サンドボックス実行)は課金されません。
制限事項
- プレビュー ステータス: Antigravity エージェントと Interactions API。機能とスキーマは変更される可能性があります。
- サポートされていない生成構成: 次のパラメータはサポートされておらず、400 エラーが返されます。
temperature、top_p、top_k、stop_sequences、max_output_tokens。 - 構造化された出力: Antigravity エージェントは構造化された出力をサポートしていません。
- 利用できないツール:
file_search、computer_use、google_mapsはまだサポートされていません。 - リモート MCP の制限事項: サーバー送信イベント(SSE)トランスポートは対象外です(ストリーミング可能な HTTP を使用してください)。また、サーバー
nameは厳密に小文字の英数字である必要があります(大文字を使用すると、一般的な400 Bad Requestエラーがトリガーされます)。 - ファイル システム ツール: 現在、ファイル システム ツールはありません。これは
environmentの一部です。 - ストアの要件:
background=Trueを使用したエージェントの実行にはstore=Trueが必要です。 - ステートフルのみの関数呼び出し: 関数呼び出しはステートフル モードでのみサポートされています。ターンを継続するには
previous_interaction_idを使用する必要があります。履歴を手動で再構築する(ステートレス モード)ことはサポートされていません。 - サポートされていないマルチモーダル タイプ。現時点では、音声、動画、ドキュメントの入力はサポートされていません。テキストと画像のみが許可されます。
次のステップ
- クイックスタート: マルチターン会話とストリーミング。
- カスタム エージェントの構築: カスタム手順、スキル、エージェントの保存。
- 環境: サンドボックス構成、ソース、ネットワーキング。
- Deep Research エージェント: 長文の調査タスク。
- Interactions API: 基盤となる API。