Google's `gemini-api` CLI Lets You Run Gemini 4 Neon Inside Claude Code, Codex, and Pi
Google is up to something again — Gemini can now ride hard in Claude Code/Codex.
Hello everyone, I'm Brother Er.
Gemini 4 Neon's strength is no longer in doubt, and even the Antigravity APP has been getting more and more useful lately.
And on top of that, Antigravity's skins have also started catching fire, even though the official side doesn't support them yet.
Of course, if you're already used to Claude Code, Codex, or Pi, and don't want to use Antigravity, but you still want to use Gemini 4 Neon, you can also plug it in via gemini-api.
It packs Gemini 4 Neon and other models, image generation, voice dubbing, long-document parsing, and cloud-hosted agents into a single-file command. Put it on your system path, and your existing Agent can call Gemini over at any time from the terminal.
It just needs one API key to work, and the key can be applied for in Google's AI Studio.
Very convenient.
01. Difference from gemini-cli
When many people see the repo name gemini-api-cli, their first reaction is: didn't Google already release a gemini-cli? Why is there another command-line tool?
The two things are different. I can only say Google's naming was a bit chaotic at first.
gemini-cli is an interactive command-line Agent. After opening the terminal, you can have back-and-forth conversations with it and let it take over the entire code repository. It's in the same track as Claude Code and Codex CLI. Currently the official recommendation is also to use Antigravity CLI.
gemini-api, on the other hand, is a stateless tool invoked by other Agents. It is a single-file executable compiled in Go, open-sourced under Apache 2.0, and runs on macOS, Linux, and Windows.
The context and execution plan are still controlled by your host Agent. Whenever you need a specific Gemini capability, you just type the gemini-api subcommand in the terminal. I downloaded the v0.5.0 macOS binary to my local machine and ran gemini-api models. The built-in offline model list already includes the entire Gemini 4 family and multimodal models.
Text and reasoning default to the fastest Gemini 4 Hydrogen (gemini-4-hydrogen). You can switch to Gemini 4 Neon at any time with -m gemini-4-neon, or to the flagship Gemini 4 Carbon.
Image generation defaults to gemini-nano-banana-2.1, voice defaults to gemini-3.8-flash-tts, music composition defaults to lyria-3.5, and video generation defaults to gemini-omni-1.2-flash.
For understanding and transcription, analyze can read PDFs, images, audio/video, tables, and video links, while transcribe defaults to gemini-3.5-transcribe to output subtitles.
For cloud-hosted Agents, agent run can spin up deep-research-preview-04-2026 for deep research, and can also spin up antigravity-preview-09-2026 to run code in a cloud Linux sandbox.
02. Integrating with Claude Code
If you don't want to type the installation commands yourself, you can send the following prompt to your Claude Code, Codex, or Pi, and let the Agent install and verify the environment itself:
Please help me install Google's official gemini-api CLI (repo address https://github.com/google-gemini/gemini-api-cli), and install the accompanying gemini-api-cli Skill (npx skills add google-gemini/gemini-skills --skill gemini-api-cli). After installation, run gemini-api version and a test request with --dry-run to confirm it works. Don't change any of my other existing configurations.
If you prefer manual installation, on macOS or Linux terminal, a single command installs the precompiled binary:
curl -fsSL https://raw.githubusercontent.com/google-gemini/gemini-api-cli/main/scripts/install.sh | bash
Windows users can run the official installation script with PowerShell. Those familiar with the Go toolchain can also compile from source with go install github.com/google-gemini/gemini-api-cli/cmd/gemini-api@latest.
After installation, you need to configure a GEMINI_API_KEY.
I looked through the gemini-api auth login --help documentation. Currently gemini-api only accepts API Keys or Google Cloud OAuth access tokens. It does not yet support logging in directly with a personal Gemini Pro or Ultra subscription account.
You can generate an API Key in Google AI Studio (https://aistudio.google.com/apikey) with one click. If you have a Google AI Pro or Ultra subscription, you can also check in the background whether your account comes with a monthly API credit allowance.
I tested with my own free-tier key. gemini-3.8-flash-tts speech synthesis worked, consuming 39 tokens to generate a 75388-byte WAV audio; but calling gemini-4-neon and gemini-nano-banana-2.1 for image generation both returned 429, indicating a free-tier quota of 0. To use these two models, you need to bind a billing account in AI Studio and upgrade to the paid tier. Set a monthly spending cap at aistudio.google.com/spend so you can use it with peace of mind.
Once you have the key, there are two ways to save it:
# Method 1: Write it to the current terminal environment variable (good for temporary tests or CI)
export GEMINI_API_KEY="YOUR_API_KEY"
# Method 2: Save it to the system keychain (macOS Keychain / Windows Credential Manager)
gemini-api configure --api-key "YOUR_API_KEY"
One thing to note: if you configure different keys in both the system keychain and the terminal environment variable, the environment variable GEMINI_API_KEY takes precedence and overrides the keychain configuration. When you're not sure which key is currently active, run gemini-api whoami to see the credential source.
After configuration, you can first use --dry-run to check whether the command is written correctly.
--dry-run is a no-execution preview mode. With this parameter, the CLI does all parameter and JSON validation locally, prints the full HTTP URL, request headers, and request body it's about to send, while automatically hiding the key. It doesn't connect to the network, doesn't read the system keychain, and doesn't consume tokens.
Integrating into Claude Code: Claude Code supports a plugin marketplace. Enter the following two slash commands in sequence to configure the official skill pack and call specs at once.
/plugin marketplace add google-gemini/gemini-skills
/plugin install gemini-skills@gemini-skills
Integrating into Codex CLI: Codex CLI also supports plugin commands. Run two commands in the terminal to register and install.
codex plugin marketplace add https://github.com/google-gemini/gemini-skills
codex plugin add gemini-skills@gemini-skills
Integrating into Pi:
npx skills add google-gemini/gemini-skills --skill gemini-api-cli
If you don't even want to install a plugin, you can put the four short rules Google officially provides into CLAUDE.md or AGENTS.md.
You can call gemini-api in the terminal to use Gemini models, generate or edit media, analyze files, and launch hosted Agents.
1. Before calling, use --help to view subcommands; when constructing complex --body, use --schema to check fields.
2. For unfamiliar complex calls, first add --dry-run -o json for offline preview.
3. When you need a single complete JSON or --jq filtering, add --stream=false -o json in streaming commands.
4. Record the file paths and interaction IDs output by media commands, to chain subsequent steps.
03. Hands-on Cases
All four cases below come with prompts you can copy and send to your Agent. The gemini-api request parameters involved have been validated with --dry-run on my local v0.5.0, and the fields and syntax are correct.
Have Neon do cross-review in Claude Code
After the same model drafts a product plan, bid document, tutorial, or core code, letting it check itself often leaves the same blind spots.
After writing, you can send the following prompt to Claude Code or Codex, asking Gemini 4 Neon to open the xhigh thinking level and act as an independent reviewer:
I just finished writing the plan document in the current directory (or just modified the core code for order deduction). Please pass the content to the gemini-4-neon model via gemini-api, set thinking_level to xhigh, and take a picky reviewer's perspective to go through each point for logic holes, missing edge cases, and contradictions. Record the returned interaction ID; if a high-risk issue is found, first fix the first round with me, then use --previous-interaction-id to ask Neon to review the changes again, and confirm the loop is closed before stopping.
Once you have the interaction ID, for the second-round review you don't need to send the entire document and conversation history again. The Agent carries --previous-interaction-id, and the Gemini server automatically picks up the previous context to continue the review.
Writing articles, producing video and audio
After writing an article, tutorial, or voice-over script, and needing a cover image and an intro, once gemini-api is installed, you can put copywriting and asset production into one prompt:
I just finished writing the article draft in the current directory. Please use gemini-api image (16:9 ratio, 2K resolution) to generate a dark, minimalist cover image and save it to ./assets/cover.jpg; then extract a 15-second two-person podcast intro, use gemini-api tts to synthesize it with a two-person voice into ./assets/intro.wav. After getting the two local file paths, insert the cover image at the beginning of the draft, and write the asset list into ./assets/manifest.md.
A more interesting usage comes from Google DeepMind's Philipp Schmid. He shared a case of testing voice functionality end-to-end fully automatically without a microphone.
With gemini-api, the entire test flow only needs four steps:
- Have Codex or Claude Code call
gemini-api ttsto synthesize a24 kHzWAV human voice file according to the script, e.g.,./test-voice.wav. - When launching Chrome or Playwright, pass the virtual media parameters
--use-fake-ui-for-media-streamand--use-file-for-fake-audio-capture=./test-voice.wav%noloop. - The Agent automatically clicks the microphone button on the page, and the browser's
getUserMediainterface starts feeding this synthetic speech as the microphone's real-time input from0.0seconds. - Finally, the Agent reads the page DOM and asserts whether the transcribed text and interface state match expectations.
The following prompt is compiled from Philipp Schmid's public template. If you build voice-based web applications, keep this for later:
Please test the current project's voice input feature end-to-end without relying on a physical microphone. First use gemini-api tts to generate a test voice and save it as ./fixtures/voice.wav (content: "check my refund records for the last three months"); then use Playwright to launch Chromium with the parameters --use-fake-ui-for-media-stream and --use-file-for-fake-audio-capture=./fixtures/voice.wav%noloop; open the page, click the microphone button to trigger capture, and finally verify the transcription result and query status in the page DOM.
Launch Deep Research and a cloud sandbox in the background
When doing industry analysis, writing report PPTs, or doing technology selection, you often run into very time-consuming side research. gemini-api agent run supports the --background parameter, which returns an interaction ID immediately after launching the task, without occupying the current connection.
You can send the following prompt to the Agent in hand, letting it dispatch research in the background while you continue working on your document or project in the foreground:
Please use gemini-api's background mode (--background) to launch deep-research-preview-04-2026 to research public benchmark data on accuracy and cost of mainstream knowledge base retrieval solutions for long documents in 2026, and require primary sources from papers or official blogs. After getting the interaction ID, record it first. Don't block the current session; let's continue working on the PPT outline. When I call you in ten minutes, check the status again and pull the full report back to save it locally as ./research.md.
If the task also needs to actually run scripts to calculate data or make charts, you can have the Agent call antigravity-preview-09-2026 and enable the cloud remote sandbox ({"environment":"remote"}) in the prompt. Google will start a Linux sandbox with Bash, Python, and Node preinstalled to run the computation, and then the local Agent can download the report or CSV produced by the sandbox back to the local machine.
Handling long PDFs, research reports, and meeting recordings
When you encounter dozens of pages of scanned product plans, industry research reports, before/after visual draft comparisons, or review recordings, once you equip Pi (or your Claude Code, Codex) with gemini-api, you can just send a prompt for large files and let Gemini 4 Neon chew through them:
Please use gemini-api's gemini-4-neon model to analyze ./docs/q4-report.pdf and ./recordings/review.mp4 (files over 14 MB should first be uploaded via files upload and then reused by reference), extract the five most important data conclusions from the report, the three points of disagreement in the meeting, and a to-do list with timestamps and responsible people, and write them into ./summary.md. Also transcribe the recording into an SRT subtitle with speaker labels and save it to ./recordings/review.srt.
The Agent automatically routes files according to gemini-api rules. Files within 14 MB are sent inline with the request. Files larger than that are uploaded once through the Files API (cloud retention 48 hours), and after getting the files/<id> reference, they are handed to analyze and transcribe in sequence, so large files don't need to be re-uploaded.
If you need to extract structured tabular data from messy customer feedback or error logs, you can also have the Agent specify a JSON Schema and turn off server-side storage ("store": false) in the prompt.
04. Underlying principle analysis
Many people who have read this far might wonder: since Google already supports MCP, why build a separate stateless gemini-api command-line tool?
I pulled down the source code of google-gemini/gemini-api-cli and looked through it. There are three engineering designs worth mentioning.
Interactions API
Whether it's generate, image, tts, analyze, or agent run, the underlying request goes to the same endpoint: POST /v1beta/interactions. This is Google's primary Interactions API (a unified interaction interface that puts single-turn generation, multimodal media, multi-turn state, and hosted Agents into one protocol).
On top of that, the CLI commands are split into two layers.
The top layer is "intent commands," such as image, tts, analyze, transcribe. This layer does the dirty work: fills in default models, automatically detects local file size and MIME type, decodes returned images or audio, and saves them to disk.
The bottom layer is complete resource commands and --body parameters generated according to the OpenAPI specification. For example, to set thinking_level to xhigh for Gemini 4 Neon, first use --schema to check the field, then use --body to pass JSON, and you can call the full protocol.
Saving MCP's context overhead
gemini-api takes a different on-demand approach by embedding all documentation into the binary.
First, query the spec on demand. When you need to choose a command, run --help, or output KDL-format --usage. When you need to construct a complex request body, run --schema to print the built-in JSON Schema. When not in use, it doesn't consume the host Agent's context.
Then, write files to disk, and standard output only prints paths. Images, audio, and video are often several megabytes. If they were returned as Base64 strings through the raw REST interface, they would blow up the context. gemini-api's media commands default to writing files to disk, printing only a single local path to stdout.
Finally, TOON output and built-in gojq. With --agent-mode, it switches by default to the TOON format with fewer symbols and less token consumption (based on gotoon). Errors are returned as structured JSON on stderr. With built-in gojq, you don't need to install jq separately to use --jq for field filtering.
In simple terms, MCP stuffs all tool descriptions into the context in advance, while gemini-api only queries a command's description when the Agent uses it, and returns results with a compressed size as much as possible.
BYOS self-hosted sandbox
gemini-api insists on client-side zero state: no local SQLite, no chat history storage.
By default, the Interactions API stores interaction records on the server (store: true), and each response returns an interaction ID. On the next round, just include --previous-interaction-id, and the server picks up the previous context. For extra-long outputs that get truncated, there is also a token continuation mechanism, so the client doesn't have to stitch truncated text itself.
What surprised me most in the source code was the docs/self-hosted/ directory. It describes BYOS (bring your own sandbox environment).
If your code cannot be uploaded to Google's cloud sandbox, you can use the same gemini-api binary to run gemini-api environments connect in your own intranet container or cloud host.
Ending
In the Agent era, the most important thing about a tool is that it feels natural to use.
My current main harness is Antigravity CLI and the desktop APP.
Then Codex and Claude Code.
With so many Agents, managing them becomes hard, which is why configuration management software like CC Switch and magpie exist. Also, many tools bundle multiple Agents into one APP.
I personally like native harnesses, because they let you build up long-term memory.
Google's gemini-api takes a very humble stance. You don't want to leave Claude Code, Codex, or Pi? No problem. Google turns Gemini 4 Neon and the whole set of multimodal capabilities into a zero-dependency tool, so the Agent you're already using can call it directly.
When Google eventually connects personal subscription credits to gemini-api, so users don't have to deal with API Keys separately, this way of calling Gemini across different Agents should become even more popular.
See you next time.
Top 1 from juejin.cn, machine-translated. The original thread is authoritative.
Does this mean Google AI members can use third-party code agents?