To set up a Gemini coding agent, create an API key in Google AI Studio and give it to an agent that speaks Gemini: OpenCode, Google’s own Antigravity CLI, or Contenox. Claude Code and Codex CLI can’t use it. A key works on the free tier straight away, but agent work hits free-tier limits quickly, and Google may use free-tier prompts to improve its products. For your own code, turn on billing first.
Use Gemini with your agent
| Agent | Supported? | How | Note |
|---|---|---|---|
| Claude Code | No | Claude Code runs Claude models only, through Anthropic, Amazon Bedrock, Google Cloud’s Agent Platform (Vertex AI) or Microsoft Foundry. Anthropic doesn’t support routing it to other models. | |
| Codex CLI | No | Codex talks to custom providers through the OpenAI Responses API only. Gemini’s OpenAI compatibility documents Chat Completions, not Responses. | |
| OpenCode | Yes | /connect → Google → paste the key |
Also reads GEMINI_API_KEY from the environment. |
| Antigravity CLI | Yes | agy, then sign in with Google or a Gemini API key |
Google’s own agent. Replaced Gemini CLI for individual accounts. |
| Contenox | Yes | Backends → Providers → Gemini |
Free tier or paid?
| Free tier | Paid tier | |
|---|---|---|
| Cost | Nothing | Per token, billed to the Google Cloud billing account on your project |
| Limits | Low; an agent can hit them within a few steps | Higher, and they rise as you spend more |
| Models | Flash and Flash-Lite models; not the top models | All models |
| Your prompts | May be used to improve Google’s products; human reviewers may read them | Not used to improve Google’s products |
Google’s terms say not to send sensitive or confidential information to the free tier. A codebase usually counts. In the EEA, Switzerland and the UK, Google applies its paid-tier data rules to free usage as well.
To move to paid, set up billing for your project in AI Studio. Your project’s tier is on the AI Studio Projects page.
OpenCode
Install it. On Windows, OpenCode recommends WSL; natively, use npm:
npm install -g opencode-ai
macOS or Linux:
curl -fsSL https://opencode.ai/install | bash
Start opencode in your project, type /connect, choose Google and paste your AI
Studio key. Pick a Gemini model with /models. The key is saved in
~/.local/share/opencode/auth.json.
The Vertex trap: OpenCode also lists Vertex. That one uses Google Cloud credentials, not an AI Studio key. Pick Google for a key.
Antigravity CLI
Install it. Windows PowerShell:
irm https://antigravity.google/cli/install.ps1 | iex
macOS or Linux:
curl -fsSL https://antigravity.google/cli/install.sh | bash
Run agy --version to check, then agy in your project. Sign in with a Google account
(personal Free, Pro and Ultra plans) or use a Gemini API key.
Since 18 June 2026, Gemini CLI no longer serves free individual, Google AI Pro or Ultra accounts; those moved to Antigravity CLI. Gemini CLI still works with Gemini Code Assist Standard and Enterprise licenses and with paid Gemini API keys.
Which Gemini model should I pick?
Google’s models page describes Gemini 3.8 Flash as built for long software engineering tasks and autonomous agents, and recommends it for new projects. Gemini 4 Argon is Google’s flagship reasoning model; the pricing page lists it as paid tier only. Flash-Lite models are cheaper and faster, and fit small edits better than multi-file changes.
Why do I get 429 errors?
A 429 (often RESOURCE_EXHAUSTED) means your project hit a rate limit. It is the most
common Gemini problem with agents, because one task sends many requests in a row.
- Limits are per project, not per key. A second key in the same project adds nothing.
- Daily limits reset at midnight Pacific time.
- Turn on billing to leave the free tier. The first upgrade is usually immediate.
- Check your active limits on the AI Studio rate limit page.
Current numbers are on Google’s rate limits and pricing pages.
AI Studio key or Vertex AI?
Use an AI Studio key for yourself or a small team. If your company already runs on Google Cloud and wants usage under its Cloud project, permissions and contracts, use Vertex AI instead.
Contenox
Contenox takes the same AI Studio key and lets you switch between Gemini and other providers per session.
- Open Backends → Providers and, under Recommended, choose Gemini.
- Select Create key, create a key in Google AI Studio and copy it.
- Paste it into API Key, select Connect and wait for Connected.
- Pick a Gemini model in the Model chip on the message box.
To keep the key out of the app, enter GEMINI_API_KEY under Advanced in
Environment variable name, set it with setx GEMINI_API_KEY "your-key-here", and
reopen Contenox. If the status shows Key rejected, check that the key still exists in
AI Studio, then use Replace.
Related
- Vertex AI
- How to choose a model for coding
- Keep secrets away from AI agents
- AI coding costs
- OpenRouter: one key for many model makers