Google Antigravity SDK for building AI agents
pip install google-antigravity==0.1.19 Copy PIP instructions
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.
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:
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).
# 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.
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, Agent runs in read-only mode for safety. Pass capabilities=CapabilitiesConfig() to enable all tools (including writes).
from google.antigravity import LocalAgentConfig, CapabilitiesConfig from google.antigravity.utils.interactive import run_interactive_loop config = LocalAgentConfig( # api_key="your_api_key_here", capabilities=CapabilitiesConfig(), ) 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:
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):
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:
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:
For more detailed documentation on specific components, see:
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Enable javascript to be able to filter the list of wheel files.
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 verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by Google Cloud, verified by PyPI on Sep 26, 2026.




