> ## Documentation Index
> Fetch the complete documentation index at: https://docs.braintrust.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Antigravity SDK

> Trace Google Antigravity SDK agent turns in Braintrust to debug agent steps, tool calls, and token usage

The [Google Antigravity](https://antigravity.google/) SDK (`google-antigravity`) is a Python SDK for building agents on Antigravity. Braintrust traces each `Agent.chat()` turn, including the agent's steps and tool calls.

> [!NOTE]
>
> Requires Braintrust Python SDK v0.51.0 or later and `google-antigravity` v0.1.23 or later. To trace sessions in the Antigravity coding agent instead, see [Google Antigravity](https://docs.braintrust.dev/integrations/developer-tools/antigravity.md).

**Python**

## Setup

Install Braintrust alongside the Antigravity SDK, then set your environment variables.

**1. Install packages**

```bash uv theme={null}
uv add braintrust google-antigravity
```

```bash pip theme={null}
pip install braintrust google-antigravity
```

**2. Set environment variables**

```bash title=".env" theme={null}
BRAINTRUST_API_KEY=<your-braintrust-api-key>
GEMINI_API_KEY=<your-gemini-api-key>
```

## Auto-instrumentation

`braintrust.auto_instrument()` traces Antigravity agents alongside Braintrust's other supported libraries. Call it before you create an `Agent`.

```python title="trace_antigravity_auto.py" theme={null}
import asyncio

import braintrust

braintrust.init_logger(project="antigravity-sdk-example")  # Replace with your project name
braintrust.auto_instrument()

from google.antigravity import Agent, LocalAgentConfig


async def main():
    config = LocalAgentConfig(model="gemini-3.8-flash")
    async with Agent(config) as agent:
        response = await agent.chat("Summarize what this repository does.")
        print(await response.text())


asyncio.run(main())
```

To disable Antigravity SDK instrumentation when calling `auto_instrument()`, pass `antigravity=False`:

```python theme={null}
braintrust.auto_instrument(antigravity=False)
```

## Manual instrumentation

`setup_antigravity()` traces the Antigravity SDK without auto-instrumenting other libraries. It initializes a Braintrust logger when one isn't already active. Call it before you create an `Agent`.

```python title="trace_antigravity_manual.py" theme={null}
import asyncio

from braintrust.integrations.antigravity import setup_antigravity

setup_antigravity(project="antigravity-sdk-example")  # Replace with your project name

from google.antigravity import Agent, LocalAgentConfig


async def main():
    config = LocalAgentConfig(model="gemini-3.8-flash")
    async with Agent(config) as agent:
        response = await agent.chat("Summarize what this repository does.")
        print(await response.text())


asyncio.run(main())
```

To instrument a specific `Agent` class instead, pass it to `wrap_antigravity_agent()`. The class is patched in place, including when you imported it before the call.

```python theme={null}
from braintrust.integrations.antigravity import wrap_antigravity_agent
from google.antigravity import Agent

wrap_antigravity_agent(Agent)
```

## What Braintrust traces

Braintrust traces each `Agent.chat()` turn as a nested trace:

* Chat turn spans (`antigravity.chat`), with the prompt as input, preceded by the agent's system instructions when set. The output is the assistant's final text or structured output. Metadata records the model, the enabled built-in tools and Python tool definitions (name, description, and parameters), and the conversation ID.
* Model step spans (`antigravity.<step type>`), with the step's assistant content and reasoning as output, and the trajectory ID and step index in metadata.
* Built-in tool spans named after each tool, such as `view_file`, with the tool arguments as input.
* Python tool spans named after each function tool, with the call arguments as input and the return value as output.
* Images, documents, audio, and video in prompts and Python tool results, uploaded as attachments.
* Token usage metrics (prompt, cached prompt, completion, reasoning, and total) and time to first token on the chat turn span.
* Errors on the chat turn span, including cancelled turns, and on the step that failed.

> [!NOTE]
>
> The Antigravity SDK runs model requests in a separate process and reports token usage per turn. Braintrust records that usage on the `antigravity.chat` span, and model step spans show the agent's progress within the turn.

## Resources

* [Google Antigravity](https://antigravity.google/)
* [`google-antigravity` on PyPI](https://pypi.org/project/google-antigravity/)
* [Braintrust Python SDK reference](https://docs.braintrust.dev/sdks/python/versions/latest.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.