narlyse-ag
v1.6.12
Published
Enhanced Google Antigravity IDE OAuth auth plugin for OpenCode (Fork by Andy Vandaric) - featuring Oh-My-OpenCode integration, strict quota locking, and proxy support.
Maintainers
Readme
OpenCode AG Auth (Narlyse AG)
The hardened, safety-first Antigravity plugin for OpenCode.
This plugin enables OpenCode to authenticate against Antigravity (Google's IDE) with a focus on account protection and session stability. You can access models like gemini-3.1-pro and claude-opus-4-6-thinking while keeping your accounts safe from bans and allowing your agents to run without interruption.
Why this fork?
This is a specialized fork of opencode-antigravity-auth that focuses on safety and reliability for power users and autonomous agents.
Enhanced Protection
- Strict Quota Protocol (SQP): Enforces a 70% safety buffer on API usage. Accounts are strictly locked before they hit Google's abuse limits.
- Leak-Proof Locking: Locked accounts are ignored until their specific reset time passes. This prevents "leaky" usage caused by cache expiry.
Agent Stability
- Oh-My-OpenCode Integration: Native support for session recovery. It automatically handles tool crashes and model "thinking" blocks without user intervention.
- Smart Proxy Support: Proxy support via
undicifor complex network environments. - Interactive Pause: Pauses execution gracefully when quotas run low. This allows human intervention instead of crashing the process.
Key Features
- All Antigravity Models: Claude Opus 4.6, Sonnet 4.6, and Gemini 3.1 Pro/Flash via Google OAuth.
- Thinking Models: Configurable thinking budgets for complex reasoning tasks.
- Multi-Account Rotation: Add unlimited Google accounts. The plugin rotates through them based on health and quota.
- Dual Quota Pools: Intelligently routes between Antigravity and Gemini CLI quotas.
- Google Search Grounding: Enable real-time web search for Gemini models.
[!CAUTION] Using this plugin may violate Google's Terms of Service. A small number of users have reported their Google accounts being banned or shadow-banned (restricted access without explicit notification).
High-risk scenarios:
- Warning: Fresh Google accounts have a very high chance of getting banned.
- Warning: New accounts with Pro or Ultra subscriptions are frequently flagged and banned.
By using this plugin, you acknowledge:
- This is an unofficial tool not endorsed by Google.
- Your account may be suspended or permanently banned.
- You assume all risks associated with using this plugin.
Recommendation: Use an established Google account that you do not rely on for critical services. Avoid creating new accounts specifically for this plugin.
Installation
Option A: Let an LLM do it
Paste this into any LLM agent (Claude Code, OpenCode, Cursor, etc.):
Install the narlyse-ag plugin and add the Antigravity model definitions to ~/.config/opencode/opencode.json by following: https://raw.githubusercontent.com/narlyseorg/narlyse-ag/main/README.mdOption B: Manual setup (NPM)
Add the plugin to
~/.config/opencode/opencode.json(OpenCode will auto-install from NPM):{ "plugin": ["narlyse-ag@latest"] }Want bleeding-edge features? Use
narlyse-ag@betainstead.Login with your Google account:
opencode auth loginAdd models, choose one:
- Run
opencode auth loginthen select "Configure models in opencode.json" (auto-configures all models). - Or manually copy the full configuration below.
- Run
Use it:
opencode run "Hello" --model=google/antigravity-claude-sonnet-4-6-thinking --variant=max
Step-by-Step Instructions
Edit the OpenCode configuration file at
~/.config/opencode/opencode.jsonNote: This path works on all platforms. On Windows,
~resolves to your user home directory (e.g.,C:\Users\YourName).Add the plugin to the
pluginarray.Add the model definitions from the Full models configuration section.
Set
providerto"google"and choose a model.
Verification
opencode run "Hello" --model=google/antigravity-claude-sonnet-4-6-thinking --variant=maxFor a complete installation guide, including manual methods and advanced agent protocols, see docs/INSTALLATION.md.
Models
Model Reference
Antigravity quota (default routing for Claude and Gemini):
| Model | Variants | Notes |
|-------|----------|-------|
| antigravity-gemini-3.1-pro | low, high | Gemini 3.1 Pro with thinking |
| antigravity-gemini-3-flash | minimal, low, medium, high | Gemini 3 Flash with thinking |
| antigravity-claude-sonnet-4-6 | | Claude Sonnet 4.6 |
| antigravity-claude-sonnet-4-6-thinking | low, max | Claude Sonnet with extended thinking |
| antigravity-claude-opus-4-6-thinking | low, max | Claude Opus 4.6 with extended thinking |
Gemini CLI quota (separate from Antigravity; used when cli_first is true or as fallback):
| Model | Notes |
|-------|-------|
| gemini-2.5-flash | Gemini 2.5 Flash |
| gemini-2.5-pro | Gemini 2.5 Pro |
| gemini-3-flash-preview | Gemini 3 Flash (preview) |
| gemini-3.1-pro-preview | Gemini 3.1 Pro (preview) |
Routing Behavior:
- Antigravity-first (default): Gemini models use Antigravity quota across accounts.
- CLI-first (
cli_first: true): Gemini models use Gemini CLI quota first.- When a Gemini quota pool is exhausted, the plugin automatically falls back to the other pool.
- Claude and image models always use Antigravity. Model names are automatically transformed for the target API (e.g.,
antigravity-gemini-3-flashtogemini-3-flash-previewfor CLI).
Using variants:
opencode run "Hello" --model=google/antigravity-claude-sonnet-4-6-thinking --variant=maxFor details on variant configuration and thinking levels, see docs/MODEL-VARIANTS.md.
Add this to your ~/.config/opencode/opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["narlyse-ag@latest"],
"provider": {
"google": {
"models": {
"antigravity-gemini-3.1-pro": {
"name": "Gemini 3.1 Pro (Antigravity)",
"limit": { "context": 1048576, "output": 65535 },
"modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
"variants": {
"low": { "thinkingLevel": "low" },
"high": { "thinkingLevel": "high" }
}
},
"antigravity-gemini-3-flash": {
"name": "Gemini 3 Flash (Antigravity)",
"limit": { "context": 1048576, "output": 65536 },
"modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
"variants": {
"minimal": { "thinkingLevel": "minimal" },
"low": { "thinkingLevel": "low" },
"medium": { "thinkingLevel": "medium" },
"high": { "thinkingLevel": "high" }
}
},
"antigravity-claude-sonnet-4-6": {
"name": "Claude Sonnet 4.6 (Antigravity)",
"limit": { "context": 1000000, "output": 64000 },
"modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
},
"antigravity-claude-sonnet-4-6-thinking": {
"name": "Claude Sonnet 4.6 Thinking (Antigravity)",
"limit": { "context": 1000000, "output": 64000 },
"modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
"variants": {
"low": { "thinkingConfig": { "thinkingBudget": 8192 } },
"max": { "thinkingConfig": { "thinkingBudget": 32768 } }
}
},
"antigravity-claude-opus-4-6-thinking": {
"name": "Claude Opus 4.6 Thinking (Antigravity)",
"limit": { "context": 1000000, "output": 64000 },
"modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
"variants": {
"low": { "thinkingConfig": { "thinkingBudget": 8192 } },
"max": { "thinkingConfig": { "thinkingBudget": 32768 } }
}
},
"gemini-2.5-flash": {
"name": "Gemini 2.5 Flash (Gemini CLI)",
"limit": { "context": 1048576, "output": 65536 },
"modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
},
"gemini-2.5-pro": {
"name": "Gemini 2.5 Pro (Gemini CLI)",
"limit": { "context": 1048576, "output": 65536 },
"modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
},
"gemini-3-flash-preview": {
"name": "Gemini 3 Flash Preview (Gemini CLI)",
"limit": { "context": 1048576, "output": 65536 },
"modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
},
"gemini-3.1-pro-preview": {
"name": "Gemini 3.1 Pro Preview (Gemini CLI)",
"limit": { "context": 1048576, "output": 65535 },
"modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
}
}
}
}
}Backward Compatibility: Legacy model names with an
antigravity-prefix (e.g.,antigravity-gemini-3-flash) still work. The plugin automatically handles model name transformation for both Antigravity and Gemini CLI APIs.
Multi-Account Setup
Add multiple Google accounts for higher combined quotas. The plugin automatically rotates between accounts when one is rate-limited.
opencode auth login # Run again to add more accountsAccount management options (via opencode auth login):
- Configure models: Auto-configure all plugin models in opencode.json
- Check quotas: View remaining API quota for each account
- Manage accounts: Enable or disable specific accounts for rotation
For details on load balancing, dual quota pools, and account storage, see docs/MULTI-ACCOUNT.md.
Troubleshoot
Quick Reset: Most issues can be resolved by deleting
~/.config/opencode/antigravity-accounts.jsonand runningopencode auth loginagain.
Configuration Path (All Platforms)
OpenCode uses ~/.config/opencode/ on all platforms including Windows.
| File | Path |
|------|------|
| Main config | ~/.config/opencode/opencode.json |
| Accounts | ~/.config/opencode/antigravity-accounts.json |
| Plugin config | ~/.config/opencode/antigravity.json |
| Debug logs | ~/.config/opencode/antigravity-logs/ |
Windows users:
~resolves to your user home directory (e.g.,C:\Users\YourName). Do NOT use%APPDATA%.
Custom path: Set the
OPENCODE_CONFIG_DIRenvironment variable to use a custom location.
Windows migration: If upgrading from plugin v1.3.x or earlier, the plugin will automatically find your existing config in
%APPDATA%\opencode\and use it. New installations use~/.config/opencode/.
Multi-Account Auth Issues
If you encounter authentication issues with multiple accounts:
- Delete the accounts file:
rm ~/.config/opencode/antigravity-accounts.json - Re-authenticate:
opencode auth login
403 Permission Denied (rising-fact-p41fc)
Error:
Permission 'cloudaicompanion.companions.generateChat' denied on resource
'//cloudaicompanion.googleapis.com/projects/rising-fact-p41fc/locations/global'Cause: The plugin falls back to a default project ID when no valid project is found. This works for Antigravity but fails for Gemini CLI models.
Solution:
- Go to Google Cloud Console
- Create or select a project
- Enable the Gemini for Google Cloud API (
cloudaicompanion.googleapis.com) - Add
projectIdto your accounts file:{ "accounts": [ { "email": "[email protected]", "refreshToken": "...", "projectId": "your-project-id" } ] }
Note: Do this for each account in a multi-account setup.
Gemini Model Not Found
Add this to your google provider config:
{
"provider": {
"google": {
"npm": "@ai-sdk/google",
"models": { ... }
}
}
}Gemini 3 Models 400 Error ("Unknown name 'parameters'")
Error:
Invalid JSON payload received. Unknown name "parameters" at 'request.tools[0]'Causes:
- Tool schema incompatibility with Gemini's strict protobuf validation.
- MCP servers with malformed schemas.
- Plugin version regression.
Solutions:
Update to latest beta:
{ "plugin": ["narlyse-ag@beta"] }Disable MCP servers one-by-one to find the problematic one.
Add npm override:
{ "provider": { "google": { "npm": "@ai-sdk/google" } } }
MCP Servers Causing Errors
Some MCP servers have schemas incompatible with Antigravity's strict JSON format.
Common symptom:
Invalid function name must start with a letter or underscoreSometimes it shows up as:
GenerateContentRequest.tools[0].function_declarations[12].name: Invalid function name must start with a letter or underscoreThis usually means an MCP tool name starts with a number (for example, a 1mcp key like 1mcp_*). Rename the MCP key to start with a letter (e.g., gw) or disable that MCP entry for Antigravity models.
Diagnosis:
- Disable all MCP servers in your config.
- Enable them one-by-one until the error reappears.
- Report the specific MCP in a GitHub issue.
"All Accounts Rate-Limited" (But Quota Available)
Cause: A cascade bug in clearExpiredRateLimits() in hybrid mode (fixed in recent beta).
Solutions:
- Update to the latest beta version.
- If it persists, delete the accounts file and re-authenticate.
- Try switching
account_selection_strategyto"sticky"inantigravity.json.
Session Recovery
If you encounter errors during a session:
- Type
continueto trigger the recovery mechanism. - If blocked, use
/undoto revert to the pre-error state. - Retry the operation.
Using with Oh-My-OpenCode
Important: Disable the built-in Google auth to prevent conflicts:
// ~/.config/opencode/oh-my-opencode.json
{
"google_auth": false,
"agents": {
"frontend-ui-ux-engineer": { "model": "google/gemini-3.1-pro" },
"document-writer": { "model": "google/gemini-3-flash" },
"multimodal-looker": { "model": "google/gemini-3-flash" }
}
}Infinite .tmp Files Created
Cause: When an account is rate-limited and the plugin retries infinitely, it creates many temporary files.
Workaround:
- Stop OpenCode.
- Clean up:
rm ~/.config/opencode/*.tmp. - Add more accounts or wait for the rate limit to expire.
OAuth Callback Issues
Symptoms:
- "fail to authorize" after successful Google login
- Safari shows "Safari can't open the page"
Cause: Safari's "HTTPS-Only Mode" blocks the http://localhost callback.
Solutions:
Use Chrome or Firefox (easiest): Copy the OAuth URL and paste it into a different browser.
Disable HTTPS-Only Mode temporarily:
- Safari > Settings (Cmd + ,) > Privacy
- Uncheck "Enable HTTPS-Only Mode"
- Run
opencode auth login - Re-enable after authentication
macOS / Linux:
# Find process using the port
lsof -i :51121
# Kill if stale
kill -9 <PID>
# Retry
opencode auth loginWindows (PowerShell):
netstat -ano | findstr :51121
taskkill /PID <PID> /F
opencode auth loginOAuth callback requires the browser to reach localhost on the machine running OpenCode.
WSL2:
- Use VS Code's port forwarding, or
- Configure Windows to WSL port forwarding
SSH / Remote:
ssh -L 51121:localhost:51121 user@remoteDocker / Containers:
- OAuth with localhost redirect does not work in containers.
- Wait 30s for the manual URL flow, or use SSH port forwarding.
Configuration Key Typo: plugin not plugins
The correct key is plugin (singular):
{
"plugin": ["narlyse-ag@beta"]
}Not "plugins" (will cause an "Unrecognized key" error).
Migrating Accounts Between Machines
When copying antigravity-accounts.json to a new machine:
- Ensure the plugin is installed:
"plugin": ["narlyse-ag@beta"] - Copy
~/.config/opencode/antigravity-accounts.json - If you get an "API key missing" error, the refresh token may be invalid. You will need to re-authenticate.
Known Plugin Interactions
For details on load balancing, dual quota pools, and account storage, see docs/MULTI-ACCOUNT.md.
Plugin Compatibility
@tarquinen/opencode-dcp
DCP creates synthetic assistant messages that lack thinking blocks. List this plugin BEFORE DCP:
{
"plugin": [
"narlyse-ag@latest",
"@tarquinen/opencode-dcp@latest"
]
}oh-my-opencode
Disable built-in auth and override agent models in oh-my-opencode.json:
{
"google_auth": false,
"agents": {
"frontend-ui-ux-engineer": { "model": "google/antigravity-gemini-3.1-pro" },
"document-writer": { "model": "google/antigravity-gemini-3-flash" },
"multimodal-looker": { "model": "google/antigravity-gemini-3-flash" }
}
}Tip: When spawning parallel subagents, enable
pid_offset_enabled: trueinantigravity.jsonto distribute sessions across accounts.
Plugins you do not need
- gemini-auth plugins: Not needed. This plugin handles all Google OAuth.
Configuration
Create ~/.config/opencode/antigravity.json for optional settings:
{
"$schema": "https://raw.githubusercontent.com/narlyseorg/narlyse-ag/main/assets/antigravity.schema.json"
}Most users do not need to configure anything. The defaults work well.
Model Behavior
| Option | Default | What it does |
|--------|---------|--------------
| keep_thinking | false | Preserve Claude's thinking across turns. Warning: enabling may degrade model stability. |
| session_recovery | true | Auto-recover from tool errors |
| cli_first | false | Route Gemini models to Gemini CLI first (Claude and image models stay on Antigravity). |
Account Rotation
| Your Setup | Recommended Config |
|------------|-------------------|
| 1 account | "account_selection_strategy": "sticky" |
| 2-5 accounts | Default ("hybrid") works great |
| 5+ accounts | "account_selection_strategy": "round-robin" |
| Parallel agents | Add "pid_offset_enabled": true |
Quota Protection
| Option | Default | What it does |
|--------|---------|--------------|
| soft_quota_threshold_percent | 90 | Skip account when quota usage exceeds this percentage. Prevents Google from penalizing accounts that fully exhaust quota. Set to 100 to disable. |
| quota_refresh_interval_minutes | 15 | Background quota refresh interval. After successful API requests, refreshes quota cache if older than this interval. Set to 0 to disable. |
| soft_quota_cache_ttl_minutes | "auto" | How long quota cache is considered fresh. "auto" = max(2 * refresh interval, 10 minutes). Set a number (1-120) for fixed TTL. |
How it works: Quota cache is refreshed automatically after API requests (when older than
quota_refresh_interval_minutes) and manually via "Check quotas" inopencode auth login. The threshold check usessoft_quota_cache_ttl_minutesto determine cache freshness. If the cache is older, the account is considered "unknown" and allowed (fail-open). When ALL accounts exceed the threshold, the plugin waits for the earliest quota reset time (like rate limit behavior). If the wait time exceedsmax_rate_limit_wait_seconds, it errors immediately.
Rate Limit Scheduling
Control how the plugin handles rate limits:
| Option | Default | What it does |
|--------|---------|--------------|
| scheduling_mode | "cache_first" | "cache_first" = wait for same account (preserves prompt cache), "balance" = switch immediately, "performance_first" = round-robin |
| max_cache_first_wait_seconds | 60 | Max seconds to wait in cache_first mode before switching accounts |
| failure_ttl_seconds | 3600 | Reset failure count after this many seconds (prevents old failures from permanently penalizing accounts) |
When to use each mode:
- cache_first (default): Best for long conversations. Waits for the same account to recover, preserving your prompt cache.
- balance: Best for quick tasks. Switches accounts immediately when rate-limited for maximum availability.
- performance_first: Best for many short requests. Distributes load evenly across all accounts.
App Behavior
| Option | Default | What it does |
|--------|---------|--------------|
| quiet_mode | false | Hide toast notifications |
| debug | false | Enable debug logging |
| auto_update | true | Auto-update plugin |
For all options, see docs/CONFIGURATION.md.
Environment variables:
OPENCODE_CONFIG_DIR=/path/to/config opencode # Custom config directory
OPENCODE_ANTIGRAVITY_DEBUG=1 opencode # Enable debug logging
OPENCODE_ANTIGRAVITY_DEBUG=2 opencode # Verbose loggingTroubleshooting
See the full Troubleshooting Guide for solutions to common issues including:
- Auth problems and token refresh
- "Model not found" errors
- Session recovery
- Gemini CLI permission errors
- Safari OAuth issues
- Plugin compatibility
- Migration guides
Documentation
- Configuration - All configuration options
- Multi-Account - Load balancing, dual quota pools, account storage
- Model Variants - Thinking budgets and variant system
- Troubleshooting - Common issues and fixes
- Architecture - How the plugin works
- API Spec - Antigravity API reference
License
MIT License. See LICENSE for details.
Intended Use
- Personal or internal development only.
- Respect internal quotas and data handling policies.
- Not for production services or bypassing intended limits.
Warning
By using this plugin, you acknowledge:
- Terms of Service risk: This approach may violate ToS of AI model providers.
- Account risk: Providers may suspend or ban accounts.
- No guarantees: APIs may change without notice.
- Assumption of risk: You assume all legal, financial, and technical risks.
Disclaimer
- Not affiliated with Google. This is an independent open-source project.
- "Antigravity", "Gemini", "Google Cloud", and "Google" are trademarks of Google LLC.
