Gemini API CLI: Give Claude Code and Codex Gemini 4 Neon

Install and configure Google's experimental Gemini API CLI for existing coding agents. Verify authentication, select Gemini 4 Neon instead of the Hydrogen default, add reusable instructions to AGENTS.md or CLAUDE.md, and choose another API route when Google AI Studio does not support your region.

Contents
Gemini API CLI: Give Claude Code and Codex Gemini 4 Neon

If you already use Claude Code or Codex, you can add Google’s Gemini API CLI to give your coding agent access to Gemini models, image generation, and multimodal analysis. The open-source gemini-api binary runs as a shell command, so your existing agent does not need to become a Gemini-specific coding agent. Install it, configure GEMINI_API_KEY, and add its usage instructions to AGENTS.md or CLAUDE.md.

There is one important model-selection detail: the CLI defaults to gemini-4-hydrogen for text generation and analysis. If you want Gemini 4 Neon, select gemini-4-neon explicitly.

Google’s Gemini API team highlighted this workflow on November 25, 2026. The CLI itself is older: Google introduced its experimental preview on October 19, and its v0.5.0 release appeared on November 20.

Choose your API route first

The official CLI is useful when Google AI Studio can issue you an API key. If your account or region cannot obtain one, use another provider through a separately configured client integration.

RouteWhat you needWhen to choose it
Official Gemini API CLIGoogle AI Studio API key, supported region, and applicable API billing accessYou want Gemini models and media tools through one shell binary
Gemini Enterprise Agent PlatformGoogle Cloud access and an eligible project, with the platform’s authentication and setup requirementsYou want Google’s recommended alternative for locations outside the AI Studio region list
Independent API providerProvider account, separate API key, supported model, and compatible client protocolYou cannot use the official API or need another billing route

Google’s supported regions list determines whether the Gemini API and AI Studio are available in your location. Google recommends trying Gemini Enterprise Agent Platform when your location is outside that list. Its setup has separate Google Cloud project, authentication, and permission requirements.

An independent API provider is another option, but it does not automatically become a Gemini API CLI provider. The CLI documentation does not establish a supported arbitrary third-party Base URL configuration.

When choosing another provider, check its current model listing, API protocol, billing unit, and client integration before switching. A model being available through Chat Completions does not establish that it works through Anthropic Messages or Responses.

BetterToken API
Claude, GPT, Gemini, and DeepSeek with one API key
Text & code
ClaudeGPTGeminiDeepSeekGLMKimiQwenMiniMax+4
Video & images
SeedanceKlingWanHailuoGPT ImageNano Banana+2
  • One key for every model
  • Pay as you go, no subscription
  • OpenAI- and Anthropic-compatible

1. Install Gemini API CLI and put it on PATH

The official repository is google-gemini/gemini-api-cli. It distributes a standalone Go binary under the Apache-2.0 license.

The CLI supports macOS, Linux, and Windows. You do not need to clone the repository or install a Node.js package.

macOS and Linux (Bash):

curl -fsSL https://raw.githubusercontent.com/google-gemini/gemini-api-cli/main/scripts/install.sh | bash

Windows (PowerShell):

iwr -useb https://raw.githubusercontent.com/google-gemini/gemini-api-cli/main/scripts/install.ps1 | iex

Install with Go:

go install github.com/google-gemini/gemini-api-cli/cmd/gemini-api@latest

The Go installation uses the Go binary installation directory. Make sure that directory is included in your shell’s PATH.

Alternatively, download the prebuilt archive for your operating system from GitHub Releases. Extract the executable and place it in a directory already included in PATH.

Check that your shell can find the executable:

command -v gemini-api
gemini-api --help

On Windows, use:

Get-Command gemini-api
gemini-api --help

If the command cannot be found, reopen your terminal and check the installation directory. For a manual installation, add the executable’s directory to your shell’s PATH.

The CLI is still in beta. Breaking changes may occur between releases. Pin a specific release in CI and automated workflows instead of installing an unspecified latest version on every run.

2. Configure GEMINI_API_KEY and verify authentication

The CLI uses GEMINI_API_KEY to authenticate requests to Google’s Gemini API.

First, create an API key in Google AI Studio. Your Google account and project must meet the applicable access requirements.

For a temporary Bash session, read the key without echoing it:

read -rs GEMINI_API_KEY && export GEMINI_API_KEY

The value remains available to child processes launched from that shell. This matters because Claude Code and Codex need to inherit the environment variable when they execute gemini-api.

For persistent workstation configuration, use the interactive configuration command:

gemini-api configure --interactive

The documented persistent credential locations include the operating system’s keychain and:

~/.config/gemini-api/config.yaml

Avoid putting API keys in project instruction files, shell commands that enter shell history, or committed configuration files.

Check the configuration with whoami

Run:

gemini-api whoami

This command displays the active authentication and configuration information. Check whether the CLI recognizes the expected credential source.

However, whoami is a local configuration check. It does not prove that Google’s servers accept your key.

Validate a request with —dry-run

Use a harmless text-generation request:

gemini-api generate "Hello from my coding agent" --dry-run

The CLI validates the arguments and previews the resolved HTTP request. It redacts credentials and does not make a network request.

This confirms that your command and request parameters are valid. It does not establish API availability, billing eligibility, or successful authentication.

Make a real API request

Remove --dry-run:

gemini-api generate "Hello from my coding agent"

A normal generated response confirms that the CLI can reach the API and complete the request.

If the request fails, check the following:

  • Missing credentials: Run whoami and check the environment inherited by your shell.
  • Authentication failure: Confirm that GEMINI_API_KEY contains the intended key.
  • Region or project restrictions: Check the supported regions list and the project’s API access.
  • Model unavailable: Query the live model list before changing your command.

Do not treat a successful dry run as proof that any of these remote conditions are satisfied.

3. Give Claude Code and Codex reusable instructions

The main benefit of this CLI is that your existing coding agent can discover and execute its commands through the shell.

You do not need to install a separate Gemini coding agent or replace your existing workflow.

Google recommends putting instructions in AGENTS.md, CLAUDE.md, .cursorrules, or the relevant agent configuration.

For Codex, use AGENTS.md. For Claude Code, use CLAUDE.md.

Add this block to the instruction file in your project:

You have access to gemini-api through the shell.
Use it to call Gemini models, generate or edit media, analyze files, or launch managed agents.
1. Inspect --help or --usage to choose a command, and --schema when building a --body JSON payload.
2. Preview API calls with --dry-run (or --dry-run --output-format json).
3. For discrete JSON output or --jq filtering on streaming commands (generate, agent run, agent status --stream), pass --stream=false --output-format json (--background on agent run returns a single interaction without streaming unless --stream is passed).
4. Capture returned file paths (from media commands) and interaction IDs (from agent/model runs) to continue multi-step tasks.

The instructions tell the agent to inspect the available commands instead of guessing their syntax.

They also establish a useful preview-first workflow. Media commands return local file paths, while background agent operations return interaction IDs. Your host agent can use those results in subsequent steps.

For example, after adding the instructions, ask Claude Code:

Use gemini-api to generate a mascot image for this project.
Save the generated asset under ./assets/.
Report the resulting file path.

Or ask Codex:

Use gemini-api to analyze the project brief in ./docs/brief.pdf.
Summarize its main requirements and save the result to ./docs/analysis.md.

The agent should inspect the CLI help when necessary, preview the operation, execute it, and use the returned output.

Remember that the instruction file does not install the binary or configure authentication. Those steps must already be complete.

4. Select Gemini 4 Neon instead of the default Hydrogen

The v0.5.0 release changed the default model to gemini-4-hydrogen. The current command overview identifies the following defaults:

CommandDefault model
gemini-api generategemini-4-hydrogen
gemini-api analyzegemini-4-hydrogen
gemini-api imagegemini-nano-banana-2.1
gemini-api ttsgemini-3.8-flash-tts
gemini-api musiclyria-3.5
gemini-api videogemini-omni-1.2-flash

These defaults are command-specific. Installing the CLI does not make every command use Gemini 4 Neon.

Use -m to select Gemini 4 Neon

The CLI supports -m and --model for generation and analysis commands.

Google’s v0.5.0 model enumeration includes gemini-4-neon as a supported model identifier. Use that exact value:

gemini-api generate "Review this authentication implementation for security issues." \
  -m gemini-4-neon \
  --dry-run

After checking the preview, make the actual request:

gemini-api generate "Review this authentication implementation for security issues." \
  -m gemini-4-neon

For document analysis, first upload the PDF and capture the returned file URI:

FILE_URI=$(gemini-api files upload ./docs/architecture.pdf --wait)

Then pass that URI to the analysis command:

gemini-api analyze \
  -i "$FILE_URI" \
  "Identify the main architectural risks." \
  -m gemini-4-neon

The upload command returns a files/<id> URI. The analysis command uses that URI instead of assuming a local filesystem path is accepted.

The -m flag selects the model for that command. It does not permanently change the CLI’s default.

To check which models your API key can access, run:

gemini-api models list --all

This queries live API models available to your API key. The --all option retrieves additional pages.

If the live model list does not show Neon, check the API key’s project access and current model availability.

For model specifications, thinking levels, and API pricing, see Gemini 4 Neon API Pricing, Thinking Levels, Cursor and Copilot.

5. Understand what the CLI does not replace

Gemini API CLI is an interface to Google’s API. It is not a replacement for your existing coding agent.

The responsibilities remain separate:

  • Claude Code or Codex: Plans repository work, edits files, runs commands, and coordinates tasks.
  • Gemini API CLI: Sends Gemini requests and returns generated content, files, analysis, or interaction IDs.
  • Gemini API: Provides the underlying models and services.
  • Your API key: Determines which API project and account handle authentication and usage.

The CLI also does not provide access to subscription-only features from ChatGPT, Claude.ai, or other services. API billing and web subscriptions are separate.

Its documented API workflow does not establish support for arbitrary third-party gateways. If you need an alternative provider, configure that provider through a client integration that documents its own protocol and Base URL.

For more ways to connect existing coding agents to independent providers, see T3 Code Setup: Claude Code, Codex, and API Gateways.

If you maintain shared agent instructions across several coding tools, Agent Skills: .claude/skills vs .agents/skills Setup also explains how to organize reusable instructions.

Troubleshooting checklist

SymptomWhat to check
gemini-api: command not foundInstallation directory and PATH
Missing API keyGEMINI_API_KEY and gemini-api whoami
Dry run succeeds but real request failsAPI key validity, project access, region, and billing
Agent cannot find the CLIWhether its shell inherits the correct PATH
Agent uses Hydrogen instead of NeonAdd -m gemini-4-neon to the command
Model not foundCheck the live model list and exact model ID
Automated workflow breaks after an updatePin the CLI release version

A useful final check is to ask your host agent to make one small real request with gemini-4-neon. Confirm the generated response.

Once that works, expand the workflow to document analysis, media generation, or background managed-agent tasks.

The CLI gives your existing agent a shell-based route to Google’s Gemini API. A separate provider requires its own documented integration and authentication path.

BetterToken API
Claude, GPT, Gemini, and DeepSeek with one API key
Text & code
ClaudeGPTGeminiDeepSeekGLMKimiQwenMiniMax+4
Video & images
SeedanceKlingWanHailuoGPT ImageNano Banana+2
  • One key for every model
  • Pay as you go, no subscription
  • OpenAI- and Anthropic-compatible