Skip to main content
Gemini CLI is a command-line interface tool that can be made compatible with Z.AI’s GLM models by using a customized fork.

Step 1: Obtaining the Custom Version

1. Cloning the Custom Repository

Since the official Gemini CLI repository only supports Google’s Gemini models, we need to use a customized branch that supports OpenRouter compatibility:

2. Switching to the Compatible Branch

Step 2: Environment Configuration

1. Setting Environment Variables

Description Configure the API base URL:
Configure the API Key:

Step 3: Installation and Launch

1. System Requirements

Ensure your Node.js version is >= 18.

2. Installing Dependencies

3. Launch Process

Description After launching, complete the following steps:
  1. Select a background color theme.
  2. User login (recommended to use a Google account for authentication, which will redirect to a webpage for verification).

Step 4: Usage Results

Description Once configured, you can use Z.AI’s GLM models in the command line for conversations and code generation.