DOC 04Clients
Gemini CLI Setup Guide
Install Gemini CLI, configure the spiderai endpoint and key, and verify the connection from the command line.
Gemini CLI is Google’s official AI assistant for the terminal. Follow these steps to install it and connect it to spiderai.
Step 1: Install Gemini CLI
npm install -g @google/gemini-clisudo npm install -g @google/gemini-clinpm install -g @google/gemini-cliOn macOS you can also use Homebrew:
brew install gemini-cliVerify installation; a version number means it worked:
gemini --versionStep 2: Configure environment variables
Set these three environment variables to connect Gemini CLI to spiderai:
GOOGLE_GEMINI_BASE_URLEndpoint, without /v1https://api.spiderai.funGEMINI_API_KEYAPI key from a Gemini groupYOUR_API_KEYGEMINI_MODELModel to usegemini-3.8-flash
Temporary (current terminal only):
$env:GOOGLE_GEMINI_BASE_URL = "https://api.spiderai.fun"
$env:GEMINI_API_KEY = "YOUR_API_KEY"
$env:GEMINI_MODEL = "gemini-3.8-flash"export GOOGLE_GEMINI_BASE_URL="https://api.spiderai.fun"
export GEMINI_API_KEY="YOUR_API_KEY"
export GEMINI_MODEL="gemini-3.8-flash"export GOOGLE_GEMINI_BASE_URL="https://api.spiderai.fun"
export GEMINI_API_KEY="YOUR_API_KEY"
export GEMINI_MODEL="gemini-3.8-flash"Persistent (applies to new terminals):
[System.Environment]::SetEnvironmentVariable("GOOGLE_GEMINI_BASE_URL", "https://api.spiderai.fun", [System.EnvironmentVariableTarget]::User)
[System.Environment]::SetEnvironmentVariable("GEMINI_API_KEY", "YOUR_API_KEY", [System.EnvironmentVariableTarget]::User)
[System.Environment]::SetEnvironmentVariable("GEMINI_MODEL", "gemini-3.8-flash", [System.EnvironmentVariableTarget]::User)echo 'export GOOGLE_GEMINI_BASE_URL="https://api.spiderai.fun"' >> ~/.bashrc
echo 'export GEMINI_API_KEY="YOUR_API_KEY"' >> ~/.bashrc
echo 'export GEMINI_MODEL="gemini-3.8-flash"' >> ~/.bashrc
source ~/.bashrcecho 'export GOOGLE_GEMINI_BASE_URL="https://api.spiderai.fun"' >> ~/.zshrc
echo 'export GEMINI_API_KEY="YOUR_API_KEY"' >> ~/.zshrc
echo 'export GEMINI_MODEL="gemini-3.8-flash"' >> ~/.zshrc
source ~/.zshrcYOUR_API_KEY with a Gemini group key copied from API Keys. To use another model, change GEMINI_MODEL.Step 3: Start using Gemini CLI
Run this from your project directory:
geminiOn the first start, choose Trust folder, then choose Use Gemini API Key as the sign-in method (preselected when GEMINI_API_KEY is set) and press Enter. You can then start chatting.
Test command
After the first-start setup, ask a one-off question in the same directory:
gemini -p "Hello"Settings for command-line mode (-p) onlyRunning gemini -p before the first-start setup fails with Invalid auth method selected.
Write ~/.gemini/settings.json to select API key sign-in:
mkdir -p ~/.gemini
cat > ~/.gemini/settings.json << 'EOF'
{ "security": { "auth": { "selectedType": "gemini-api-key" } } }
EOFsecurity.auth.selectedType into it instead.In a folder you have not trusted, add --skip-trust:
gemini -p "Hello" --skip-trustFor more information, see the Google AI documentation.