> ## Documentation Index
> Fetch the complete documentation index at: https://docs.evolink.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Gemini CLI

> Connect Gemini CLI to EvoLink.AI

## Overview

<img src="https://mintcdn.com/muyutechnology/ogYegfyiYikRHauR/images/integration-guide/image-2.png?fit=max&auto=format&n=ogYegfyiYikRHauR&q=85&s=164ba3d3b5cdc5deaff461189e96ba50" alt="Gemini CLI Interface" width="1711" height="578" data-path="images/integration-guide/image-2.png" />

Gemini CLI is Google's official command-line tool for interacting with Gemini models in the terminal.
By integrating Gemini CLI with **EvoLink API**, you can go beyond official model limits and access EvoLink's broader model set, including **Gemini, GPT, and Claude** series models, through one entry point.

## Prerequisites

Before configuring, make sure you have:

### 1. Install Node.js and npm

**Why needed?** Node.js is the runtime environment for CLI tools (like installing WeChat on your phone to chat, you need to install Node.js on your computer to run CLI tools).

**If already installed:** Run `node -v` and `npm -v` to check version. If v20+, skip this step.

**First-time installation:**

* Download and install from [Node.js official website](https://nodejs.org/) (recommend LTS version)
* If you're unfamiliar with the installation process, refer to [Runoob - Node.js Installation Guide](https://www.runoob.com/nodejs/nodejs-install-setup.html)
* Recommended: **Node.js v20 or higher**
* Verify installation:

```bash theme={null}
node -v
npm -v
```

<img src="https://mintcdn.com/muyutechnology/aVl9y2uT7NNwpwBy/images/integration-guide/claude-node-npm-verify.png?fit=max&auto=format&n=aVl9y2uT7NNwpwBy&q=85&s=13be4f60f117fca3024b2b2c1d0fd208" alt="Node.js and npm version verification" width="1730" height="923" data-path="images/integration-guide/claude-node-npm-verify.png" />

### 2. Get EvoLink API Key

* Log in to [EvoLink Dashboard](https://evolink.ai/dashboard)
* Find API Keys in the dashboard, click 'Create New Key' button, then copy the generated Key
* API Key usually starts with `sk-`

## Step 1: Install Gemini CLI

<Note>
  **Tip:** If you don't know how to open a command line terminal, see [FAQ - How to open command line terminal](#13-how-to-open-command-line-terminal)
</Note>

### 1. Install command

```bash theme={null}
npm install -g @google/gemini-cli
```

**Expected result:** Download info scrolling, ending with `added XX packages` (takes 1-3 minutes).

**If error occurs:** `permission denied` means Windows needs "Run as administrator" PowerShell, macOS/Linux add `sudo` before command.

### 2. Verify Installation

```bash theme={null}
gemini --version
```

**Success indicator:** Shows version number (e.g., `1.x.x`).

<img src="https://mintcdn.com/muyutechnology/ImpSKD1BzFmyJCJ-/images/integration-guide/gemini-version.png?fit=max&auto=format&n=ImpSKD1BzFmyJCJ-&q=85&s=3fd01705c8f519f6d81ba1fb78d25cb2" alt="Gemini CLI Version" width="1730" height="923" data-path="images/integration-guide/gemini-version.png" />

## Step 2: Configure EvoLink API

**⚠️ Important:** Gemini CLI configuration is **slightly more complex** than other tools, requiring modification of installation files. If you're new to programming, consider using **Claude CLI** or **Codex CLI** first (simpler configuration).

### 1. Find installation directory

```bash theme={null}
npm root -g
```

**You'll see a path like:**

* Windows: `C:\Users\YourUsername\AppData\Roaming\npm\node_modules`
* macOS: `/usr/local/lib/node_modules`
* Linux: `/usr/lib/node_modules`

<img src="https://mintcdn.com/muyutechnology/aVl9y2uT7NNwpwBy/images/integration-guide/gemini-find-install-dir.png?fit=max&auto=format&n=aVl9y2uT7NNwpwBy&q=85&s=b532f9ef42e03905f6b23a216debb194" alt="Find Gemini CLI installation directory" width="1730" height="923" data-path="images/integration-guide/gemini-find-install-dir.png" />

### 2. Modify API endpoint

Modify 2 files:

<img src="https://mintcdn.com/muyutechnology/ImpSKD1BzFmyJCJ-/images/integration-guide/gemini-modify-api.png?fit=max&auto=format&n=ImpSKD1BzFmyJCJ-&q=85&s=02aaff8284dabd21e029e42b85310dd5" alt="File location" width="1028" height="236" data-path="images/integration-guide/gemini-modify-api.png" />

**File 1:** `{install_dir}\@google\gemini-cli\node_modules\@google\genai\dist\node\index.mjs`

Find line **\~11222**:

```javascript theme={null}
// Before
initHttpOptions.baseUrl = `https://generativelanguage.googleapis.com/`;

// After
initHttpOptions.baseUrl = `https://direct.evolink.ai/`;
```

<img src="https://mintcdn.com/muyutechnology/aVl9y2uT7NNwpwBy/images/integration-guide/gemini-mjs-modify.png?fit=max&auto=format&n=aVl9y2uT7NNwpwBy&q=85&s=5ba761a74f73a50df86f72a2303c2087" alt="Modify mjs file" width="1302" height="896" data-path="images/integration-guide/gemini-mjs-modify.png" />

**File 2:** `{install_dir}\@google\gemini-cli\node_modules\@google\genai\dist\node\index.cjs`

Find line **\~11244**, make the same change.

<img src="https://mintcdn.com/muyutechnology/aVl9y2uT7NNwpwBy/images/integration-guide/gemini-cjs-modify.png?fit=max&auto=format&n=aVl9y2uT7NNwpwBy&q=85&s=84ee7886704faaebddad7b44a565e285" alt="Modify cjs file" width="1301" height="865" data-path="images/integration-guide/gemini-cjs-modify.png" />

### 3. Configure API Key

<Tabs>
  <Tab title="Windows PowerShell">
    **Temporary (current session only)**

    ```powershell theme={null}
    $env:GEMINI_API_KEY = "your-evolink-api-key"
    ```

    **Permanent**

    ```powershell theme={null}
    [Environment]::SetEnvironmentVariable("GEMINI_API_KEY", "your-evolink-api-key", "User")
    ```

    Restart the terminal for changes to take effect.

    **Verify Configuration**

    ```powershell theme={null}
    echo $env:GEMINI_API_KEY
    ```

    If it outputs your API Key, the configuration is successful.

    <img src="https://mintcdn.com/muyutechnology/aVl9y2uT7NNwpwBy/images/integration-guide/gemini-check-env.png?fit=max&auto=format&n=aVl9y2uT7NNwpwBy&q=85&s=588d9271f5c882ec0fbdd463f12877e1" alt="Check environment variable" width="1730" height="923" data-path="images/integration-guide/gemini-check-env.png" />
  </Tab>

  <Tab title="macOS / Linux">
    **Temporary (current session only)**

    ```bash theme={null}
    export GEMINI_API_KEY="your-evolink-api-key"
    ```

    **Permanent**
    Edit `~/.bashrc` or `~/.zshrc`, add:

    ```bash theme={null}
    export GEMINI_API_KEY="your-evolink-api-key"
    ```

    Then run `source ~/.bashrc` or `source ~/.zshrc` to apply, or restart the terminal.

    **Verify Configuration**

    ```bash theme={null}
    echo $GEMINI_API_KEY
    ```

    If it outputs your API Key, the configuration is successful.
  </Tab>
</Tabs>

## Step 3: Start Using Gemini CLI

### 1. Enter working directory

```shell theme={null}
cd your-working-directory
```

**Note:** Replace `your-working-directory` with actual path

### 2. Single query mode

```shell theme={null}
gemini "Who are you"
```

### 3. Interactive mode

```shell theme={null}
gemini
```

<img src="https://mintcdn.com/muyutechnology/aVl9y2uT7NNwpwBy/images/integration-guide/gemini-interface.png?fit=max&auto=format&n=aVl9y2uT7NNwpwBy&q=85&s=390483a8f111f322165b81ff8bbe0626" alt="Gemini CLI Interface" width="1730" height="923" data-path="images/integration-guide/gemini-interface.png" />

**Success indicators:**

* See AI response text (several lines)
* **No** errors like `401`, `403`, `API Key invalid`

**If you see errors:**

* `401 Unauthorized`: API Key not set or invalid → Check environment variable
* `403 Forbidden`: Insufficient API Key permissions → Verify API endpoint modification
* `Network error`: Network issue → Check connection

## FAQ

### 1. What is Gemini CLI and what is it used for?

Gemini CLI is Google's official command-line tool for interacting with Gemini models in the terminal. With EvoLink configuration, you can also access GPT, Claude, and other models.

### 2. How do I verify installation and configuration on first use?

Run these commands in sequence:

* `node -v` and `npm -v`: Confirm Node.js and npm are installed
* `gemini --version`: Confirm Gemini CLI is installed
* `gemini "Who are you"`: Confirm API configuration is correct

### 3. What's the difference between interactive mode and single command mode?

* **Interactive mode**: Run `gemini` to enter continuous conversation for multi-turn interactions
* **Single command mode**: Run `gemini "question"` to get a single response and exit

### 4. Will Gemini CLI automatically read or upload my local files and code?

No. Gemini CLI only reads file content when you explicitly reference or authorize it. It's recommended to use it in a dedicated project folder.

### 5. How do I use Gemini CLI to analyze local file content?

In interactive mode, you can reference files by:

* Typing the file path for Gemini to read
* Dragging files into the terminal window

### 6. Does Gemini CLI support Chinese input and output?

Yes, fully supported.

### 7. No output after execution—what could be the cause?

Common causes include:

* Network connection issues
* Invalid API Key or insufficient balance
* Incorrect API endpoint configuration
* Firewall or proxy blocking requests

### 8. Why don't my API endpoint or environment variable changes take effect?

* Restart your terminal or command line window
* Confirm `GEMINI_API_KEY` environment variable is set correctly
* Confirm API endpoint files are modified correctly (need to modify .mjs and .cjs files in node\_modules)

### 9. What causes 401/403 errors?

* **401 error**: `GEMINI_API_KEY` not set or invalid
* **403 error**: Insufficient permissions or expired key
* Verify API endpoint is `https://direct.evolink.ai/`

### 10. What scenarios is Gemini CLI suited for?

**Suited for:**

* Code writing, debugging, and refactoring
* Quick Q\&A in command-line environments
* File content analysis
* Automation script integration

**Not suited for:**

* Complex GUI interactions
* Real-time collaborative editing
* Large-scale batch file processing

### 11. How do I switch models?

Type `/model` in interactive mode.

<img src="https://mintcdn.com/muyutechnology/ogYegfyiYikRHauR/images/integration-guide/image-3.png?fit=max&auto=format&n=ogYegfyiYikRHauR&q=85&s=9fd12b04bfc76875a9652b480a44b786" alt="Gemini CLI Switch Model" width="1280" height="570" data-path="images/integration-guide/image-3.png" />

Available models:

* `gemini-2.5-pro`
* `gemini-2.5-flash`
* `gemini-3-pro-preview`
* `gemini-3-flash-preview`

### 12. How do I upload images?

* Option 1: Reference the image path
* Option 2: Drag and drop an image into the terminal

All methods require user action—Gemini CLI will not automatically read or upload local images.

### 13. How to open command line terminal?

<Tabs>
  <Tab title="Windows">
    * Method 1: Press `Win + R`, type `cmd` or `powershell`, then press Enter
    * Method 2: Search for "Command Prompt" or "PowerShell" in the Start menu
    * Method 3: Hold Shift and right-click in a folder, select "Open PowerShell window here"
  </Tab>

  <Tab title="macOS">
    * Method 1: Press `Command + Space` to open Spotlight, type `Terminal`, then press Enter
    * Method 2: Go to "Applications" → "Utilities" → "Terminal"
  </Tab>

  <Tab title="Linux">
    * Method 1: Press `Ctrl + Alt + T` shortcut
    * Method 2: Search for "Terminal" in the application menu
  </Tab>
</Tabs>

## Notes

<Warning>
  Run Gemini CLI in a dedicated project folder. Avoid running it in sensitive directories (such as system folders or directories containing credentials). Gemini CLI operates starting from the current working directory.
</Warning>
