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

# Gemini CLI 安装与配置

> 安装 Gemini CLI，并配置为使用吉吉API。

## 环境准备

<Info>
  Gemini CLI 需要 Node.js 18 或更高版本，请先完成 [Node.js 环境配置](/environment/setup)。macOS 使用 Homebrew 安装时可跳过。
</Info>

## 安装

<Tabs>
  <Tab title="macOS">
    **方法一：Homebrew（推荐）**

    ```bash theme={null}
    brew install gemini-cli
    ```

    **方法二：npm**

    ```bash theme={null}
    npm install -g @google/gemini-cli --registry=https://registry.npmmirror.com
    ```
  </Tab>

  <Tab title="Windows">
    ```powershell theme={null}
    npm install -g @google/gemini-cli --registry=https://registry.npmmirror.com
    ```
  </Tab>

  <Tab title="Linux">
    ```bash theme={null}
    npm install -g @google/gemini-cli --registry=https://registry.npmmirror.com
    ```
  </Tab>
</Tabs>

安装完成后，**打开一个新的终端窗口**，确认安装成功：

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

## 创建 API Key

在 [API 密钥](https://www.jiji.cc/keys) 页面新建一个 Key，分组选择包含 Gemini 模型的分组。

## 配置

配置文件位于：

* **macOS/Linux**：`~/.gemini/`
* **Windows**：`C:\Users\你的用户名\.gemini\`

<Steps>
  <Step title="创建 .env">
    ```bash .env theme={null}
    GOOGLE_GEMINI_BASE_URL=https://www.jiji.cc
    GEMINI_API_KEY=your-api-key-here
    ```

    <Warning>
      将 `your-api-key-here` 替换为你的 API Key。值两边**不要**加引号，请求地址**不要**加 `/v1`。
    </Warning>
  </Step>

  <Step title="创建 settings.json">
    指定使用 API Key 登录，避免启动时弹出 Google 账号登录：

    ```json settings.json theme={null}
    {
      "security": {
        "auth": {
          "selectedType": "gemini-api-key"
        }
      }
    }
    ```

    <Note>
      如果 `settings.json` 已存在，只需把 `security` 部分合并进去，不要覆盖整个文件。
    </Note>
  </Step>
</Steps>

| 配置项 | 说明 |
| - | - |
| `GOOGLE_GEMINI_BASE_URL` | 吉吉API 请求地址 |
| `GEMINI_API_KEY` | 你的 API Key |
| `GEMINI_MODEL` | 可选，默认使用的模型，可用模型以 [模型广场](https://www.jiji.cc/extension/models) 为准 |

## 验证

在终端运行 `gemini`，看到对话界面并能正常回复即配置完成：

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

## 遇到问题

<Card title="Gemini CLI 常见问题" icon="circle-question" href="/gemini/faq">
  安装、配置与错误排查
</Card>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.