Skip to content

Latest commit

 

History

History
80 lines (58 loc) · 2.12 KB

File metadata and controls

80 lines (58 loc) · 2.12 KB

Use Gemini CLI with CometAPI

Canonical docs: https://apidoc.cometapi.com/integrations/gemini-cli

Use this guide to configure Gemini CLI with CometAPI credentials, base URL settings, and Gemini model IDs. Use this guide to run Gemini CLI with CometAPI as the API endpoint.

Official references:

Note Model availability changes over time. Check the CometAPI Models page for available Gemini models.

Prerequisites

Requirement Details
Node.js 22+ (LTS recommended)
OS macOS, Linux, or Windows
CometAPI key From your CometAPI Dashboard (starts with sk-)

Setup

Install Gemini CLI

npm install -g @google/gemini-cli

Or via Homebrew (macOS / Linux):

brew install gemini-cli

Verify:

gemini --version

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.

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

Invalid API Key error

Verify GEMINI_API_KEY is set correctly. Run echo $GEMINI_API_KEY to check.

fetch failed

Network restrictions may block the connection. Try a system-wide proxy.

Wrong Node.js version

Gemini CLI requires Node.js 22+. Run node --version to check.

Uninstall Gemini CLI

Run npm uninstall -g @google/gemini-cli.