Skip to main content

Overview

Gemini CLI is Google’s official command-line tool that allows you to interact directly with Gemini AI models in your terminal. Through APIYI, 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 APIYI?Using Gemini CLI through APIYI 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
  • APIYI account and API Key

Step 1: Install Gemini CLI

Step 2: Get APIYI API Key

1

Register/Login to APIYI

Visit api.apiyi.com to register or login
2

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 safe

Step 3: Configure Environment Variables

Important Configuration: GOOGLE_GEMINI_BASE_URL must be set to https://api.apiyi.com without any additional paths (like /v1 or /gemini), otherwise connection will fail.

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

Example Output:

Code Review

Technical Q&A

Documentation Generation

Interactive Commands

In Gemini CLI interactive mode, you can use these commands:
Model Switching: Use /model command to switch between different Gemini models like gemini-3-pro-preview, gemini-2.5-flash, gemini-2.5-pro, etc.

Supported Models

Through APIYI, you can use the latest Gemini models:

Gemini 2.5 Series

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 APIYI, 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

Checklist:
  1. Verify environment variables:
    Should output:
    • GOOGLE_GEMINI_BASE_URL: https://api.apiyi.com (no /v1 or other paths)
    • GEMINI_API_KEY: Complete key starting with sk-
  2. Reload environment variables:
  3. Restart terminal: Close and reopen terminal completely
  4. Verify API Key: Login to APIYI dashboard to confirm key is valid with sufficient balance
Use /model command in interactive mode:
Or specify directly in command:
Method 1: Use /save command
Method 2: Redirect output
Method 3: Use session management
Recommended: Use nvm to manage Node.js versions:
Possible causes and solutions:
  1. Network issues: APIYI provides optimized domestic nodes, usually fast
  2. Model selection: Use gemini-2.5-flash or gemini-2.5-flash-lite for fastest response
  3. Token limit: Reduce complexity of single request
  4. Concurrent requests: Avoid sending too many requests simultaneously
Test connection speed:
Recommended: Use PowerShell:
  1. Install Node.js (download installer from official website)
  2. Run PowerShell as administrator
  3. Set environment variables:
  4. Restart PowerShell
  5. Install and use Gemini CLI
Or use WSL (Windows Subsystem for Linux) for better experience.

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 APIYI depends on your chosen model and usage.

View Detailed Pricing

View detailed pricing and cost-effectiveness comparison for all Gemini models
APIYI offers recharge bonuses: the more you recharge, the higher the bonus (10%-22%). First-time recharge gets extra bonus. View recharge promotion details.

Get Help

Enterprise WeChat

Enterprise WeChat QR CodeScan QR code or Click to contact supportTechnical consultation, usage guidance

Email Inquiry

Customer Service: support@apiyi.comBusiness: business@apiyi.com
Quick Start: Follow the “Quick Start” section above to complete setup and start using Gemini CLI in 5 minutes!