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

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.

- Published: 2026-11-21
- Canonical: https://replicas.dev/resources/gemini-cli-api-key

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](https://geminicli.com/docs/resources/tos-privacy/):

> 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](https://geminicli.com/docs/resources/faq/#why-cant-i-use-third-party-software-like-claude-code-openclaw-or-opencode-with-gemini-cli):

> 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](https://antigravity.google/terms):

> 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](https://antigravity.google/docs/faq#why-cant-i-use-third-party-software-such-as-claude-code-openclaw-or-opencode-with-my-antigravity-login):

> 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](https://antigravity.google/docs/faq#can-i-use-antigravity-cli-headless-mode-in-third-party-coding-agents-or-automate-account-switching) 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](https://antigravity.google/docs/remote-control) for driving Antigravity on "your own desktop workstation or server", and [headless mode](https://antigravity.google/docs/cli/headless) (`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](https://developers.googleblog.com/an-important-update-transitioning-gemini-cli-to-antigravity-cli/) 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

| Credential | In Google's own tools | In Pi, OpenCode or another third-party agent | How it's billed |
|---|---|---|---|
| Google account on a free, Google AI Pro or Ultra plan | Antigravity app and CLI. Gemini CLI stopped serving these plans on June 18, 2026 | No. Google's terms call it a breach | Plan quota, no per-token bill |
| Google account with Gemini Code Assist Standard or Enterprise | Gemini CLI | No. Gemini CLI's terms bar third-party access to Code Assist | Your organization's license |
| Google AI Studio API key (Gemini API) | Gemini CLI, with a paid key | Yes. Google recommends it | Per token. Some models have a free tier |
| Google Cloud project (Vertex AI) | Gemini CLI, and Antigravity's [Pay As You Go](https://antigravity.google/docs/pay-as-you-go) sign-in | Yes. Google names Vertex AI and Gemini Enterprise keys | Per token, on your Google Cloud bill |

Google's Cloud docs now list Vertex AI under Gemini Enterprise Agent Platform. Sources: [Gemini CLI authentication methods](https://geminicli.com/docs/resources/tos-privacy/), [Gemini CLI README](https://github.com/google-gemini/gemini-cli#readme), [Antigravity FAQ](https://antigravity.google/docs/faq) and [Antigravity pricing](https://antigravity.google/pricing).

Free-tier API keys come with a data trade-off. Google's [Gemini API terms](https://ai.google.dev/gemini-api/terms#unpaid-services) 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](https://pi.dev) is an open-source coding agent that works with many model providers. Its [provider docs](https://docs.pi.dev/latest/providers) 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](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/CHANGELOG.md), 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:

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

Sources: Google's [Choosing a model](https://ai.google.dev/gemini-api/docs/choosing-a-model) guide and [Gemini API pricing](https://ai.google.dev/gemini-api/docs/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](https://blog.google/innovation-and-ai/models-and-research/gemini-models/introducing-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](https://ai.google.dev/gemini-api/docs/models/gemini-4-neon)). It's also generally available on Google Cloud under the same ID ([Google Cloud model page](https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/gemini/4-neon)).

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:

```text
In the vote app, find where the two voting options (Cats and Dogs) are defined.
Make them configurable through the OPTION_A and OPTION_B environment variables if
they are not already, keep the current values as defaults, and add two lines to
the README explaining how to change them. Run any quick check you can. Do not open
a pull request.
```

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 Flash | Gemini 4 Neon |
|---|---:|---:|
| Time from request to final answer | 3 min 15 s | 1 min 23 s |
| Input tokens, not cached | 246,017 | 50,995 |
| Cached input tokens | 1,062,890 | 239,674 |
| Output tokens | 13,061 | 3,647 |
| Shell commands run | 55 | 15 |
| 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](https://aistudio.google.com/apikey). Neon needs a key on the paid tier.

Install Pi with its [documented npm command](https://github.com/earendil-works/pi/tree/main/packages/coding-agent#readme), then enter the key without saving it in your shell history:

```bash
npm install -g --ignore-scripts @earendil-works/pi-coding-agent
read -rsp 'Gemini API key: ' GEMINI_API_KEY; printf '\n'
export GEMINI_API_KEY
pi --list-models gemini
```

Start Pi in your repository with the model you want:

```bash
cd /path/to/your/repository
pi --provider google --model gemini-4-neon
```

For a Google Cloud project instead, Pi's [provider docs](https://docs.pi.dev/latest/providers) 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](/resources/pi-vs-opencode). For other ways to keep an agent running off your laptop, see [running Claude Code and Codex in the cloud](/resources/claude-code-in-the-cloud).

## What each route costs

| Route | What you pay | Fees on top |
|---|---|---|
| Google AI Pro or Ultra in Antigravity, Google's own apps only | A [Google AI plan](https://one.google.com/about/google-ai-plans/) subscription | Optional AI credit overages above the plan's quota ([Antigravity pricing](https://antigravity.google/pricing)) |
| Gemini API key in Pi | Google's per-token price, from the model table above | None |
| Google Cloud project in Pi | Google Cloud's per-token price | None |
| OpenRouter key in Pi | Google's per-token price | 5.5% when you buy credits. With your own Google key (BYOK), free up to $25,000 of usage a month, then 5% ([OpenRouter FAQ](https://openrouter.ai/docs/faq#pricing-and-fees)) |
| Pi on Replicas | Your model provider bills tokens. Replicas bills the workspace by the minute | $0.004 to $0.016 a minute while awake, by size ([Replicas billing](https://docs.replicas.dev/admin/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](https://docs.replicas.dev/features/coding-agents/pi)). 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](https://openrouter.ai/docs/guides/overview/auth/byok).
- **OpenCode Go and Aster go first.** If your organization also has one of those keys, Pi uses it before OpenRouter ([credential order](https://docs.replicas.dev/admin/credentials)).
- **The OpenAI-compatible option doesn't take a Gemini key.** It calls the OpenAI Responses API, which Google's [OpenAI-compatible endpoint](https://ai.google.dev/gemini-api/docs/openai) 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](https://app.replicas.dev). For which other cloud agents take your own key, see [cloud coding agents that use your own API key](/resources/coding-agents-bring-your-own-key).


## FAQ

### Can I use my Gemini CLI or Antigravity login in Pi, OpenCode or Claude Code?
No. Google's Gemini CLI terms and the Google Antigravity Additional Terms say using third-party software, tools, or services with that Google sign-in breaks the terms and may get the account suspended or terminated. Google's FAQs say to use a Google AI Studio, Vertex AI or Gemini Enterprise API key with third-party coding agents instead.

### Can I run Gemini CLI or Antigravity CLI on a cloud server?
Google's terms are about third-party tools using its sign-in, not about where Google's own CLI runs. Google documents headless mode for scripts and CI, and Remote Control for your own server. Since June 18, 2026, Gemini CLI is for Gemini Code Assist Standard or Enterprise and paid API keys, and free and Google AI Pro or Ultra users have moved to Antigravity CLI.

### What is Gemini 4 Neon?
A Gemini model Google announced on November 18, 2026, with the model ID gemini-4-neon. Google places it between Gemini 4 Hydrogen and Gemini 4 Carbon for complex, interactive software engineering. It is only on the paid tier of the Gemini API, at $3 per million input tokens and $15 per million output tokens, and Pi 1.6.0 lists it.

### Can I use a Gemini API key with Pi on Replicas?
Not directly yet. Pi on Replicas reaches Gemini models through OpenRouter, including Gemini 3.8 Flash by default and Gemini 4 Neon once an admin turns it on. To bill your own Google account, add your Google AI Studio key to OpenRouter as a BYOK key.
