Google Antigravity Rust SDK
The Google Antigravity SDK is a Rust library 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
-
Add the SDK to your project using Cargo:
Or add it manually to your
Cargo.toml:[] = "0.1.0" = { = "1", = ["full"] } -
Obtain the
localharnessbinary: The SDK relies on a compiled native Go runtime binary (localharness) to orchestrate agent operations. You have two options to install it:-
Option A: Without Python/pip (Recommended for Rust-only environments & web servers) Run the helper installer script to download and extract the binary directly from PyPI (wheels are standard ZIP files):
-
Option B: Using Python/pip If Python is already installed on your development machine, simply run:
The Rust SDK will automatically locate the binary inside the Python package installation directory fallback.
-
Quickstart
Get started by setting your API key and running the hello_world example:
Concepts
Simple Agent
The Agent struct manages the full lifecycle — binary discovery, tool wiring, hook registration, and policy defaults.
use ;
use policy;
async
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:
use AgentConfig;
use Conversation;
use LocalConnectionStrategy;
use ToolRunner;
use GeminiConfig;
use Arc;
async
Features
Custom Tools
Register Rust functions as custom tools:
use ;
use Tool;
use async_trait;
use Value;
;
Hooks and Policies
Control agent behavior with a declarative policy system:
use ;
let policies = vec!;
Web Integration
The SDK provides two patterns for building web applications with AI agents:
Leptos + Axum (Native)
For standard web servers (VPS, Docker, bare metal). The Agent runs in-process with full SDK features.
# Open http://localhost:3000
Leptos + Spin/WASI (Edge)
For edge/serverless deployments on Fermyon Spin. Since Spin components cannot make outbound TCP/WebSocket connections, two modes are supported:
Sidecar Mode (Full SDK):
# Terminal 1: Start the agent sidecar
GEMINI_API_KEY=your-key
# Terminal 2: Start Spin
# Open http://localhost:3000
Direct Mode (Lightweight, no sidecar):
See
examples/README.mdfor detailed architecture diagrams and configuration options.
GeminiDirectClient
For environments where TCP/WebSocket is unavailable (e.g. WASI, embedded), the SDK provides a transport-agnostic Gemini API client that builds HTTP request payloads and parses responses — the caller provides the HTTP transport:
use ;
use GeminiConfig;
let client = new
.with_system_instruction;
// Build the request (URL, headers, body) — send via your HTTP client
let request = client.build_request.unwrap;
// Parse the response
let text = parse_response.unwrap;
Local Development
This project uses just to manage development tasks.
- Check Code Quality: Run all style, lint, and test checks.
- Install Local Harness: Download and configure the required
localharnessbinary. - Bump version & Release tag: Bump the package version, update Cargo.lock, commit using
--no-verify(skipping git hooks), and tag the release.# Auto-bump patch version (e.g., 0.1.0 -> 0.1.1) # Or force/override with a specific version - Publish to Crates.io: Manually publish the package to crates.io (runs
just checkfirst).
Architecture
For more information, see ARCHITECTURE.md.
License
This project is licensed under the MIT License.