▸ Agent Skills
72 min read

\\

if (window.location.hostname === ‘www.antigravity.google’) { window.location.replace( https://antigravity.google${window.location.pathname}${window.location.search}${window.location.hash} ); } <title>Local models - Antigravity SDK | Google Antigravity Docs<script> window.dataLayer = window.dataLayer || []; window.__agyGtmLoaded = window.__agyGtmLoaded || false; window.__agyLastPageViewPath = window.__agyLastPageViewPath || ‘’;

function __agyDetectViewport() { const width = Math.round( window.innerWidth || (document.documentElement && document.documentElement.clientWidth) || 1440 ); const height = Math.round( window.innerHeight || (document.documentElement && document.documentElement.clientHeight) || 900 ); const orientation = width >= height ? ‘landscape’ : ‘portrait’; const minDim = Math.min(width, height); const maxDim = Math.max(width, height); const aspectRatio = minDim > 0 ? maxDim / minDim : 1; const ua = typeof navigator !== ‘undefined’ ? navigator.userAgent || ‘’ : ‘’;

const hasSegments =
  Boolean(
    window.visualViewport &&
      window.visualViewport.segments &&
      window.visualViewport.segments.length > 1
  ) ||
  Boolean(
    typeof navigator !== 'undefined' &&
      navigator.devicePosture &&
      navigator.devicePosture.type === 'folded'
  ) ||
  Boolean(
    window.matchMedia &&
      window.matchMedia(
        '(horizontal-viewport-segments: 2), (vertical-viewport-segments: 2)'
      ).matches
  );
const isFoldableUA =
  /Pixel Fold|SM-F9|SM-F7|Galaxy Z Fold|Surface Duo/i.test(ua);
const isFoldableUnfolded =
  minDim >= 600 && maxDim <= 1150 && aspectRatio <= 1.3;
const isFoldableCover =
  (width >= 320 &&
    width <= 368 &&
    height >= 700 &&
    height / width >= 2.0) ||
  (height >= 320 &&
    height <= 368 &&
    width >= 700 &&
    width / height >= 2.0);

const isIpad =
  /ipad/i.test(ua) ||
  (typeof navigator !== 'undefined' &&
    navigator.maxTouchPoints > 0 &&
    /macintosh/i.test(ua));
let os = 'unknown';
if (/iphone|ipod/i.test(ua)) os = 'iphone';
else if (isIpad) os = 'ipad';
else if (/googlebook|cros/i.test(ua)) os = 'googlebook';
else if (/android/i.test(ua)) os = 'android';
else if (/windows/i.test(ua)) os = 'windows';
else if (/macintosh|mac os x/i.test(ua)) os = 'mac';
else if (/linux/i.test(ua)) os = 'linux';

let viewportCategory = 'desktop';
if (
  hasSegments ||
  isFoldableUA ||
  isFoldableUnfolded ||
  isFoldableCover
) {
  viewportCategory = 'foldable';
} else if (width < 600) {
  viewportCategory = 'mobile';
} else if (width <= 1024 || isIpad) {
  viewportCategory = 'tablet';
}

return {
  viewportCategory: viewportCategory,
  formFactor: viewportCategory,
  viewportWidth: width,
  viewportHeight: height,
  orientation: orientation,
  operatingSystem: os,
};

}

function __agyRecordPageView() { const currentPath = window.location.pathname || ‘/’; if (window.__agyLastPageViewPath === currentPath) return;

if (
  window.agyAnalytics &&
  typeof window.agyAnalytics.trackPageView === 'function'
) {
  window.agyAnalytics.trackPageView();
  return;
}

window.__agyLastPageViewPath = currentPath;
const vp = __agyDetectViewport();
const eventParams = {
  pagePath: currentPath,
  viewportCategory: vp.viewportCategory,
  formFactor: vp.formFactor,
  viewportWidth: vp.viewportWidth,
  viewportHeight: vp.viewportHeight,
  orientation: vp.orientation,
  operatingSystem: vp.operatingSystem,
};
if (document.title) {
  eventParams.pageTitle = document.title;
}
if (document.referrer) {
  eventParams.referrer = document.referrer;
}
try {
  const sp = new URLSearchParams(window.location.search || '');
  const utmSource = sp.get('utm_source');
  const utmMedium = sp.get('utm_medium');
  const utmCampaign = sp.get('utm_campaign');
  const utmTerm = sp.get('utm_term');
  const utmContent = sp.get('utm_content');
  if (utmSource) {
    eventParams.utm_source = utmSource;
    eventParams.utmSource = utmSource;
  }
  if (utmMedium) {
    eventParams.utm_medium = utmMedium;
    eventParams.utmMedium = utmMedium;
  }
  if (utmCampaign) {
    eventParams.utm_campaign = utmCampaign;
    eventParams.utmCampaign = utmCampaign;
  }
  if (utmTerm) {
    eventParams.utm_term = utmTerm;
    eventParams.utmTerm = utmTerm;
  }
  if (utmContent) {
    eventParams.utm_content = utmContent;
    eventParams.utmContent = utmContent;
  }
} catch (_err) {
  // Ignore URLSearchParams errors
}

const entry = {
  event: 'page_view',
  pagePath: currentPath,
  viewportCategory: vp.viewportCategory,
  formFactor: vp.formFactor,
  viewportWidth: vp.viewportWidth,
  viewportHeight: vp.viewportHeight,
  orientation: vp.orientation,
  operatingSystem: vp.operatingSystem,
  eventParams: eventParams,
};
if (eventParams.pageTitle) entry.pageTitle = eventParams.pageTitle;
if (eventParams.referrer) entry.referrer = eventParams.referrer;
if (eventParams.utm_source) {
  entry.utm_source = eventParams.utm_source;
  entry.utmSource = eventParams.utmSource;
}
if (eventParams.utm_medium) {
  entry.utm_medium = eventParams.utm_medium;
  entry.utmMedium = eventParams.utmMedium;
}
if (eventParams.utm_campaign) {
  entry.utm_campaign = eventParams.utm_campaign;
  entry.utmCampaign = eventParams.utmCampaign;
}
if (eventParams.utm_term) {
  entry.utm_term = eventParams.utm_term;
  entry.utmTerm = eventParams.utmTerm;
}
if (eventParams.utm_content) {
  entry.utm_content = eventParams.utm_content;
  entry.utmContent = eventParams.utmContent;
}

window.dataLayer.push(entry);
window.dataLayer.push({ eventParams: undefined });

}

__agyRecordPageView();

window.glueCookieNotificationBarLoaded = function () { if (window.__agyGtmLoaded) return; window.__agyGtmLoaded = true; (function (w, d, s, l, i) { w[l] = w[l] || []; w[l].push({ ‘gtm.start’: new Date().getTime(), event: ‘gtm.js’, }); const f = d.getElementsByTagName(s)[0], j = d.createElement(s), dl = l != ‘dataLayer’ ? ‘&l=’ + l : ‘’; j.async = true; j.src = ‘https://www.googletagmanager.com/gtm.js?id=’ + i + dl; f.parentNode.insertBefore(j, f); })(window, document, ‘script’, ‘dataLayer’, ‘GTM-M4N2ZKXQ’); __agyRecordPageView(); };

document.addEventListener(‘astro:page-load’, function () { __agyRecordPageView(); }); <script> window.StarlightThemeProvider = (() => { const storedTheme = typeof localStorage !== ‘undefined’ && localStorage.getItem(‘starlight-theme’); const theme = storedTheme || (window.matchMedia(‘(prefers-color-scheme: light)’).matches ? ‘light’ : ‘dark’); document.documentElement.dataset.theme = theme === ‘light’ ? ‘light’ : ‘dark’; return { updatePickers(theme = storedTheme || ‘auto’) { document.querySelectorAll(‘starlight-theme-select’).forEach((picker) => { const select = picker.querySelector(‘select’); if (select) select.value = theme; /** @type {HTMLTemplateElement | null} */ const tmpl = document.querySelector(#theme-icons); const newIcon = tmpl && tmpl.content.querySelector(‘.’ + theme); if (newIcon) { const oldIcon = picker.querySelector(‘svg.label-icon’); if (oldIcon) { oldIcon.replaceChildren(…newIcon.cloneNode(true).childNodes); } } }); }, }; })(); <style>@layer starlight.components{svg:where(.astro-n5k4ipy7){color:var(–sl-icon-color);font-size:var(–sl-icon-size,1em);width:1em;height:1em}} .button{font-size:var(–base-size);line-height:var(–cta-line-height);letter-spacing:var(–cta-letter-spacing);border-radius:var(–shape-corner-rounded,999px);cursor:pointer;text-align:center;border:1px solid #0000;justify-content:center;align-self:flex-start;align-items:center;height:fit-content;padding:10px 24px;font-family:Google Sans Flex,sans-serif;font-weight:450;text-decoration:none;transition:all .15s ease-out;display:inline-flex}.button span{text-decoration:none}.button .icon{color:currentColor;margin:0 var(–space-sm) 0 0;flex-shrink:0;align-items:center;line-height:0;display:inline-flex}.button:disabled{cursor:not-allowed}.button-primary{background:var(–theme-primary-primary,#1a73e8);color:var(–theme-primary-on-primary,#fff)}.button-primary:hover,.button-primary:focus-visible{background:var(–theme-button-states-primary-hovered,#1557b0);outline:none}.button-primary:disabled{background:var(–theme-button-states-disabled);color:var(–theme-button-states-on-disabled)}.button-primary-inverse{background:var(–palette-grey-0);color:var(–palette-grey-1200)}.button-primary-inverse:hover,.button-primary-inverse:focus-visible{background:var(–theme-surface-surface-container-high);outline:none}.button-primary-inverse:active{background:var(–theme-surface-surface-container-high)}.button-primary-inverse:disabled{background:var(–theme-button-states-disabled);color:var(–theme-button-states-on-disabled)}.button-secondary{color:var(–theme-surface-on-surface);background:var(–theme-secondary-button);backdrop-filter:blur(6px);border:1px solid var(–theme-outline-variant)}.button-secondary:hover,.button-secondary:focus-visible{background:var(–theme-button-secondary-hover);outline:none}.button-secondary:disabled{background:var(–theme-button-states-disabled);color:var(–theme-button-states-on-disabled)}.button-secondary-inverse{color:var(–theme-surface-surface);background:var(–theme-nav-button-hover);backdrop-filter:blur(8px);border:1px solid var(–theme-inverse-outline-variant)}.button-secondary-inverse:hover,.button-secondary-inverse:focus-visible{background:var(–theme-button-secondary-inverse-hover);outline:none}.button-secondary-inverse:disabled{background:var(–palette-grey-1100);color:var(–palette-grey-50-20)}.button-text,.button-nav{background:0 0}.button-text{color:var(–theme-text-on-text)}.button-text:hover,.button-text:focus-visible{background:var(–theme-button-states-hovered);outline:none}.button-text:active{background:var(–theme-button-states-pressed)}.button-text:disabled{color:var(–theme-button-states-on-disabled)}.button-compact{min-block-size:36px;padding:6px 16px}.download-button,.button-nav{font-size:var(–cta-sm-size);line-height:var(–cta-sm-line-height);letter-spacing:var(–cta-sm-letter-spacing);font-weight:450}.button-nav{color:var(–theme-surface-on-surface-variant)}.button-nav:hover,.button-nav:focus-visible{color:#000;background:var(–theme-nav-button-hover);outline:none}@media (width<=767px){.button-nav{width:100%}}.dropdown-nav{padding-right:8px}.dropdown-icon,.play-icon{letter-spacing:normal;text-transform:none;white-space:nowrap;word-wrap:normal;-webkit-font-smoothing:antialiased;text-rendering:optimizelegibility;font-feature-settings:“liga”;-webkit-font-feature-settings:“liga”;font-variation-settings:“FILL” 0, “wght” 300, “GRAD” 0, “ROND” 50, “opsz” 48;margin:0 0 0 var(–space-xs);transition:transform .3s all;direction:ltr;flex-shrink:0;justify-content:center;align-items:center;font-family:Google Symbols;font-size:1.5em;font-weight:300;line-height:1;display:inline-flex}.dropdown-icon svg,.play-icon svg{fill:currentColor;display:block}.button.dropdown-open .dropdown-icon,.button[aria-expanded=true] .dropdown-icon,.dropdown-open>.dropdown-icon{transform:rotate(-180deg)}.play-icon{font-variation-settings:“FILL” 1, “wght” 300, “GRAD” 0, “ROND” 50, “opsz” 48}@media (width<=1024px){.nav-button{padding:var(–space-md);width:100%}} Skip to content

<site-search class=“astro-mtusqnhg astro-r5ar4xm7” data-translations=“{“placeholder”:“Search”}“>
<script> (() => { const openBtn = document.querySelector(‘button[data-open-modal]’); const shortcut = openBtn?.querySelector(‘kbd’); if (!openBtn || !(shortcut instanceof HTMLElement)) return; const platformKey = shortcut.querySelector(‘kbd’); if (platformKey && /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform)) { platformKey.textContent = ‘⌘’; openBtn.setAttribute(‘aria-keyshortcuts’, ‘Meta+K’); } shortcut.style.display = ‘’; })();
<script> StarlightThemeProvider.updatePickers();

Run Antigravity agents on your machine using local models without an API key or internet connection.

Depending on your setup, you can configure local model execution using the following classes:

\ \LiteRTAgentConfig: Runs .litertlm model checkpoints (such as Gemma 4 26B A4B) directly on-device using Google AI Edge’s LiteRT runtime. \LocalOpenAIAgentConfig: Connects to an external local server with an OpenAI-compatible API, such as Ollama, LM Studio, or vLLM.

LiteRTAgentConfig runs local models using the LiteRT runtime. When the agent starts, the SDK spins up and manages a local loopback server backed by your .litertlm checkpoint. Supported hardware backends (gpu for Apple Silicon Metal and NVIDIA CUDA, or npu) are detected automatically at startup.

Follow these steps to install the dependencies and import the model checkpoint:

Note: A machine with at least 24 GB of VRAM or unified memory is recommended to run the Gemma 4 26B A4B checkpoint (which downloads about 16.8 GB).

\ \

Create and activate a virtual environment:

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

Install the SDK and the litert-lm package:

pip install google-antigravity litert-lm
\

Use the litert-lm CLI to import the Gemma 4 26B A4B checkpoint:

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

This command downloads about 16.8 GB and registers the checkpoint at ~/.litert-lm/models/gemma4-26b/model.litertlm.

Note: On macOS, if litert-lm import fails with an SSL certificate verification error, install certifi and export SSL_CERT_FILE before retrying:

pip install certifi
export SSL_CERT_FILE=$(python3 -c "import certifi; print(certifi.where())")

Once you have configured LiteRT, run a local LiteRT agent by passing the .litertlm model file in LiteRTAgentConfig. For example:

Note: Use the full path to your model file or use os.path.expanduser() because tilde (~) isn’t expanded automatically.

import asyncio
import os

from google.antigravity import Agent, LiteRTAgentConfig

MODEL_PATH = os.path.expanduser(
    "~/.litert-lm/models/gemma4-26b/model.litertlm"
)


async def main():
    config = LiteRTAgentConfig(model_path=MODEL_PATH)

    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)
        print()


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

If you want to let the local agent edit files and run shell commands in a project directory, set workspaces and attach a tool policy. For example:

import asyncio
import os

from google.antigravity import Agent, LiteRTAgentConfig
from google.antigravity.hooks import policy


async def main():
    workspace = os.path.expanduser("~/my-local-project")
    os.makedirs(workspace, exist_ok=True)

    config = LiteRTAgentConfig(
        model_path=os.path.expanduser(
            "~/.litert-lm/models/gemma4-26b/model.litertlm"
        ),
        workspaces=[workspace],
        policies=[policy.allow_all()],
    )

    async with Agent(config) as agent:
        response = await agent.chat(
            "Create a static webpage index.html with a dark-mode toggle."
        )
        async for token in response:
            print(token, end="", flush=True)
        print()


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

LiteRTAgentConfig automatically applies the .lightweight() preset when initialized. This preset restricts built-in tools to core coding operations, trims system instructions for smaller context windows, and sets a default context compaction threshold sized for the 64k LiteRT KV-cache.

In addition to standard AgentConfig fields (tools, policies, hooks, mcp_servers, subagents, workspaces, and system_instructions), LiteRTAgentConfig supports the following options:

\ \model_path (string, required): Absolute path to a .litertlm model file. \backend (LiteRTBackend or string, optional): Hardware backend for inference ('gpu', 'npu', or 'cpu'). Defaults to LiteRTBackend.GPU. \enable_speculative_decoding (boolean, optional): Enables multi-token prediction for faster generation. Defaults to False. \cache_dir (string, optional): Directory path for caching compiled model graphs across launches. \compaction_config (CompactionConfig, optional): Overrides the default context compaction threshold.

To connect to an external local server that exposes an OpenAI-compatible API (such as Ollama, LM Studio, or vLLM), use LocalOpenAIAgentConfig. Call .lightweight() on the configuration to apply the tool and prompt optimizations designed for local models if needed.

Note: Don’t use LocalOpenAIAgentConfig to connect to litert-lm serve. Use LiteRTAgentConfig instead so the SDK manages the LiteRT server lifecycle for you.

For example, you can connect an agent to a local Ollama server running Gemma 4:

import asyncio
from google.antigravity import Agent, LocalOpenAIAgentConfig


async def main():
    config = LocalOpenAIAgentConfig(
        model="gemma4:26b",
        base_url="http://localhost:11434/v1",
    ).lightweight()

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


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

LocalOpenAIAgentConfig supports all standard AgentConfig options along with these connection parameters:

\ \model (string or ModelTarget, optional): Model identifier registered on your local server (such as "gemma4:26b" or "gemma-4-26B-A4B-it"). \base_url (string, optional): URL of the local server’s OpenAI-compatible endpoint (such as "http://localhost:11434/v1" for Ollama or "http://localhost:1234/v1" for LM Studio).

To explore full working code examples, check out the following resources:

\ \local_models.py: Getting-started script for LiteRTAgentConfig and LocalOpenAIAgentConfig. \Antigravity Hybrid Gauntlet: Hybrid workflow that pairs a cloud Gemini planner with local Gemma 4 26B agents for on-device code auditing and patching.

Last updated Oct 11, 2026