KozeKoze
← Back to Blog
Tutorial2026年3月23日·管理员

Gemini CLI Configuration Tutorial

Gemini CLI Configuration Tutorial

📋 Preparatory Steps

Before you begin, please ensure you have:

  • Registered a Koze account and logged in
  • Created an API Key on the API Management page
  • Installed Gemini CLI (npm install -g @anthropic-ai/gemini-cli or refer to Official Repository)

🚀 Method 1: Access via Gemini API (Recommended)

Set the following environment variables in the terminal:

# Set Koze Gemini proxy address export GOOGLE_GEMINI_BASE_URL='https://api.kozeai.com/gemini'

# Set your Koze API Key
export GEMINI_API_KEY='your API key'

# Specify the model to use
export GEMINI_MODEL='gemini-2.5-pro'

Authentication method:Select Use Gemini API Key at startup. If prompted to enter an API Key, just press Enter and leave it blank.

💡 If you are automatically redirected to the Google login page at startup, please delete ~/.gemini/settings.json and restart.

🔧 Method Two: Access via Code Assist API

Another access method, suitable for some special scenarios:

# Set up the Code Assist endpoint

export CODE_ASSIST_ENDPOINT='https://api.kozeai.com/gemini'

# Set up the Access Token (using your Koze API Key)

export GOOGLE_CLOUD_ACCESS_TOKEN='your API key'

# Enable GCA mode

export GOOGLE_GENAI_USE_GCA='true'

# Specify the model

export GEMINI_MODEL='gemini-2.5-pro'

Authentication method:Select Login with at startup Google.

⚠️ Note: The Gemini CLI console may display "Failed to fetch user info: 401 Unauthorized", which is normal and does not affect usage.

🎯 Step 3: Launch Gemini CLI

After configuration, launch it in the terminal:

gemini

📌 Persist Environment Variables

It is recommended to write environment variables to the shell configuration file (using method 1 as an example):

# Zsh user

cat >> ~/.zshrc << < EOF <

export GOOGLE_GEMINI_BASE_URL=

export GEMINI_API_KEY=

export GEMINI_MODEL=

EOF source ~/.zshrc

📌 Available Models

Model Name Description
gemini-2.5-pro Gemini 2.5 Pro, the latest generation of high-performance models
gemini-2.5-flash Gemini 2.5 Flash, faster and more cost-effective
gemini-2.0-flash Gemini 2.0 Flash

⚠️ Frequently Asked Questions (FAQ)
Problem Solution
Automatically redirect to Google Login after startup Delete ~/.gemini/settings.json and try again
Prompt 401 Unauthorized This is a normal prompt and does not affect usage; ignore it.
Model unavailable Check in the Koze Model Lobby whether your current plan includes Gemini models.

 

#geminiCLI#gemini
Gemini CLI Configuration Tutorial | Koze AI