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:
# API 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.8-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_URLtohttps://api.icodeeasy.cc/v1beta, or Gemini CLI will build paths like/v1beta/v1beta/models/.... Ifapi.icodeeasy.ccis slow from your network, changeGOOGLE_GEMINI_BASE_URLtohttps://jp.icodeeasy.ccorhttps://sg.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
# API 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.8-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 or https://sg.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 Case | Model |
|---|---|
| New fast model | gemini-3.8-flash |
Deprecated (served by gemini-3.8-flash) | gemini-3.7-flash, gemini-3.6-flash |
| Fast response | gemini-3-flash-preview |
| Budget-friendly fast | gemini-2.5-flash |
| Stronger reasoning | gemini-3.1-pro-preview |
| Stable 2.5 Pro | gemini-2.5-pro |
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. The text model gemini-2.5-flash is also available: as of 2026-08-03 it is served under its own name (no longer transparently upgraded to gemini-3.6-flash) and billed at the 2.5 Flash price. As of 2026-10-13, gemini-3.7-flash, gemini-3.6-flash, and gemini-3.5-flash are deprecated by Google: requests sent under these three names are still accepted here, but they are transparently served by gemini-3.8-flash, the model name in responses is gemini-3.8-flash, and billing follows the 3.8 Flash price.
Raw API Test Example
To test the native Gemini API directly without the CLI:
curl "https://api.icodeeasy.cc/v1beta/models/gemini-3.8-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
Video Analysis Demo
Gemini models support video understanding: send the video as inlineData (base64) together with the request, and the model watches it and returns an analysis in the format you ask for. Common video-capable models: gemini-3.8-flash.
The following demo is complete and runnable: read a local MP4 → build the request → call the non-streaming endpoint → extract and validate the JSON result.
# 0) Set your I Code Easy API Key first
export ICODEEASY_API_KEY="your API Key"
# 1) base64-encode the local video (macOS: base64 -i demo.mp4 | tr -d '\n' > demo.b64)
base64 -w0 demo.mp4 > demo.b64
# 2) Build the request with jq to avoid hand-writing a huge JSON body
jq -n --rawfile data demo.b64 '{
contents: [
{
role: "user",
parts: [
{text: "Watch this video and return a summary, per-scene descriptions, and keywords as JSON that strictly follows the schema."},
{inlineData: {mimeType: "video/mp4", data: $data}}
]
}
],
generationConfig: {
temperature: 0.1,
responseMimeType: "application/json",
responseJsonSchema: {
type: "object",
properties: {
summary: {type: "string"},
scenes: {type: "array", items: {type: "string"}},
keywords: {type: "array", items: {type: "string"}}
},
required: ["summary", "scenes", "keywords"],
additionalProperties: false
}
}
}' > video-request.json
# 3) Non-streaming call
curl --silent --show-error \
"https://api.icodeeasy.cc/v1beta/models/gemini-3.8-flash:generateContent" \
-H "x-goog-api-key: ${ICODEEASY_API_KEY}" \
-H "Content-Type: application/json" \
--data-binary @video-request.json \
--output video-response.json
# 4) Check the finish state and extract the business JSON
jq -e '.candidates[0].finishReason == "STOP"' video-response.json > /dev/null
jq -r '[.candidates[0].content.parts[]? | select(.thought != true) | (.text // "")] | join("")' \
video-response.json > video-result.json
jq -e . video-result.json
You can confirm the video was recognized (promptTokensDetails shows a VIDEO modality token count):
jq '.usageMetadata' video-response.json
Notes:
- Video is billed as input tokens at the same rate as text; the
VIDEOmodality token count inusageMetadatais the billing basis. - base64 is about 1/3 larger than the original file; keep each clip to about 10–15 MB and split longer videos into segments.
- Passing an external URL via
fileData.fileUriis not supported: the model service does not fetch external links. Always download the video locally and send it asinlineDataas shown in the demo above. - Latency grows with clip length, so raise the client timeout (5 minutes or more recommended). Occasional 503 / "service temporarily unavailable" responses can happen at peak times; retry after a few tens of seconds.
- This endpoint is for video understanding/analysis; video generation is not included.
FAQ
| Symptom | Cause | Fix |
|---|---|---|
Request path contains /v1beta/v1beta/models/... | GOOGLE_GEMINI_BASE_URL includes /v1beta | Use https://api.icodeeasy.cc |
api.icodeeasy.cc is slow | Current network path to the primary domain is poor | Use https://jp.icodeeasy.cc or https://sg.icodeeasy.cc, without /v1beta |
model_not_found: gemini-3-flash | The available model ID uses the preview name | Use gemini-3-flash-preview; this service also maps it automatically |
| 401 / missing authorization | I Code Easy API Key is not set | Set GEMINI_API_KEY="your API Key" |
Gemini fails through /v1/responses | Gemini CLI uses Gemini native API, not OpenAI Responses API | Use /v1beta/models/{model}:generateContent or let Gemini CLI send requests automatically |
Related guides
How to use GLM-5.3 with Claude Code
Use GLM-5.3 in Claude Code: set an API key, Base URL and model, check Windows or Unix settings, and fix authentication, model selection and connection errors.
MiniMax Setup
Connect MiniMax through a Claude-compatible client, configure the model, Base URL, and API key, and diagnose common connection problems.
Kimi Code Setup: API Key, K3.1 Pro, and Claude Code
Set up Kimi Code CLI or Claude Code with K3.1 Pro. Compare persistent and temporary settings, verify your first call, and fix 401, model, and URL errors.