Skip to content

Repository files navigation

pi-agy-provider

Warning

Work in Progress — Proof of Concept

This extension is under active development. The agy OAuth auto-detection and token refresh have known issues on some setups. For a stable Antigravity OAuth experience with Gemini 3 models, Claude, and GPT-OSS, use below extension:

pi install npm:@yofriadi/pi-antigravity-oauth

That extension performs a full PKCE OAuth dance with proper refresh token support and provides access to 16+ models including Gemini 3.5 Flash, Claude Opus/Sonnet, and GPT-OSS.

npm npm downloads License CI

pi provider for Google Antigravity — run Gemini models in pi using your existing agy CLI login or a Gemini API key.

This extension registers provider agy and connects pi to Google's OpenAI-compatible Gemini endpoint. If you already use the Antigravity CLI (agy), pi picks up your OAuth token automatically — no duplicate sign-in.

Why use this

  • Same credentials as Antigravity — reuses agy OAuth from ~/.gemini/
  • Full pi integration — streaming, tool calls, usage tracking via openai-completions
  • Flexible authagy OAuth, GEMINI_API_KEY, or pi /login
  • Live model list — fetches models from the API at startup, with a static fallback

Quick start

# Install
pi install npm:pi-agy-provider

# Run (OAuth if agy is already logged in, otherwise set GEMINI_API_KEY)
pi --model agy/gemini-3.5-flash -p "Explain async/await in JavaScript"

Requirements: pi and either:

  1. agy CLI signed in with your Google account, or
  2. A Gemini API key from Google AI Studio

Installation

# npm registry (recommended)
pi install npm:pi-agy-provider

# git
pi install git:github.com/jellydn/pi-agy-provider

# local path
pi install /path/to/pi-agy-provider

As an npm package (requires peer deps @earendil-works/pi-ai and @earendil-works/pi-coding-agent):

npm install pi-agy-provider

Quick test without installing:

pi -e /path/to/pi-agy-provider --model agy/gemini-3.5-flash

Authentication

Credentials are resolved in this order:

Priority Source Notes
1 GEMINI_API_KEY env var Long-lived; best for extended sessions
2 GOOGLE_API_KEY env var Alternate env name used by some Google SDKs
3 agy OAuth token From macOS Keychain (security find-generic-password -s "gemini"). Refresh supported.
4 ~/.pi/agent/auth.json pi-stored key or OAuth object

Option A: agy CLI (experimental)

If you use Google Antigravity, sign in once with the agy CLI. This extension reads that token from the macOS Keychain automatically.

agy   # sign in if you haven't already
pi /login   # select "Google Gemini (agy)" — auto-detects Keychain token

Note: agy OAuth token refresh requires the Antigravity OAuth client credentials to be correctly configured. If auto-login doesn't work, use Option B or the recommended @yofriadi/pi-antigravity-oauth extension.

Option B: Static API key (recommended for this provider)

export GEMINI_API_KEY="your_key_here"   # from aistudio.google.com/apikey

Or run pi /loginGoogle Gemini (agy). If no agy login is found, it opens Google AI Studio and prompts you to paste a key.

Note: agy OAuth token refresh requires the Antigravity OAuth client credentials (ANTIGRAVITY_CLIENT_ID). If auto-login doesn't work, use a static API key or the recommended @yofriadi/pi-antigravity-oauth extension.

Usage

# Non-interactive
pi --model agy/gemini-3.5-flash -p "Summarize this repo"

# Interactive
pi --model agy/gemini-3.1-pro-preview

# List models
pi --list-models agy

# In another project
cd my-project
pi --model agy/gemini-3.5-flash --trust "Refactor the auth module"

Switch models in-session: /model agy/gemini-3.5-flash

Supported models

Model Model ID Context Max output
Gemini 3.5 Flash gemini-3.5-flash 1M 65,536
Gemini 3.1 Pro gemini-3.1-pro-preview 1M 65,536

Model IDs match the Gemini API. In pi, prefix with agy/ (e.g. agy/gemini-3.5-flash).

Configuration

Variable Default Purpose
GEMINI_API_KEY Primary API key
GOOGLE_API_KEY Alternate API key env var
GEMINI_API_BASE https://generativelanguage.googleapis.com/v1beta/openai Override API endpoint

Pricing for usage tracking follows Google Gemini API pricing.

Development

npm install
npm test              # unit tests (Vitest)
npm run test:e2e      # smoke test (needs GEMINI_API_KEY + pi)
npm run lint
npm run typecheck
prek install          # pre-commit hooks

License

MIT — see LICENSE.

Changelog

See CHANGELOG.md.

Author

👤 Huynh Duc Dung

Show your support

Give a ⭐️ if this project helped you!

ko-fi PayPal Buy Me a Coffee

About

Pi provider for Google Antigravity

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages