Gemini CLI Setup

Gemini CLI is Google's AI coding assistant and is useful for large-context code tasks.

Complete the Environment Setup chapter first and make sure Node.js and npm are installed.


Linux / macOS

Step 1: Install Gemini CLI

npm i -g @google/gemini-cli

Step 2: Configure Environment Variables

Add to ~/.bashrc or ~/.zshrc:

# Relay base URL: domain only, do not append /v1beta
export GOOGLE_GEMINI_BASE_URL="https://api.icodeeasy.cc"

# Use your I Code Easy API Key
export GEMINI_API_KEY="your API Key"

# Recommended fast model. You can also use stronger models such as gemini-3.1-pro-preview
export GEMINI_MODEL="gemini-3.5-flash"

# Explicitly use Gemini API v1beta
export GOOGLE_GENAI_API_VERSION="v1beta"

Save the file and run source ~/.bashrc or source ~/.zshrc.

Note: Do not set GOOGLE_GEMINI_BASE_URL to https://api.icodeeasy.cc/v1beta, or Gemini CLI will build paths like /v1beta/v1beta/models/.... If api.icodeeasy.cc is slow from your network, change GOOGLE_GEMINI_BASE_URL to https://jp.icodeeasy.cc, still without /v1beta.

Step 3: Start Gemini

cd your-project-folder
gemini

Windows

Step 1: Install Gemini CLI

npm i -g @google/gemini-cli

Step 2: Configure Environment Variables in PowerShell

# Relay base URL: domain only, do not append /v1beta
[Environment]::SetEnvironmentVariable("GOOGLE_GEMINI_BASE_URL", "https://api.icodeeasy.cc", "User")

# Use your I Code Easy API Key
[Environment]::SetEnvironmentVariable("GEMINI_API_KEY", "your API Key", "User")

# Recommended fast model. You can also use stronger models such as gemini-3.1-pro-preview
[Environment]::SetEnvironmentVariable("GEMINI_MODEL", "gemini-3.5-flash", "User")

# Explicitly use Gemini API v1beta
[Environment]::SetEnvironmentVariable("GOOGLE_GENAI_API_VERSION", "v1beta", "User")

Open a new PowerShell window after setting environment variables.

If api.icodeeasy.cc is slow from your network, change GOOGLE_GEMINI_BASE_URL to https://jp.icodeeasy.cc, still without /v1beta.

Step 3: Start Gemini

Open a new PowerShell window, enter your project directory, and start:

cd your-project-folder
gemini

Model Selection

Common models:

Use CaseModel
New fast modelgemini-3.5-flash
Fast responsegemini-3-flash-preview
Stronger reasoninggemini-3.1-pro-preview
Stable 2.5 Progemini-2.5-pro
Stable 2.5 Flashgemini-2.5-flash

Gemini CLI's built-in flash option may resolve to the older gemini-3-flash-preview. If a client or plugin sends gemini-3-flash, this service maps it to gemini-3-flash-preview automatically.


Raw API Test Example

To test the native Gemini API directly without the CLI:

curl "https://api.icodeeasy.cc/v1beta/models/gemini-3.5-flash:streamGenerateContent?alt=sse" \
  -H "x-goog-api-key: your API Key" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {
        "role": "user",
        "parts": [{"text": "Hello, briefly introduce yourself"}]
      }
    ]
  }'

Non-streaming endpoint path:

/v1beta/models/{model}:generateContent

Streaming endpoint path:

/v1beta/models/{model}:streamGenerateContent?alt=sse

FAQ

SymptomCauseFix
Request path contains /v1beta/v1beta/models/...GOOGLE_GEMINI_BASE_URL includes /v1betaUse https://api.icodeeasy.cc
api.icodeeasy.cc is slowCurrent network path to the primary domain is poorUse https://jp.icodeeasy.cc, without /v1beta
model_not_found: gemini-3-flashSome upstreams only recognize the preview model nameUse gemini-3-flash-preview; this service also maps it automatically
401 / missing authorizationI Code Easy API Key is not setSet GEMINI_API_KEY="your API Key"
Gemini fails through /v1/responsesGemini CLI uses Gemini native API, not OpenAI Responses APIUse /v1beta/models/{model}:generateContent or let Gemini CLI send requests automatically