All resources
Guide/8 min read

Gemini CLI, Antigravity and API keys: what Google allows in other tools

Published

Summary

Google's terms bar Pi, OpenCode and other agents from using a Gemini CLI or Antigravity login. Which Gemini key works where, the cost, and Gemini 4 Neon in Pi.

Google's terms say third-party tools can't use the Google sign-in from Gemini CLI or Antigravity. That covers coding agents such as Pi, OpenCode, Claude Code and OpenClaw, and hosted services that run them for you. Google's own FAQs name the alternative: an API key from Google AI Studio, Vertex AI or Gemini Enterprise.

This guide quotes what Google's pages say, shows which Gemini credential works where and what each costs, and covers which Gemini models, including the new Gemini 4 Neon, you can run in Pi with an API key. We checked every source on November 21, 2026.

What Google's terms say

Google says this in four places. The Gemini CLI terms and privacy page:

Directly accessing the services powering Gemini CLI (for example, the Gemini Code Assist service) using third-party software, tools, or services (for example, using OpenClaw with Gemini CLI OAuth) is a violation of applicable terms and policies. Such actions may be grounds for suspension or termination of your account.

The Gemini CLI FAQ:

Using third-party software, tools, or services to harvest or piggyback on Gemini CLI's OAuth authentication to access our backend services is a direct violation of our applicable terms and policies. [...] If you would like to use a third-party coding agent with Gemini, the supported and secure method is to use a Vertex AI or Google AI Studio API key.

The Google Antigravity Additional Terms of Service:

Using third party software, tools, or services to access the Service (e.g. using OpenClaw with Antigravity OAuth) is a breach of this Agreement. Such actions may be grounds for suspension or termination of your Antigravity and/or Gemini CLI accounts.

And the Antigravity FAQ:

Using third-party software, tools, or services to access Antigravity is a violation of our Terms of Service [...]. To use a third-party coding agent with Gemini, we recommend using a Gemini Enterprise or Google AI Studio API key.

The same FAQ adds that wrapping Antigravity CLI inside other agents isn't supported on consumer plans: "Wrapping agy inside third-party coding agents or applications, or automating account rotation, is not supported under consumer plans."

All of these are about the Google account sign-in (OAuth). None of them restricts API keys, and none says you can't run Google's own tools on a cloud machine. Google documents Remote Control for driving Antigravity on "your own desktop workstation or server", and headless mode (agy -p) for scripts and CI.

For most people, the Antigravity rules are the ones that apply, because Google moved free and Google AI Pro and Ultra users from Gemini CLI to Antigravity. Google's transition post says that on June 18, 2026, "Gemini CLI and Gemini Code Assist IDE extensions will stop serving requests for Google AI Pro and Ultra, as well as those using it free of charge", and that "Gemini CLI will remain accessible via paid Gemini and Gemini Enterprise Agent Platform API keys."

Which Gemini credential works where

CredentialIn Google's own toolsIn Pi, OpenCode or another third-party agentHow it's billed
Google account on a free, Google AI Pro or Ultra planAntigravity app and CLI. Gemini CLI stopped serving these plans on June 18, 2026No. Google's terms call it a breachPlan quota, no per-token bill
Google account with Gemini Code Assist Standard or EnterpriseGemini CLINo. Gemini CLI's terms bar third-party access to Code AssistYour organization's license
Google AI Studio API key (Gemini API)Gemini CLI, with a paid keyYes. Google recommends itPer token. Some models have a free tier
Google Cloud project (Vertex AI)Gemini CLI, and Antigravity's Pay As You Go sign-inYes. Google names Vertex AI and Gemini Enterprise keysPer token, on your Google Cloud bill

Google's Cloud docs now list Vertex AI under Gemini Enterprise Agent Platform. Sources: Gemini CLI authentication methods, Gemini CLI README, Antigravity FAQ and Antigravity pricing.

Free-tier API keys come with a data trade-off. Google's Gemini API terms say that on unpaid services Google uses your prompts and responses to improve its products and human reviewers may read them: "Do not submit sensitive, confidential, or personal information to the Unpaid Services." On paid services, Google says it doesn't use prompts or responses to improve its products. For a private repository, use a key on a Cloud project with billing turned on.

Gemini models you can run in Pi

Pi is an open-source coding agent that works with many model providers. Its provider docs list Google Gemini with the GEMINI_API_KEY environment variable, and Vertex AI with GOOGLE_CLOUD_API_KEY or a Google Cloud project. Pi removed its built-in Gemini CLI and Antigravity logins in version 0.71.0, so an API key is the Gemini route it ships with.

These are the Gemini models Google suggests for coding, with Google's own summary of each:

ModelID in PiPaid tier, per 1M tokens (input / output)Free tierWhat Google says it's for
Gemini 4 Hydrogengemini-4-hydrogen$1.50 / $7.50Yes"Fast and cost-efficient for everyday coding and agentic workflows"
Gemini 4 Neongemini-4-neon$3.00 / $15.00No"Built for complex, interactive software engineering, dense knowledge work, and science workflows"
Gemini 4 Carbongemini-4-carbon$2.00 / $10.00, then $4.00 / $20.00 from December 1, 2026No"Built for long-horizon asynchronous work and deep verification"
Gemini 3.8 Flashgemini-3.8-flash$0.75 / $3.75, then $1.50 / $7.50 from January 1, 2027Yes"Our most intelligent Flash model, engineered for long-horizon software engineering, autonomous agents, and complex enterprise workflows"

Sources: Google's Choosing a model guide and Gemini API pricing. Pi 1.6.0 lists all four IDs under its google provider; we checked its model list.

Gemini 4 Neon

Google announced Gemini 4 Neon on November 18, 2026. Google's guide places it between Hydrogen and Carbon: Neon "delivers deeper reasoning than Hydrogen while finishing faster with fewer output tokens than Carbon", and Google suggests it "for multi-file refactoring, repository-wide debugging, and analytical tasks where a developer or coding agent is waiting on the response."

Neon is only on the paid tier of the Gemini API. It has a 1M-token context window and four thinking levels: low, medium, high (the default) and xhigh (model page). It's also generally available on Google Cloud under the same ID (Google Cloud model page).

Pi 1.6.0, released November 20, 2026, lists gemini-4-neon for both its google and google-vertex providers. Pi 1.5.2 doesn't, so update Pi if Neon is missing from pi --list-models.

How we tested

An AI agent working in a Replicas workspace did the research and the test runs on November 21, 2026, and a person on our team reviewed this guide before it was published. Replicas is our product.

We gave Pi one small task on a scratch copy of an open-source voting app, with no customer data in it:

We ran it in Replicas' built-in Pi agent, once on Gemini 3.8 Flash and once on Gemini 4 Neon, each in its own cloud workspace. We used a development build of Replicas, and the requests went to Google's models through OpenRouter, the route Replicas supports for Gemini today. We didn't have a Google AI Studio key for this test, so we didn't run the standalone setup below end to end. We did check that Pi 1.6.0 lists the models in the table.

Gemini 3.8 FlashGemini 4 Neon
Time from request to final answer3 min 15 s1 min 23 s
Input tokens, not cached246,01750,995
Cached input tokens1,062,890239,674
Output tokens13,0613,647
Shell commands run5515
Model cost at list prices$0.31$0.24

Both runs found that the app already read OPTION_A and OPTION_B, left the code alone, added two lines to the README and ran the app's tests. Neon's README note was right. Flash's note included the example OPTION_A=Tacos OPTION_B=Burritos docker compose up, which wouldn't work, because the app's docker-compose.yml doesn't pass those variables to the vote container. Neon costs four times as much per token, but it used far fewer tokens on this task, so the run cost less. This is one run per model, not a benchmark.

Run Pi with a Gemini API key on a cloud machine

Use this on a cloud VM or dev box you control. You need Node.js 22.19 or newer and a Gemini API key from Google AI Studio. Neon needs a key on the paid tier.

Install Pi with its documented npm command, then enter the key without saving it in your shell history:

Start Pi in your repository with the model you want:

For a Google Cloud project instead, Pi's provider docs use GOOGLE_CLOUD_API_KEY, or GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION with Application Default Credentials, and the google-vertex provider. For a long session over SSH, run Pi inside tmux so it keeps going when you disconnect.

The same rule applies to OpenCode and every other third-party agent: give it an API key, not your Google sign-in. For how Pi and OpenCode compare, see Pi vs OpenCode. For other ways to keep an agent running off your laptop, see running Claude Code and Codex in the cloud.

What each route costs

RouteWhat you payFees on top
Google AI Pro or Ultra in Antigravity, Google's own apps onlyA Google AI plan subscriptionOptional AI credit overages above the plan's quota (Antigravity pricing)
Gemini API key in PiGoogle's per-token price, from the model table aboveNone
Google Cloud project in PiGoogle Cloud's per-token priceNone
OpenRouter key in PiGoogle's per-token price5.5% when you buy credits. With your own Google key (BYOK), free up to $25,000 of usage a month, then 5% (OpenRouter FAQ)
Pi on ReplicasYour model provider bills tokens. Replicas bills the workspace by the minute$0.004 to $0.016 a minute while awake, by size (Replicas billing)

Gemini in Pi on Replicas, and its limits

Replicas runs Pi in a cloud workspace with your repository checked out, so it keeps working when your laptop is closed. Here is what it supports for Gemini today:

  • No direct Google key yet. Replicas' Pi connects through OpenCode Go, Aster, OpenRouter, an OpenAI-compatible endpoint or Ollama (Pi on Replicas). There's no setting for a Google AI Studio or Google Cloud key.
  • Gemini comes through OpenRouter. Gemini 3.8 Flash is in Pi's default OpenRouter models, and admins can turn on others, such as google/gemini-4-neon, under Pi → OpenRouter models. To keep the token bill on your own Google account, add your AI Studio key to OpenRouter as a BYOK key.
  • OpenCode Go and Aster go first. If your organization also has one of those keys, Pi uses it before OpenRouter (credential order).
  • The OpenAI-compatible option doesn't take a Gemini key. It calls the OpenAI Responses API, which Google's OpenAI-compatible endpoint doesn't offer. A request to it returned 404 in our test.
  • No Gemini CLI or Antigravity. Replicas doesn't run Google's own agents, and it doesn't use your Google account sign-in.

If you want Pi on Gemini running in the cloud with the rest of your agents, try Replicas with $100 of free usage. For which other cloud agents take your own key, see cloud coding agents that use your own API key.

FAQ

Frequently asked questions