Skip to main content

Google Antigravity SDK

The Google Antigravity SDK is a Python SDK for building AI agents powered by Antigravity and Gemini. It provides a secure, scalable, and stateful infrastructure layer that abstracts the agentic loop, letting you focus on what your agent does rather than how it runs.

Installation

pip install google-antigravity

Quickstart

Get started by running one of the examples/, such as the hello_world example with:

export GEMINI_API_KEY="your_api_key_here"
python ./examples/getting_started/hello_world.py

Gemini Enterprise Agent Platform (formerly Vertex AI)

To use the SDK with Gemini Enterprise Agent Platform (formerly Vertex AI), the SDK supports two authentication modes:

1. Express Mode (API Key)

For fast setup without requiring Google Cloud projects, regional configuration, or Application Default Credentials (ADC), provide an API key with vertex=True:

from google.antigravity import Agent, LocalAgentConfig

config = LocalAgentConfig(
    vertex=True,
    api_key="your_api_key_here",
)

async with Agent(config) as agent:
    response = await agent.chat("Hello!")
    print(await response.text())

2. Standard Mode (Project & Location with ADC)

For enterprise deployments routing to regional endpoints, configure LocalAgentConfig with vertex=True, project, and location. By default, this mode authenticates via Application Default Credentials (ADC).

from google.antigravity import Agent, LocalAgentConfig

config = LocalAgentConfig(
    vertex=True,
    project="your-gcp-project",
    location="us-central1",
)

async with Agent(config) as agent:
    response = await agent.chat("Hello!")
    print(await response.text())

Alternatively, you can leave these fields unset in LocalAgentConfig and export the environment variables instead:

# Either GOOGLE_GENAI_USE_VERTEXAI or GOOGLE_GENAI_USE_ENTERPRISE enable Vertex.
export GOOGLE_GENAI_USE_VERTEXAI=True
export GOOGLE_CLOUD_PROJECT="your-gcp-project"
export GOOGLE_CLOUD_LOCATION="us-central1"

Explicit kwargs always take precedence over env vars.

Ensure you have authenticated locally before running the agent in Standard Mode:

gcloud auth application-default login

See vertex.py for a complete example.

Concepts

Simple Agent

The Agent class is the easiest way to get started. It manages the full lifecycle — binary discovery, tool wiring, hook registration, and policy defaults — behind a single async context manager.

The system_instructions parameter is optional.

import asyncio
from google.antigravity import Agent, LocalAgentConfig

async def main():
    config = LocalAgentConfig(
        system_instructions="You are an expert assistant for codebase navigation.",
        # api_key="your_api_key_here",
    )
    async with Agent(config) as agent:
        response = await agent.chat("What files are in the current directory?")
        print(await response.text())

async def run():
    await main()

if __name__ == "__main__":
    asyncio.run(run())

Streaming Responses

To stream agent output in real-time (e.g., for fluid UI or console applications), simply iterate over the ChatResponse object using an async for loop. The stream wrapper natively yields conversational str text tokens as they arrive, with zero network overhead:

import asyncio
import sys
from google.antigravity import Agent, LocalAgentConfig

async def main():
    config = LocalAgentConfig()
    async with Agent(config) as agent:
        # Returns instantly — does not block
        response = await agent.chat("Write a short poem about space.")

        async for token in response:
            sys.stdout.write(token)
            sys.stdout.flush()
        print()

asyncio.run(main())

Sugared Thoughts & Tool Call Streams (Advanced)

For more complex use cases, you can also stream internal model reasoning/thinking or intercept tool call dispatches in real-time using dedicated async stream properties:

# 1. Stream reasoning/thinking deltas
async for thought in response.thoughts:
    show_thinking_bubble(thought)

# 2. Stream strongly-typed ToolCall events
async for call in response.tool_calls:
    show_executing_spinner(call.name)

By default, an Agent enables most built-in tools but denies permission to execute shell commands (run_command) through its security policy, policy.confirm_run_command(). To change this restriction, pass a custom list to the policies=[...] parameter of the agent's configuration, for example LocalAgentConfig(policies=[...]). For details on implementing these permission scopes in a runnable script, see examples/getting_started/policies.py.

CapabilitiesConfig controls which tools the model can see, using enabled_tools and disabled_tools. It doesn't control whether the agent is allowed to call those tools. To control permissions, use policies.

Interactive Loop

from google.antigravity import LocalAgentConfig
from google.antigravity.utils.interactive import run_interactive_loop

config = LocalAgentConfig(
    # api_key="your_api_key_here",
)
await run_interactive_loop(config)

Advanced Usage with Conversation

For full control over the connection lifecycle, use Conversation with a ConnectionStrategy directly. Conversation is a stateful session that accumulates step history, provides a chat() convenience method, and exposes state introspection:

import asyncio
from google.antigravity.connections.local import LocalConnectionStrategy
from google.antigravity.conversation.conversation import Conversation
from google.antigravity.tools.tool_runner import ToolRunner

async def main():
    tool_runner = ToolRunner()
    strategy = LocalConnectionStrategy(
        tool_runner=tool_runner,
    )

    async with Conversation.create(strategy) as conversation:
        # High-level: one-call send + collect
        response = await conversation.chat("What files are here?")
        print(await response.text())

        # Step history accumulates automatically
        print(f"Total steps: {len(conversation.history)}")
        print(f"Turns: {conversation.turn_count}")
        print(f"Last response: {conversation.last_response}")

        # Low-level: streaming steps
        await conversation.send("Tell me more.")
        async for step in conversation.receive_steps():
            if step.is_complete_response:
                print(step.content)

asyncio.run(main())

Features

Multimodal Ingestion

Pass rich multimedia file attachments (images, videos, audio, and documents) to the agent alongside textual instruction prompt lists.

You can attach assets directly using content classes (perfect for in-memory bytes) or conveniently from a filesystem path (which automatically resolves types and guesses MIME formats):

from google.antigravity import Agent, LocalAgentConfig
from google.antigravity.types import Image, from_file

config = LocalAgentConfig(system_instructions="You are an expert software architect.")
async with Agent(config) as agent:
    # 1. Flat filesystem shortcut (automatically resolves as types.Document)
    pdf_spec = from_file("spec.pdf")

    # 2. Direct constructor instantiation (perfect for in-memory raw bytes)
    chart_image = Image(
        data=b"raw_png_bytes_here",
        mime_type="image/png",
        description="Architecture blueprint"
    )

    # Send a mixed list of text instructions and content classes
    prompt = [
        "Analyze this chart against the specification and list three security vulnerabilities:",
        chart_image,
        pdf_spec
    ]
    response = await agent.chat(prompt)
    print(await response.text())

Custom Tools

Register Python functions as tools that the agent can call:

def get_weather(city: str) -> str:
    """Returns the current weather for a city."""
    return f"It's sunny in {city}."

config = LocalAgentConfig(
    tools=[get_weather],
)
async with Agent(config) as agent:
    response = await agent.chat("What's the weather in Tokyo?")

MCP Integration

Connect to external MCP servers and expose their tools to the agent:

from google.antigravity import Agent, LocalAgentConfig
from google.antigravity.types import McpStdioServer

config = LocalAgentConfig(
    mcp_servers=[McpStdioServer(name="my_server", command="npx", args=["my-mcp-server"])],
)
async with Agent(config) as agent:
    response = await agent.chat("Use the MCP tools to help me.")

Hooks and Policies

Control agent behavior with a declarative policy system:

from google.antigravity import LocalAgentConfig
from google.antigravity.hooks.policy import deny, allow, ask_user, enforce
from google.antigravity.utils.interactive import run_interactive_loop

policies = [
    deny("*"),                          # Block all tools by default
    allow("view_file"),                 # Allow reading files
    ask_user("run_command", handler=my_handler),  # Ask before running commands
]

config = LocalAgentConfig(
    policies=policies,
)
await run_interactive_loop(config)

Triggers

Run background tasks that react to external events and push messages into the agent:

from google.antigravity import LocalAgentConfig
from google.antigravity.triggers import every
from google.antigravity.utils.interactive import run_interactive_loop

async def check_status(ctx):
    await ctx.send("Check the deployment status.")

config = LocalAgentConfig(
    triggers=[every(60, check_status)],
)
await run_interactive_loop(config)

Local AI Models

The Antigravity SDK supports local, offline agentic workflows powered by Gemma 4 and LiteRT-LM. By pairing your SDK scripts with local models, you can run LLM-driven tasks completely offline.

Prerequisites and Installation

First, it is recommended to create and activate a virtual environment:

python3 -m venv .venv
source .venv/bin/activate

Next, install the Antigravity SDK along with LiteRT-LM:

pip install google-antigravity litert-lm

Import the Gemma 4 26B MoE model. Take note of the imported model path (e.g. on MacOS, typically models are imported to USER/.litert-lm/models):

litert-lm import \
  --from-huggingface-repo=litert-community/gemma-4-26B-A4B-it-litert-lm \
  gemma-4-26B-A4B-it-gpu.litertlm \
  gemma4-26b

Quick Start for Local Models:

import asyncio
import os
from google.antigravity import Agent, LiteRTAgentConfig

# Point directly to the locally imported LiteRT-LM model path
MODEL_PATH = os.path.expanduser("~/.litert-lm/models/gemma4-26b/model.litertlm")

async def main():
    print(f"Using local LiteRT model: {MODEL_PATH}")
    config = LiteRTAgentConfig(
        model_path=MODEL_PATH,
    ).lightweight()

    async with Agent(config) as agent:
        response = await agent.chat("What files are in the current directory?")
        async for token in response:
            print(token, end="", flush=True)

if __name__ == "__main__":
    asyncio.run(main())

Architecture

The SDK follows a three-layer architecture:

Layer Purpose Key Classes
Layer 1 — Simplified High-level, batteries-included entry point Agent
Layer 2 — Session Stateful session with history and convenience methods Conversation, ChatResponse, Step, ToolCall, AgentConfig, HookRunner, ToolRunner, TriggerRunner
Layer 3 — Adapter Transport and backend abstraction Connection, ConnectionStrategy, LocalConnection

Component Documentation

For more detailed documentation on specific components, see:

  • Agent — High-level, batteries-included entry point.
  • Connections — Transport and backend abstraction.
  • Conversation — Stateful session management.
  • Hooks — Agent lifecycle interception and policies.
  • MCP — Model Context Protocol integration.
  • Tools — In-process tool execution.
  • Triggers — Background tasks and external events.

License

Apache License 2.0

Metadata

Release files for google-antigravity 0.1.24

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for google-antigravity 0.1.24
File Actions
google_antigravity-0.1.24-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details for google_antigravity-0.1.24-py3-none-win_arm64.whl
google_antigravity-0.1.24-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for google_antigravity-0.1.24-py3-none-win_amd64.whl
google_antigravity-0.1.24-py3-none-manylinux_2_17_x86_64.musllinux_1_1_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64, Linux musl 1.1+ x86-64 Details for google_antigravity-0.1.24-py3-none-manylinux_2_17_x86_64.musllinux_1_1_x86_64.whl
google_antigravity-0.1.24-py3-none-manylinux_2_17_aarch64.musllinux_1_1_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64, Linux musl 1.1+ ARM64 Details for google_antigravity-0.1.24-py3-none-manylinux_2_17_aarch64.musllinux_1_1_aarch64.whl
google_antigravity-0.1.24-py3-none-macosx_11_0_x86_64.whl Python 3 none macOS 11.0+ x86-64 Details for google_antigravity-0.1.24-py3-none-macosx_11_0_x86_64.whl
google_antigravity-0.1.24-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for google_antigravity-0.1.24-py3-none-macosx_11_0_arm64.whl

Total release size: 244.1 MB

Release files / google_antigravity-0.1.24-py3-none-win_arm64.whl

Download URL google_antigravity-0.1.24-py3-none-win_arm64.whl
Size 39.2 MB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
28837e53cf361fca8c63edee1d3cc0ba22c08eae3dec594d7f332e320fdcc9b7
BLAKE2b-256 checksum
How to use checksums
370ab209a4339870016cfc23ec44d87151677972fd9ab5e83de0f87f7ad6f40e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.2.0 CPython/3.11.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by Google Cloud, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / google_antigravity-0.1.24-py3-none-win_amd64.whl

Download URL google_antigravity-0.1.24-py3-none-win_amd64.whl
Size 42.8 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
cc2d2af2cbc260d9a9f6c95e7b844185dad29b44760c1e3884d2cb001f55adb8
BLAKE2b-256 checksum
How to use checksums
3763de80a45b2fad18f5e97cfc12a25436b6498669fe5eb8c6694e386b48d6d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.2.0 CPython/3.11.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by Google Cloud, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / google_antigravity-0.1.24-py3-none-manylinux_2_17_x86_64.musllinux_1_1_x86_64.whl

Download URL google_antigravity-0.1.24-py3-none-manylinux_2_17_x86_64.musllinux_1_1_x86_64.whl
Size 43.5 MB
Tags Linux glibc 2.17+ x86-64 Linux musl 1.1+ x86-64 Python 3
SHA-256 checksum
How to use checksums
678c5c56a4efa8d94b90df808a93b339cf3ead498b01898272d5833c8c9ad13f
BLAKE2b-256 checksum
How to use checksums
bc4fc697485a4fabffd38947eab670485fbcf7e24add178a64c6982f72c4708a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.2.0 CPython/3.11.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by Google Cloud, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / google_antigravity-0.1.24-py3-none-manylinux_2_17_aarch64.musllinux_1_1_aarch64.whl

Download URL google_antigravity-0.1.24-py3-none-manylinux_2_17_aarch64.musllinux_1_1_aarch64.whl
Size 39.8 MB
Tags Linux glibc 2.17+ ARM64 Linux musl 1.1+ ARM64 Python 3
SHA-256 checksum
How to use checksums
55c95c04b00c417667d37a000931638c23479d0f1fa0fbe6e89abb8c60057cda
BLAKE2b-256 checksum
How to use checksums
3d2b8ae68143e638cd7ac4db9824cc9b0fb6036b2ad92f8a15c4467602d53dfd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.2.0 CPython/3.11.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by Google Cloud, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / google_antigravity-0.1.24-py3-none-macosx_11_0_x86_64.whl

Download URL google_antigravity-0.1.24-py3-none-macosx_11_0_x86_64.whl
Size 40.4 MB
Tags Python 3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
ff368c84cc712b822c87dd2ac99b8fac47716c44ffa39bd1caf823e62f00a18f
BLAKE2b-256 checksum
How to use checksums
32e523dca5b02fe92b5e4b2516ee41b1fd762de501d931aff2be6893472d60a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.2.0 CPython/3.11.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by Google Cloud, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / google_antigravity-0.1.24-py3-none-macosx_11_0_arm64.whl

Download URL google_antigravity-0.1.24-py3-none-macosx_11_0_arm64.whl
Size 38.3 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9c359bfa7b752ad3417da1a455a114dca643d02bdea7281e8de8d0d0f44c9cca
BLAKE2b-256 checksum
How to use checksums
7160d276f00361ddedb6f9d3f2618775a909acff006279fb7bc6a64e23c75fcf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.2.0 CPython/3.11.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by Google Cloud, verified by PyPI on Nov 19, 2026.

Transparency log

Security for google-antigravity 0.1.24

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for google_antigravity-0.1.24-py3-none-win_arm64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by Google Cloud, verified by PyPI on Nov 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page