# Gemini CLI

Gemini CLI 是一款通过命令行界面与 Gemini 模型进行交互的工具。

你可以查看 [**帮助文档**](https://geminicli.com/docs/) 了解更多详情。

## 安装 Gemini CLI

使用 npm 全局安装 Gemini CLI：

```bash
npm install -g @google/gemini-cli
```

安装完成后，你可以在终端中直接使用 `gemini` 命令。

## 配置

Gemini CLI 通过环境变量读取配置信息。

**步骤 1：打开（或创建）环境变量文件**

```bash
vim ~/.env
```

**步骤 2：添加以下配置**

```bash
# 通过 AI 网关路由的 Gemini 请求基础 URL
GOOGLE_GEMINI_BASE_URL=https://gateway.theturbo.ai

# 您的 AI 网关 / AI 网关 API 密钥
GEMINI_API_KEY=YOUR_API_KEY

# 默认使用的 Gemini 模型
GEMINI_MODEL=gemini-2.5-flash
```

请将 `YOUR_API_KEY` 替换为创建 AI 网关实例后生成的 API 密钥。

## 使用 Gemini CLI

完成配置后，运行以下命令启动 Gemini CLI：

```bash
gemini
```

此后，Gemini CLI 将通过 AI 网关发送所有请求，从而实现对 Gemini 模型的统一身份认证与集中化管理。

{% hint style="info" %} <mark style="color:blue;">**注意**</mark>

* <mark style="color:blue;">请确保当前 shell 会话已加载上述环境变量。</mark>
* <mark style="color:blue;">你可以通过修改</mark> <mark style="color:blue;">`GEMINI_MODEL`</mark> <mark style="color:blue;">的值来更换默认模型。</mark>
* <mark style="color:blue;">请妥善保管你的 API 密钥，避免将其提交到代码仓库中。</mark>
  {% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.console.zenlayer.com/welcome/cn/ai-gateway/ai-gateway-integration/gemini-cli.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
