Warning
Using this plugin can get your Google account disabled.
Google's current Antigravity terms prohibit using third-party software, tools, or services (explicitly including OpenCode) to access an Antigravity/Gemini CLI login. Accounts detected doing so are blocked with:
This service has been disabled in this account for violation of Terms of Service. Please submit an appeal to continue using this product.
A disabled account can only be restored through Google's appeal form. The plugin prints this warning on every startup.
Supported alternatives that do not rely on an Antigravity login:
- OpenCode's native
googleprovider with a Gemini API key (GOOGLE_GENERATIVE_AI_API_KEY, from Google AI Studio). - OpenCode's native
google-vertexprovider with your own Google Cloud project.
Use this plugin at your own risk. The maintainer takes no responsibility for any action Google takes against your account.
An OpenCode authentication plugin that enables seamless interaction with the Antigravity CLI (agy) by hooking into its authentication, quota retrieval, and dynamic model fetching layers.
- OAuth 2.0 Integration: Uses Antigravity's OAuth flows for authentication.
- Dynamic Model Retrieval: Fetches available models based on user tier and current allocations.
- Quota Tracking: Injects the
agy_quotatool into OpenCode to check usage limits directly. - Background Session Requests: Sends the session-level requests the Antigravity backend expects alongside model calls.
- Dual OpenCode Compatibility: Natively supports both OpenCode v1 (>= 1.18.29) and OpenCode v2 out of the box without breaking changes.
Install the plugin from npm (or directly using local file configurations if developing):
npm install @anthonyhaussman/opencode-agy-authUpdate your OpenCode configuration file (typically opencode.json at the root of your project or globally at ~/.config/opencode/opencode.json) to register the plugin and specify your Google Cloud Project ID.
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@anthonyhaussman/opencode-agy-auth"],
"provider": {
"google-agy": {
"options": {
"projectId": "your-google-cloud-project-id"
}
}
}
}By default, the plugin registers a specialized provider ID to interface with agy.
You can switch your active OpenCode provider to agy or let the plugin inject authentication into your existing sessions.
If you are running OpenCode in environments with specific requirements for Antigravity, you can use the following environment variables:
OPENCODE_AGY_PROJECT_ID: Specify your Google Cloud Project ID manually.OPENCODE_AGY_AUTH_PROXY: Define a proxy if accessing authentication endpoints behind a corporate firewall.OPENCODE_AGY_ENDPOINT: Override the default internaldaily-cloudcode-pa.googleapis.comAPI endpoint.OPENCODE_AGY_VERBOSE_LOGS: Set to"1"to enable verbose diagnostic logs for API calls and responses.
Once installed and configured, OpenCode will automatically authenticate against Antigravity CLI when interacting with eligible models. If no active session exists, you will be prompted to complete an OAuth login.
Additionally, you can check your quota using slash commands directly in your OpenCode prompt:
/agyquota- Per-model detail view. Shows remaining tokens, progress bars, and reset timers for every model variant. Use when you need the full breakdown of individual buckets./agyquotasummary- High-level grouped view. Shows weekly and 5-hour limits aggregated by model family. Use when you want a quick overview of your allowance across all models.
You can also ask naturally:
"What is my current agy quota?" "Show me my quota summary"
This repository is compatible with opencode-quota, an OpenCode plugin for displaying quota information directly in your status bar or interface.
Follow the Google AGY Quick Setup Guide to set them up together.
To use both plugins side by side, register them in your opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"plugin": [
"@anthonyhaussman/opencode-agy-auth",
"opencode-quota"
],
"provider": {
"google-agy": {
"options": {
"projectId": "your-google-cloud-project-id"
}
}
}
}When used together, opencode-quota seamlessly visualizes rate limits and quotas for models authenticated through google-agy.
The plugin persists turn-state and retry-cooldown data to disk so that it survives OpenCode restarts. Files are stored under ~/.config/opencode/ (or %APPDATA%\opencode\ on Windows):
antigravity-turn-states.json- tracks thinking/reasoning state across request turns, with a 24-hour TTL and 5-second throttled writes using atomic tmp+rename.- Retry cooldowns are persisted via
CooldownStorewith the same atomic-write pattern.
Both stores initialize lazily at runtime - no filesystem reads occur at import time.
TurnStateTracker accepts a diskEnabled constructor parameter (defaults to true):
import { TurnStateTracker } from "@anthonyhaussman/opencode-agy-auth/sdk/request/turn-state-tracker";
// Disk persistence enabled (default)
const tracker = new TurnStateTracker(true);
// Memory-only mode - no filesystem reads or writes
const tracker = new TurnStateTracker(false);When diskEnabled is false, the tracker operates entirely in memory. All state is lost when the process exits. This is useful in restricted environments (containers, read-only filesystems) where disk access is unavailable or undesirable.
If disk initialization fails at runtime (permission error, corrupt file, etc.), the plugin automatically falls back to memory-only mode and logs a warning. No configuration is needed for normal use - disk persistence works out of the box.
To test and develop the plugin locally with OpenCode before publishing:
-
Build the plugin locally: Clone the repository, install dependencies, and build the source code:
npm install npm run build
-
Configure OpenCode to use the local build: In the target project where you want to test the plugin, open your
opencode.json(or~/.config/opencode/opencode.jsonfor global testing) and add the absolute local path to the plugin:{ "$schema": "https://opencode.ai/config.json", "plugin": ["/absolute/path/to/opencode-agy-auth"] }Note: OpenCode also supports dropping plugin files directly into the
.opencode/plugins/folder in your project. -
Verify the plugin: Launch OpenCode in your target project. OpenCode will automatically resolve and load your local plugin directory. You can test your changes by running
npm run buildin the plugin directory and restarting your OpenCode session.
The plugin natively supports both OpenCode v1 (>= 1.18.29) and OpenCode v2 out of the box through a dual-compatibility architecture:
- OpenCode v1: Loaded via the
server(options)hook with custom OAuth flow and provider setup. - OpenCode v2: Loaded via
Plugin.define/setup(ctx)with native catalog transformations, AI SDK hooks, session interception, and PKCE OAuth integration.
No special flags or configurations are required - the plugin detects runtime automatically.
To test bleeding-edge features or upcoming changes before official releases, configure the @alpha distribution tag:
npm install @anthonyhaussman/opencode-agy-auth@alphaOr configure it directly in your opencode.json:
{
"plugin": ["@anthonyhaussman/opencode-agy-auth@alpha"]
}Warning
Instability Warning: The @alpha release contains experimental features and active development builds. It may be unstable or cause disruptions in session authentication and model requests. Use only for testing and development. For day-to-day work, use the stable release.
If this plugin saved you time or made using Antigravity models in OpenCode smoother, consider giving the repository a star on GitHub - it helps others discover the project.