DEV Community

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

Posted on

355 7 6 6 7

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

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.

Build seamlessly, securely, and flexibly with MongoDB Atlas. Try free.

Build seamlessly, securely, and flexibly with MongoDB Atlas. Try free.

MongoDB Atlas lets you build and run modern apps in 125+ regions across AWS, Azure, and Google Cloud. Multi-cloud clusters distribute data seamlessly and auto-failover between providers for high availability and flexibility. Start free!

Learn More

Top comments (3)

Collapse
 
dotallio profile image
Dotallio

Love how clear you made the whole setup - makes jumping in way less intimidating. What's your favorite Gemini CLI use case so far?

Collapse
 
christopher_oluwadaretr profile image
Christopher Oluwadare (Trytan)

Very well written. Thanks for the clear steps

Collapse
 
sosana profile image
Zach Sosana

Can you use images for context?

Gen AI apps are built with MongoDB Atlas

Gen AI apps are built with MongoDB Atlas

MongoDB Atlas is the developer-friendly database for building, scaling, and running gen AI & LLM apps—no separate vector DB needed. Enjoy native vector search, 115+ regions, and flexible document modeling. Build AI faster, all in one place.

Start Free

👋 Kindness is contagious

Dive into this insightful article, celebrated by the caring DEV Community. Programmers from all walks of life are invited to share and expand our collective wisdom.

A simple thank-you can make someone’s day—drop your kudos in the comments!

On DEV, spreading knowledge paves the way and strengthens our community ties. If this piece helped you, a brief note of appreciation to the author truly counts.

Let’s Go!