If you use Google's Antigravity (agy) CLI, you already know how capable its agentic loop is. I wanted to use that same engine—with streaming tokens, tool execution events, and persistent multi-turn conversations—directly inside Python scripts, bots, and standard OpenAI clients.
So I built and open-sourced antigravity-sdk (v0.1.0, MIT).
How It Works
Instead of reimplementing auth or reverse-engineering endpoints, antigravity-sdk spawns the unmodified agy binary in headless --output-format stream-json mode and parses its NDJSON event stream into typed Python dataclasses:
TextDeltaEventToolCallEventToolResultEventResultEvent
Quickstart
git clone https://github.com/Sooriya04/antigravity-sdk.git
cd antigravity-sdk
pip install -e ".[all]"
1. Python SDK (Antigravity / AsyncAntigravity)
from antigravity_sdk import Antigravity
client = Antigravity()
for token in client.stream("Explain quantum entanglement in one sentence."):
print(token, end="", flush=True)
print()
2. Drop-In OpenAI Bridge (agy-bridge)
Start the FastAPI bridge on port 18790:
agy-bridge --port 18790
Then point any OpenAI client at http://127.0.0.1:18790/v1:
from openai import OpenAI
client = OpenAI(base_url="http://127.0.0.1:18790/v1", api_key="not-needed")
stream = client.chat.completions.create(
model="gemini-4-hydrogen-low",
messages=[{"role": "user", "content": "Hello Antigravity!"}],
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="", flush=True)
It also hashes incoming system prompts per session so large system contexts aren't re-sent on every turn unless they actually change.
Repo & Links
- GitHub: https://github.com/Sooriya04/antigravity-sdk
- License: MIT
-
Terms: Built around the unmodified
agyCLI (seeTERMS.mdfor Antigravity's acceptable-use notes).
Feedback, issues, and PRs are welcome!
Top comments (0)