Documentation Index
Fetch the complete documentation index at: https://docs.agipower.ai/llms.txt
Use this file to discover all available pages before exploring further.
Guide to Using Gemini CLI with AGIPower
Gemini CLI is an open-source AI terminal agent tool released by Google that brings Gemini’s capabilities directly into your terminal. Built on the ReAct (Reason + Act) loop architecture, it can autonomously handle complex tasks such as coding, debugging, file operations, and content generation. Gemini CLI offers a 1M-token context window, a request rate limit of 60 requests/minute, and rich MCP tool integration. With AGIPower, you can configure a custom API endpoint for Gemini CLI, enabling more flexible model selection and a more stable service experience.Prerequisites
- Node.js 18+
- AGIPower API Key (see Get a AGIPower API Key below)
Install Gemini CLI
npm (Recommended)
pnpm
npx (Try without installing)
gemini in your terminal to start it.
Get a AGIPower API Key
Subscription API Key (Recommended)
Pay-as-you-go API Key
Configuration
A simple setup—connect in minutes with just 3 environment variables.Step 1: Create the config directory
Step 2: Configure environment variables
You can configure environment variables in~/.gemini/.env. Gemini CLI will automatically load them from this file:
macOS/Linux/WSL
Windows PowerShell
Step 3: Configure settings.json
Set the auth method to Gemini API Key to avoid being prompted to sign in with Google when Gemini CLI starts:Step 4: Verify connectivity
"response": "OK", the basic connection is working.
Next, test read-only file analysis:
Authentication
Gemini CLI natively supports multiple authentication methods:| Method | Use Case | Notes |
|---|---|---|
| Google Account (OAuth) | Local dev | Highest free tier: 60 RPM / 1000 RPD |
| API Key | CI/CD, scripts | Set via the GEMINI_API_KEY env var |
GEMINI_API_KEY environment variable.
To re-authenticate, run:
Core Features
GEMINI.md Context File
GEMINI.md is one of Gemini CLI’s core features, similar to Claude Code’s CLAUDE.md. It serves as persistent context that is automatically loaded at the start of each session, helping the AI understand the project background and conventions.
Gemini CLI searches for and merges GEMINI.md files in the following order:
| Location | Scope | Description |
|---|---|---|
~/.gemini/GEMINI.md | Global | General instructions for all projects |
<project-root>/GEMINI.md | Project | Project-specific rules and conventions |
<current-dir>/GEMINI.md | Directory | Subdirectory-specific context |
Common Slash Commands
Gemini CLI provides many built-in commands to manage sessions and configuration:| Command | Description |
|---|---|
/help | Show help and the list of available commands |
/stats | View token usage and statistics for the session |
/memory show | Show the currently loaded GEMINI.md context |
/memory add <text> | Add content to the AI’s memory |
/theme | Switch the UI theme |
/tools | List currently available tools |
/mcp | Manage MCP server connections |
/chat | Save and restore chat history |
/copy | Copy the latest output to the clipboard |
Custom Slash Commands
Gemini CLI supports custom commands stored in:- Global commands:
~/.gemini/commands/— available across all projects - Project commands:
<project-root>/.gemini/commands/— available only in the current project
/plan command:
MCP Integration
Gemini CLI supports MCP (Model Context Protocol) servers to extend tool capabilities:settings.json:
Non-Interactive Mode
Gemini CLI supports non-interactive usage, suitable for scripts and CI:Supported Models
With AGIPower, you can use multiple Gemini models in Gemini CLI. Use theGEMINI_MODEL environment variable to specify a model:
| Model Name | Model Slug | Notes |
|---|---|---|
| Gemini 2.5 Pro | google/gemini-2.5-pro | Google’s flagship model (recommended) |
| Gemini 2.5 Flash | google/gemini-2.5-flash | Faster responses; ideal for rapid iteration |
- View available Google AI protocol models via the AGIPower model list
- Use the model slug (e.g.,
google/gemini-2.5-pro) - To route to a specific provider, see the Provider Routing docs
Known Issue: Tool Calls Error \
Temporary workaround: Modify the locally installed Gemini CLI file and comment out passingcallId.
-
Locate the file (replace the Node version in the path with your actual version):
-
Find the
handlePendingFunctionCallmethod (around line 183) and comment outcallId,: - Save the file and restart Gemini CLI.
Troubleshooting
Common Issues and Fixes
Gemini CLI prompts for Google sign-in after startup
Issue: A Google OAuth sign-in page opens when starting Gemini CLI. Solution:- Check whether
selectedTypein~/.gemini/settings.jsonis correctly set to"gemini-api-key" - Verify the config using
cat ~/.gemini/settings.json
API Key error
Issue: The API Key is reported as invalid or unauthorized. Solution:- Check that the API Key is correct (subscription keys start with
sk-ss-v1-, pay-as-you-go keys start withsk-) - Ensure the API Key is active and has sufficient balance
- Verify the key status in the AGIPower Console
Connection failure
Issue: Gemini CLI cannot connect to AGIPower. Solution:- Check your network connection
- Verify the Base URL is set to
https://api.agipower.ai - Check whether firewall settings are blocking outbound connections
- Try
curl https://api.agipower.ai/modelsto test connectivity
.env file not taking effect
Issue: Variables set in~/.gemini/.env do not take effect.
Solution:
- Gemini CLI loads
.envusing a nearest-first rule; once it finds the first one, it stops - Check whether there is already a
.envor.gemini/.envin the current project directory (it will override the global config) - Check whether the same variables were already
exported in your shell:env | grep -E "GEMINI_|GOOGLE_" - Check whether an earlier
.envfile exists in a parent directory that is being matched first - Reopen the terminal window, or run
source ~/.zshrcto reload your profile
function_response-related errors when editing files
Issue: When attempting to have Gemini CLI edit files automatically, you see errors like:- This is a known limitation—see the Tool Calls Error section
- For now, limit usage to Q&A and read-only analysis
- Do not rely on Gemini CLI for agent actions such as auto-editing or command execution
- Once AGIPower completes function calling compatibility, this will be supported automatically
Model unavailable
Issue: A model is reported as unavailable or unsupported. Solution:- Check availability via the AGIPower model list
- Verify the spelling of the model name in the
GEMINI_MODELenvironment variable - Try a default model such as
google/gemini-2.5-pro - Confirm your account has access to the model
Occasional request timeouts
Issue: Read-only file analysis requests occasionally time out. Solution:- Retrying usually works
- Reduce the size of the prompt and referenced files
- If timeouts are frequent, try a smaller model (e.g.,
google/gemini-2.5-flash) - Check that your network connection is stable
Sandbox mode issues
Issue: Command execution fails after enabling sandbox mode. Solution:- Ensure Docker is installed
- Check that Docker is running:
docker ps - Try disabling sandbox mode to test: set
"sandbox": falseinsettings.json - If using a custom sandbox, check the
.gemini/sandbox.Dockerfileconfiguration
Advanced Configuration
Project-Level Configuration
Gemini CLI supports creating a separate configuration in the project root to override global settings:Project-level settings.json
Project-level .env
- Different projects use different models
- Teams standardize default behavior
- Commercial projects use pay-as-you-go keys, personal projects use subscription keys
Session Retention
Gemini CLI supports retaining session history for reviewing previous conversations:~/.gemini/history/. Adjust maxAge as needed, or set it to false to disable retention.
Recommended Configurations for Different Scenarios
Daily Development
Code Review
Rapid Iteration