What Gemini CLI is and where to get it

Gemini CLI is Google's command-line interface for interacting with the Gemini AI model. It lets you send prompts to Gemini and receive responses directly from your terminal, without opening a browser or web application. You install it on your computer using a package manager or by downloading a binary file, depending on your operating system.

The tool is maintained by Google and distributed through their official repositories. Before you install, you will need a Google account and a Gemini API key, which you can generate for free through Google's AI Studio. The installation itself takes a few minutes and works on Windows, macOS, and Linux.

Key Takeaways

  • Gemini CLI requires a Google account and an API key from Google AI Studio before installation will work.
  • On macOS and Linux, you can install using Homebrew or by downloading a precompiled binary directly from Google's releases page.
  • On Windows, download the executable file from the releases page and add it to your system PATH so you can run it from any folder.
  • After installation, you configure the tool by setting your API key as an environment variable so the CLI can authenticate with Google's servers.
  • Test your installation by running a simple command like gemini --version to confirm the tool is working.

Getting your API key before you install

You cannot use Gemini CLI without an API key. Go to Google AI Studio at aistudio.google.com, sign in with your Google account, and click the "Get API key" button. Google will generate a key instantly — it looks like a long string of letters and numbers. Copy this key and save it somewhere safe; you will need it during setup.

The free tier of Gemini API includes a monthly quota of requests, which is enough for testing and light use. If you exceed the quota, Google will stop processing requests until the next month resets, so you do not need to enter payment information unless you plan heavy usage.

Installing on macOS using Homebrew

If you have Homebrew installed, this is the fastest route. Open Terminal and run:

brew install gemini-cli

Homebrew will download and install the latest version automatically. Once the command finishes, you can verify the installation worked by typing gemini --version and pressing Enter. If you see a version number, the installation succeeded.

If you do not have Homebrew, you can install it from brew.sh, or skip to the manual download section below.

Installing on macOS or Linux by downloading the binary

Go to the Gemini CLI releases page on GitHub (github.com/google/gemini-cli/releases) and find the latest release. Look for the file that matches your operating system — on macOS it will say "darwin" and your processor type (either "arm64" for Apple Silicon or "amd64" for Intel). On Linux, look for "linux" with your processor type. Download the file.

Open Terminal, navigate to your Downloads folder, and make the file executable by running:

chmod +x gemini-cli-darwin-arm64

(Replace the filename with the one you downloaded.) Then move it to a folder in your system PATH so you can run it from anywhere:

sudo mv gemini-cli-darwin-arm64 /usr/local/bin/gemini

You will be asked for your computer password. Type it and press Enter. Test the installation by running gemini --version.

Installing on Windows

Go to the Gemini CLI releases page on GitHub and download the file labeled "windows-amd64.exe". Save it to a folder you can find easily — your Documents folder or a new folder called "gemini" works well.

Next, add that folder to your system PATH so you can run the command from any terminal window. Right-click the Start button, select "System", then click "Advanced system settings" on the right side. Click "Environment Variables" at the bottom. Under "User variables", click "New" and create a variable named "PATH" with the value being the full path to your gemini folder — for example, C:\Users\YourName\Documents\gemini. Click OK three times to save.

Open a new Command Prompt or PowerShell window and type gemini --version. If you see a version number, the installation worked.

Setting your API key as an environment variable

The CLI needs to know your API key every time it runs. The easiest way is to set it as an environment variable named GEMINI_API_KEY.

On macOS or Linux: Open Terminal and run:

export GEMINI_API_KEY="your-api-key-here"

Replace "your-api-key-here" with the actual key you copied from Google AI Studio. This sets the variable for your current terminal session only. To make it permanent, add the same line to your shell configuration file — usually ~/.bash_profile or ~/.zshrc — then run source ~/.zshrc (or the file you edited) to reload it.

On Windows: Right-click the Start button, select "System", then click "Advanced system settings". Click "Environment Variables" at the bottom. Under "User variables", click "New" and create a variable named GEMINI_API_KEY with the value being your API key. Click OK three times. Close and reopen Command Prompt or PowerShell for the change to take effect.

Testing your installation with a simple command

Once your API key is set, test the CLI by running a basic prompt. Open your terminal and type:

gemini "What is the capital of France?"

Press Enter. The CLI will send your question to Google's servers and print the response in your terminal. If you see an answer, the installation and configuration are both working correctly.

If you see an error about the API key, double-check that you set the environment variable correctly and that your terminal session has reloaded it. If you see a network error, verify that you have internet access and that your API key is valid by checking Google AI Studio again.

Frequently Asked Questions

Do I need to pay for Gemini CLI?

The CLI itself is free to download and install. You do need a free Google account and API key from Google AI Studio. Google provides a free monthly quota of API requests; once you exceed it, requests stop working until the next month. You only pay if you choose to enable billing for higher usage.

What if I get a "command not found" error after installation?

This usually means the CLI is not in your system PATH or your terminal has not reloaded the PATH after installation. On macOS or Linux, try running the full path to the file instead, like /usr/local/bin/gemini --version. On Windows, make sure you created the PATH environment variable correctly and opened a new Command Prompt window after saving it. If you still see the error, reinstall the binary to the correct location.

Can I use Gemini CLI offline?

No. The CLI sends your prompts to Google's servers over the internet and waits for a response. You must have an active internet connection and a valid API key for every command you run.

How do I update Gemini CLI to a newer version?

On macOS with Homebrew, run brew upgrade gemini-cli. On other systems, download the latest binary from the releases page, replace your old file with the new one, and make it executable again using the same steps as the initial installation.

What should I do if my API key stops working?

Go back to Google AI Studio, check that your key is still listed and active, and regenerate it if needed. Copy the new key and update your GEMINI_API_KEY environment variable with the new value. If you still see errors, check that your free monthly quota has not been exceeded by reviewing your usage in Google AI Studio.