Gemini CLI
Overview
Gemini CLI is Google's open-source terminal AI coding assistant, known for its very large context window, making it great for long files and large codebases. Through dedicated environment variables pointing to the TokenPlus root domain, you can use TokenPlus's Gemini and other compatible models.
Installation
- Make sure Node.js is installed (the CLI requires it)
- Run npm install -g @google/gemini-cli in the terminal
- Run gemini --version to verify
Configure TokenPlus
Gemini CLI does not recognize the generic OPENAI variables; you must use GEMINI_API_KEY and GOOGLE_GEMINI_BASE_URL, and the Base URL is only the root domain (no /v1) - the CLI appends the path automatically.
# Temporary (current terminal)
export GEMINI_API_KEY="sk-your-TokenPlus-key"
export GOOGLE_GEMINI_BASE_URL="https://tokenplus.net"
export GEMINI_MODEL="gemini-2.5-flash"
# Permanent: append to ~/.bashrc / ~/.zshrc then source
echo 'export GEMINI_API_KEY="sk-your-TokenPlus-key"' >> ~/.zshrc
echo 'export GOOGLE_GEMINI_BASE_URL="https://tokenplus.net"' >> ~/.zshrc
echo 'export GEMINI_MODEL="gemini-2.5-flash"' >> ~/.zshrc
source ~/.zshrc
GOOGLE_GEMINI_BASE_URL must be the clean root domain https://tokenplus.net - never write https://tokenplus.net/v1, or it will build a /v1/v1beta path and error out. The variable name must be GEMINI_API_KEY, not OPENAI_API_KEY.
Quick start (up and running in 5 minutes)
- Install gemini-cli (npm i -g)
- Export GEMINI_API_KEY and GOOGLE_GEMINI_BASE_URL in the same terminal
- Run gemini; the first screen skips login and drops you into the interactive prompt (>)
- Type "Introduce yourself" and a reply means the config is working
FAQ
- Invalid URL (/v1/v1beta...)? Remove the /v1 at the end of the Base URL, leaving only the root domain
- A large number of [API Error] and forced auth selection? The variables were not read - check the variable names and the terminal window
- Model not found? Confirm GEMINI_MODEL is the exact full name of a model actually supported by TokenPlus