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

# Gemini CLI

> Gemini CLI 接入 ViVi-API 的配置教程。

准备好 [ViVi-API 控制台](https://api.viviai.cc/dashboard)创建的令牌 Key，并确认分组支持所选模型。已有配置请先备份，再合并所需字段。

## 1. 安装与检查

准备 **Node.js 20 或更新版本**和 npm，然后执行：

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

## 2. 配置环境变量

> [tab] Windows PowerShell
>
> 当前终端生效：
>
> ```powershell theme={null}
> $env:GOOGLE_GEMINI_BASE_URL = "https://api.viviai.cc"
> $env:GEMINI_API_KEY = "sk-your-api-key"
> ```
>
> 如需保存为当前用户的环境变量，可选执行：
>
> ```powershell theme={null}
> [System.Environment]::SetEnvironmentVariable('GOOGLE_GEMINI_BASE_URL', 'https://api.viviai.cc', 'User')
> [System.Environment]::SetEnvironmentVariable('GEMINI_API_KEY', 'sk-your-api-key', 'User')
> ```
>
> 用户环境变量保存后，新开的终端才会自动读取。

> [tab] macOS / Linux
>
> 当前终端生效：
>
> ```bash theme={null}
> export GOOGLE_GEMINI_BASE_URL="https://api.viviai.cc"
> export GEMINI_API_KEY="sk-your-api-key"
> ```
>
> 使用 Zsh 时，可把两行 `export` 加入 `~/.zshrc`，然后执行：
>
> ```bash theme={null}
> source ~/.zshrc
> ```
>
> 使用 Bash 时，放入对应的 `~/.bashrc`，再执行 `source ~/.bashrc`。

## 3. 启动与测试

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

首次运行时选择 **Gemini API Key** 认证方式。需要切换认证时，在交互界面输入 `/auth`。也可以用非交互命令测试：

```bash theme={null}
gemini -p "Hello，测试连接是否正常"
```

如果默认模型不可用，使用 `gemini -m gemini-3-flash-preview` 指定账号支持的模型。这里的环境变量填写主机地址，由客户端拼接 Gemini API 路径。

更多说明见[接入概览](https://docs.viviai.cc/scenarios.md)与[常见问题](https://docs.viviai.cc/faq.md)。


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