Google Gemini CLI Tutorial: How to Install and Use It (With Images)
Auden

Auden @auden

About: Share programming tips and best practices used.

Joined:
Apr 7, 2024

Google Gemini CLI Tutorial: How to Install and Use It (With Images)

Publish Date: Jun 26
74 0

What is Gemini CLI?

Gemini CLI is an open-source command-line AI tool developed by the Google Gemini team, specifically designed for developers. It can understand code, execute complex queries, automate tasks, and leverage Gemini’s multimodal capabilities (like image recognition) to generate creative content.

GitHub: https://github.com/google-gemini/gemini-cli

Key Features:

  • Large codebase support: Handles over 1 million tokens in context, making it easy to analyze large projects.

  • Multimodal app prototyping: Quickly generate app prototypes from PDFs or sketches.

  • Automated DevOps tasks: Perform Git operations, fetch PRs, create migration plans, and more.

  • Tool integration: Connect to media generation models like Imagen, Veo, and Lyria via an MCP server.

  • Web search ready: Built-in Google Search ensures up-to-date, reliable responses.

Install and Use Google Gemini CLI

How to Install Gemini CLI

Prerequisites

Make sure you have Node.js 18 or later installed. You can check by running:

node -v
Enter fullscreen mode Exit fullscreen mode

Install and Use Google Gemini CLI

This guide uses macOS as an example, but the steps are similar on Windows — everything happens in the terminal.

Option 1: Run Directly (No Installation)

npx https://github.com/google-gemini/gemini-cli
Enter fullscreen mode Exit fullscreen mode

Option 2: Global Installation (Recommended)

Run the following command in your terminal (you may be prompted to enter your system password if using sudo):

sudo npm install -g @google/gemini-cli
Enter fullscreen mode Exit fullscreen mode

Once installed, just type gemini in your terminal to launch the interactive CLI. On the first run, it may request some permissions — simply confirm to proceed.

Install and Use Google Gemini CLI

First-Time Setup

Upon launch, the CLI will guide you through the following steps:

Step 1: Choose a Theme

Select a preferred theme style from the options provided. Hit Enter to confirm.

Install and Use Google Gemini CLI

Step 2: Sign-In Method

Choose a login method. We recommend "Login with Google", which allows up to 60 requests/minute and 1,000 requests/day for free. Select it and hit Enter.

Install and Use Google Gemini CLI

If you need higher rate limits or enterprise access, you can use an API key:

  1. Obtain your API key from Google AI Studio.

  2. Set it as an environment variable:

export GEMINI_API_KEY="YOUR_API_KEY"
Enter fullscreen mode Exit fullscreen mode

Note: Using an API key is typically for direct API calls — this guide focuses on the CLI experience. You can learn more about Gemini API in this guide: Guide: What is Google Gemini API and How to Use It?

Step 3: Browser Authentication

After selecting your sign-in method, a browser window will open. Simply log in with your Google account.

Install and Use Google Gemini CLI

After Login

Once authenticated, you’ll see a confirmation message like this:

Install and Use Google Gemini CLI

Getting Started

You can now enter prompts directly in the CLI. For example:

Install and Use Google Gemini CLI

To upload and reference local files, use @ in the CLI to trigger file selection:

Install and Use Google Gemini CLI

Using Gemini CLI in VSCode

Try running gemini directly in VSCode’s integrated terminal. After that, use the @ command to select a file and begin a conversation.

Install and Use Google Gemini CLI

For example:

Help me write a simple calculator

Install and Use Google Gemini CLI

The CLI might request "write access" during the process — just confirm. Here's the (slightly ugly) result:

Install and Use Google Gemini CLI

Tips & Tricks

If your connection is unstable, Gemini CLI may automatically fall back from the gemini-2.5-pro model to the faster gemini-2.5-flash model.

To discover available commands and usage tips, type / in the CLI.

Install and Use Google Gemini CLI

Gemini CLI is a powerful AI companion for developers, DevOps engineers, and data analysts. It simplifies code analysis, automates workflows, and supports creative generation — all via natural language instructions.

Bonus: A Must-Have Tool for API Development – Apidog

Alongside Gemini CLI, there’s another powerful productivity tool for developers: Apidog.

Apidog is an all-in-one platform for API documentation, API debugging, API design, API testing, mocking, and automation. It streamlines your entire API workflow — making it one of the best tools to boost development efficiency.

Install and Use Google Gemini CLI

If you’re actively building and testing APIs, give Apidog a try. Signing up is easy — just register [here].

After registering, explore the official demo projects. They’re carefully crafted to help you get up to speed with Apidog’s core features.

A major benefit of Apidog is its full compatibility with Postman and Swagger formats. If you’ve used those tools before, importing your existing data will be effortless. The intuitive interface also makes it beginner-friendly — even first-time users can get started quickly.

Comments 0 total

    Add comment