Gemini coding agent: API key, free tier and setup
Updated Fact-checked
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 Harness. 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 Harness | 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#
In the OpenCode terminal, enter /connect, select Google, and enter your Google AI Studio API key. Open /models to choose a Gemini model. For a Google Cloud project with Application Default Credentials, use the Vertex AI instructions. OpenCode install options · Provider setup
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 Harness#
Contenox Harness 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 Harness. If the status shows Key rejected, check that the key still exists in
AI Studio, then use Replace.
Related#
Vertex AIVertex AI coding agent: Claude Code, Codex, OpenCode setupRun a Vertex AI coding agent on your Google Cloud project: Claude Code, Codex CLI and OpenCode setup, the roles you need, global vs regional, and 403 fixes.
How to choose a model for codingHow to compare AI coding models on your own codebaseCompare AI coding models on five tasks from your repository. Score each run on passing tests, unnecessary edits, elapsed time and cost per finished task.
Keep secrets away from AI agentsHow to keep secrets away from AI agents (and out of git)How to keep secrets away from AI agents: block .env reads in Claude Code, OpenCode and Codex, stop keys leaking through commands, and what to do if one leaked.
AI coding costsAI coding costs: why agents burn tokens and how to cut itAI coding costs explained: why one agent session can send hundreds of millions of tokens, what sessions really cost, and the habits that cut the bill.
OpenRouter: one key for many model makersOpenRouter coding agent: Claude Code, Codex, OpenCode setupUse OpenRouter with a coding agent: setup for Claude Code, Codex CLI and OpenCode, a capped API key, models that call tools well, and 401 and 402 fixes.
ChatGPT subscriptionUse your ChatGPT subscription for a coding agent | ContenoxUse your ChatGPT subscription for a coding agent. Set up device sign-in in Contenox or use Codex on desktop, in an editor or in the terminal. Check plan limits.
GitHub Copilot subscriptionUse your GitHub Copilot subscription in other coding agentsUse your GitHub Copilot subscription outside VS Code: sign-in steps for OpenCode, Codex and Contenox Harness, which plans you need, and how AI Credits are billed.
Anthropic (Claude)Claude coding agent on Windows: API key setup | ContenoxRun a Claude coding agent on Windows: Claude Code with a subscription or API key, OpenCode with a key, why Codex can't, plus models, billing and key errors.
DeepSeekDeepSeek coding agent: API key, models and setup | ContenoxSet up a DeepSeek coding agent: DeepSeek Harness, or your API key in OpenCode, Codex CLI, Claude Code or Contenox Harness, plus models, errors and where your code goes.