Skip to main content
Use this guide to run Gemini CLI with CometAPI as the API endpoint. Official references:
Model availability changes over time. Check the CometAPI Models page for currently available Gemini models.

Prerequisites

RequirementDetails
Node.js22+ (LTS recommended)
OSmacOS, Linux, or Windows
CometAPI keyFrom your CometAPI Dashboard (starts with sk-)

Setup

1

Install Gemini CLI

npm install -g @google/gemini-cli
Or via Homebrew (macOS / Linux):
brew install gemini-cli
Verify:
gemini --version
2

Set environment variables

export GEMINI_API_KEY="sk-your-cometapi-key"
export GOOGLE_GEMINI_BASE_URL="https://api.cometapi.com"
Replace sk-your-cometapi-key with your actual CometAPI key.
3

Start Gemini CLI

cd your-project
gemini
On first launch, you’ll be prompted to choose a theme, confirm the safety notice, and trust the working directory.

Persist environment variables

To avoid re-exporting every session, add to your shell config:
# Add to ~/.zshrc (macOS) or ~/.bashrc (Linux)
export GEMINI_API_KEY="sk-your-cometapi-key"
export GOOGLE_GEMINI_BASE_URL="https://api.cometapi.com"
Restart your terminal for changes to take effect.

Troubleshooting

SymptomFix
Invalid API Key errorVerify GEMINI_API_KEY is set correctly. Run echo $GEMINI_API_KEY to check
fetch failedNetwork restrictions may block the connection. Try a system-wide proxy
Wrong Node.js versionGemini CLI requires Node.js 22+. Run node --version to check
Uninstallnpm uninstall -g @google/gemini-cli