Overview
Gemini CLI is Google’s official command-line tool that allows you to interact directly with Gemini AI models in your terminal. Through API易, you can:- 🚀 Quickly call Gemini models in terminal
- 💻 AI-assisted programming and code generation
- 🔍 Code review and optimization suggestions
- 📝 Technical Q&A and documentation generation
- 🌐 Cross-platform support (Linux, macOS, Windows)
Why Choose API易?Using Gemini CLI through API易 provides more stable network connections, better pricing, and 24/7 technical support.
Quick Start
Prerequisites
- Node.js >= 18.0.0
- npm or yarn package manager
- API易 account and API Key
Step 1: Install Gemini CLI
Step 2: Get API易 API Key
1
Register/Login to API易
Visit
api.apiyi.com to register or login2
Create API Key
Go to dashboard “Token Management” page (
api.apiyi.com/token) and click “Create New Token”3
Copy Key
Copy the generated API Key (format:
sk-***) and keep it safeStep 3: Configure Environment Variables
- Zsh (macOS/Linux)
- Bash (Linux)
- PowerShell (Windows)
- CMD (Windows)
Step 4: Initialize and Test
1
Launch Gemini CLI
2
First-time Authentication
In the interactive interface, type:Select: Gemini API Key (AI Studio)
3
Test Connection
Core Features
Code Generation
- Function Generation
- Project Scaffolding
- Unit Tests
Code Review
Technical Q&A
Documentation Generation
Interactive Commands
In Gemini CLI interactive mode, you can use these commands:| Command | Description | Example |
|---|---|---|
/auth | Re-authenticate | /auth |
/model | Switch model | /model gemini-3-pro-preview |
/clear | Clear conversation history | /clear |
/help | Show help information | /help |
/exit | Exit CLI | /exit or Ctrl+C |
/save | Save conversation to file | /save conversation.txt |
Supported Models
Through API易, you can use the latest Gemini models:Gemini 3 Series (Recommended)
| Model | Use Case | Features |
|---|---|---|
| gemini-3-pro-preview | High-quality code, complex reasoning | 🏆 Top performance, #1 on LMArena leaderboard |
| gemini-3-pro-preview-thinking | Ultra-complex reasoning, algorithm design | 🧠 Chain-of-thought output, deep reasoning |
Gemini 2.5 Series
| Model | Use Case | Features |
|---|---|---|
| gemini-2.5-pro | Professional code generation | ⚡ High performance, 1M context |
| gemini-2.5-flash | Fast response, daily development | 🚀 Fast speed, low cost |
| gemini-2.5-flash-lite | Lightweight tasks, batch calls | 💰 Ultra-low cost, high-frequency |
Recommended Configuration:
- Complex programming, architecture design:
gemini-3-pro-preview - Daily code generation, Q&A:
gemini-2.5-flash - Batch processing, rapid iteration:
gemini-2.5-flash-lite
View Complete Model List
View all Gemini models supported by API易, detailed pricing and performance comparison
Advanced Usage
VS Code Integration
Use Gemini CLI extension in VS Code:GitHub Actions Integration
Automated code review:Batch Scripts
Create automation scripts:FAQ
Connection failed or authentication error?
Connection failed or authentication error?
Checklist:
-
Verify environment variables:
Should output:
GOOGLE_GEMINI_BASE_URL:https://api.apiyi.com(no /v1 or other paths)GEMINI_API_KEY: Complete key starting withsk-
-
Reload environment variables:
- Restart terminal: Close and reopen terminal completely
- Verify API Key: Login to API易 dashboard to confirm key is valid with sufficient balance
How to switch between Gemini models?
How to switch between Gemini models?
Use Or specify directly in command:
/model command in interactive mode:How to save conversation history?
How to save conversation history?
Method 1: Use Method 2: Redirect outputMethod 3: Use session management
/save commandNode.js version doesn't meet requirements?
Node.js version doesn't meet requirements?
Recommended: Use nvm to manage Node.js versions:
Why is response slow?
Why is response slow?
Possible causes and solutions:
- Network issues: API易 provides optimized domestic nodes, usually fast
- Model selection: Use
gemini-2.5-flashorgemini-2.5-flash-litefor fastest response - Token limit: Reduce complexity of single request
- Concurrent requests: Avoid sending too many requests simultaneously
How to use on Windows?
How to use on Windows?
Recommended: Use PowerShell:
- Install Node.js (download installer from official website)
- Run PowerShell as administrator
- Set environment variables:
- Restart PowerShell
- Install and use Gemini CLI
Best Practices
Prompt Optimization
Be Specific
❌ “Optimize this code”✅ “Optimize this code for performance, focusing on loop efficiency and memory usage”
Provide Context
❌ “What’s wrong with this function?”✅ “This is a user login function encountering async errors, help me find the issue”
Step-by-Step
❌ “Help me complete the entire project”✅ “Step 1: Design database models; Step 2: Create API routes; Step 3: …”
Request Examples
❌ “Explain closures”✅ “Explain JavaScript closures with 3 practical use cases and code examples”
Workflow Recommendations
1
Define Problem
Clearly describe the problem to solve or feature to implement
2
Get Solution
Use Gemini CLI to generate initial solution or code
3
Review & Optimize
Ask AI to review its own code and find potential issues
4
Iterate
Gradually optimize based on feedback until requirements are met
5
Add Documentation
Generate necessary comments and documentation
Pricing
Cost of using Gemini models through API易 depends on your chosen model and usage.View Detailed Pricing
View detailed pricing and cost-effectiveness comparison for all Gemini models
API易 offers recharge bonuses: the more you recharge, the higher the bonus (10%-22%). First-time recharge gets extra bonus. View recharge promotion details.
Related Resources
- Gemini CLI Official Documentation
- API易 Quick Start Guide
- Model Recommendations and Pricing
- Recharge Promotions
- API Manual
Get Help
Technical Support
WeChat: 8765058Technical consultation, usage guidance
Email Inquiry
Customer Service: [email protected]Business: [email protected]