Skip to content

wr-fenglei/gemini-cli

 
 

Repository files navigation

Gemini CLI

Gemini CLI CI

Gemini CLI Screenshot

This repository contains the Gemini CLI, a command-line AI workflow tool that connects to your tools, understands your code and accelerates your workflows.

With the Gemini CLI you can:

  • Query and edit large codebases in and beyond Gemini's 1M token context window.
  • Generate new apps from PDFs or sketches, using Gemini's multimodal capabilities.
  • Automate operational tasks, like querying pull requests or handling complex rebases.
  • Use tools and MCP servers to connect new capabilities, including media generation with Imagen, Veo or Lyria
  • Ground your queries with the Google Search tool, built in to Gemini.

Quickstart

  1. Prerequisites: Ensure you have Node.js version 18 or higher installed.

  2. Run the CLI: Execute the following command in your terminal:

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

    Or install it with:

    npm install -g @google/gemini-cli
    gemini
  3. Pick a color theme

  4. Authenticate: When prompted, choose your preferred AI provider:

    • Login with Google: Sign in with your personal Google account for up to 60 model requests per minute and 1,000 model requests per day using Gemini.
    • Gemini API Key: Use a Google AI Studio API key for higher limits.
    • DeepSeek API Key: Use DeepSeek's models with your DeepSeek API key.
    • OpenAI-like API: Use any OpenAI-compatible API (DeepSeek, OpenAI, Volcengine, etc.)
    • Vertex AI: For enterprise Google Cloud users.

You are now ready to use the Gemini CLI!

Installing from Source (Development/Fork)

If you have forked this repository or want to install a locally modified version:

Method 1: Using npm pack (Recommended for testing releases)

Best for: Testing the final packaged version before publishing

  1. Clone and build the project:

    git clone https://github.com/your-username/gemini-cli.git  # Or your fork's URL
    cd gemini-cli
    npm install
    npm run build
  2. Package and install globally:

    npm pack
    npm install -g google-gemini-cli-*.tgz
  3. Verify installation:

    gemini --version

Updating: When you make changes, rebuild and repackage:

npm run build
npm pack
npm install -g google-gemini-cli-*.tgz

Method 2: Direct installation from directory (Recommended for development)

Best for: Frequent code changes and rapid iteration

# Clone and build the project
git clone https://github.com/your-username/gemini-cli.git  # Or your fork's URL
cd gemini-cli
npm install
npm run build

# Install directly from directory
npm install -g .

Updating: When you make changes, just rebuild and reinstall:

npm run build
npm install -g .

For advanced use or increased limits:

Using Gemini API

If you need to use a specific model or require a higher request capacity, you can use an API key:

  1. Generate a key from Google AI Studio.

  2. Set it as an environment variable in your terminal. Replace YOUR_API_KEY with your generated key.

    export GEMINI_API_KEY="YOUR_API_KEY"

Using DeepSeek API

To use DeepSeek's models (including DeepSeek-V3 and DeepSeek-R1):

  1. Generate a key from DeepSeek Platform.

  2. Set it as an environment variable in your terminal. Replace YOUR_DEEPSEEK_API_KEY with your generated key.

    export DEEPSEEK_API_KEY="YOUR_DEEPSEEK_API_KEY"
  3. Optionally specify the model (defaults to deepseek-chat):

    export GEMINI_MODEL="deepseek-reasoner"  # For DeepSeek-R1

Using OpenAI-like API

To use any OpenAI-compatible API service (DeepSeek, OpenAI, Volcengine, etc.):

Set the required environment variables:

export OPENAI_LIKE_API_KEY="YOUR_API_KEY"
export OPENAI_LIKE_BASE_URL="YOUR_API_BASE_URL"
export OPENAI_LIKE_MODEL="YOUR_MODEL_NAME"  # Optional

For other authentication methods, including Google Workspace accounts, see the authentication guide.

Examples

Once the CLI is running, you can start interacting with Gemini from your shell.

You can start a project from a new directory:

cd new-project/
gemini
> Write me a Gemini Discord bot that answers questions using a FAQ.md file I will provide

Or work with an existing project:

git clone https://github.com/google-gemini/gemini-cli
cd gemini-cli
gemini
> Give me a summary of all of the changes that went in yesterday

Next steps

Troubleshooting

Head over to the troubleshooting guide if you're having issues.

Popular tasks

Explore a new codebase

Start by cding into an existing or newly-cloned repository and running gemini.

> Describe the main pieces of this system's architecture.
> What security mechanisms are in place?

Work with your existing code

> Implement a first draft for GitHub issue #123.
> Help me migrate this codebase to the latest version of Java. Start with a plan.

Automate your workflows

Use MCP servers to integrate your local system tools with your enterprise collaboration suite.

> Make me a slide deck showing the git history from the last 7 days, grouped by feature and team member.
> Make a full-screen web app for a wall display to show our most interacted-with GitHub issues.

Interact with your system

> Convert all the images in this directory to png, and rename them to use dates from the exif data.
> Organise my PDF invoices by month of expenditure.

Terms of Service and Privacy Notice

For details on the terms of service and privacy notice applicable to your use of Gemini CLI, see the Terms of Service and Privacy Notice.

About

An open-source AI agent that brings the power of Gemini directly into your terminal.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • TypeScript 95.3%
  • JavaScript 4.4%
  • Other 0.3%