Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.gravitex.ai/llms.txt

Use this file to discover all available pages before exploring further.

1. Overview

Gemini CLI is Google’s official command-line AI coding tool that lets you interact with Gemini models directly from your terminal. Through GravitexAI as the gateway, you can:

Terminal-native

Call Gemini 3.5 / 3.1 / 2.5 models right from your shell

AI-assisted coding

Code generation, review and unit-test automation

Smart Q&A

Tech questions, architecture design and debugging

Docs generation

Auto-generate READMEs, API docs and JSDoc comments
Using GravitexAI as the gateway gives you optimized connectivity, unified API key management, and one-stop access to Claude, GPT and Gemini under a single account.

2. Prerequisites

  • Node.js ≥ 18.0.0
  • npm or yarn
  • An API key from the GravitexAI console (format sk-xxxxxxxxxx)

3. Quick Start

Step 1 — Install Gemini CLI

node --version  # must be >= 18

npm install -g @google/gemini-cli

gemini --version

Step 2 — Get a GravitexAI API key

1

Sign in to GravitexAI

Go to maas.gravitex.ai and register or log in.
2

Create an API key

Open the API Keys page and click “Create new token”.
3

Copy the key

Copy the generated key (format: sk-xxxxxxxxxx) and store it safely.

Step 3 — Configure environment variables

Important: GOOGLE_GEMINI_BASE_URL must be set to https://api.gravitex.ai. Do not append /v1, /gemini, or any other path — it will break the connection.
# Edit your .zshrc
nano ~/.zshrc

# Add these environment variables
export GOOGLE_GEMINI_BASE_URL="https://api.gravitex.ai"
export GEMINI_API_KEY="sk-your-gravitex-key"  # replace with your GravitexAI key

# Reload
source ~/.zshrc

Step 4 — Initialize and test

1

Start the CLI

gemini
2

First-time auth

In the interactive UI, type:
/auth
Choose Gemini API Key (AI Studio).
3

Test the connection

# Simple test
gemini "Hello, is the connection working?"

# Coding test
gemini "Explain how to use React Hooks"
gemini "Write a Python function that computes Fibonacci numbers"
GravitexAI ships with the latest Gemini family. All of these are callable from the CLI:
Model IDBest forNotes
gemini-3.5-flashHigh-throughput chat, low-latency toolsLatest fast variant, fastest in class
gemini-3.1-pro-previewDeep reasoning, high-quality codegenNext-gen core model
gemini-3.1-flash-lite-previewHigh-concurrency, batch jobsBest price/perf fast tier
gemini-3.1-flash-image-previewImage understanding / text-to-imageMultimodal enhanced
gemini-3-pro-image-previewHigh-quality text-to-imageImage-focused variant
gemini-3-flash-previewMulti-turn chat, tool useBalanced speed and quality
Suggested defaults:
  • Complex coding / architecture: gemini-3.1-pro-preview
  • Daily coding & Q&A: gemini-3.5-flash
  • Batch / high-frequency: gemini-3.1-flash-lite-preview
See the GravitexAI model list for the full catalog.

5. Core Features

5.1 Code generation

gemini "Write a quicksort algorithm in Python with detailed comments"
Sample output:
def quick_sort(arr):
    """
    Quicksort
    Time:  O(n log n) avg, O(n^2) worst
    Space: O(log n)
    """
    if len(arr) <= 1:
        return arr

    pivot = arr[len(arr) // 2]
    left = [x for x in arr if x < pivot]
    middle = [x for x in arr if x == pivot]
    right = [x for x in arr if x > pivot]

    return quick_sort(left) + middle + quick_sort(right)

5.2 Code review

# Performance / bugs
gemini "Review this code for performance issues and potential bugs:
[paste your code]"

# Security audit
gemini "Audit this code for security vulnerabilities, especially SQL injection and XSS"

# Best practices
gemini "What can be improved in this React component? Does it follow best practices?"

5.3 Technical Q&A

gemini "Explain JavaScript closures with real-world use cases"
gemini "Why is my Promise not resolving correctly?"
gemini "Compare microservices vs. monolithic architecture pros and cons"

5.4 Documentation generation

gemini "Generate a professional README.md for my Node.js library, including install, usage and API docs"
gemini "Generate OpenAPI 3.0 spec for this REST endpoint"
gemini "Add detailed JSDoc comments to the following code"

6. Interactive Commands

CommandDescriptionExample
/authRe-authenticate/auth
/modelSwitch model/model gemini-3.1-pro-preview
/clearClear conversation/clear
/helpShow help/help
/exitQuit CLI/exit or Ctrl+C
/saveSave conversation to file/save conversation.txt
Switching models: use /model interactively, or specify via --model:
gemini --model gemini-3.1-pro-preview "your question"
gemini --model gemini-3.5-flash "quick test"

7. Advanced Usage

7.1 GitHub Actions (automated review)

name: Gemini Code Review
on:
  pull_request:
    branches: [ main ]

jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - uses: actions/setup-node@v3
        with:
          node-version: '18'

      - name: Install Gemini CLI
        run: npm install -g @google/gemini-cli

      - name: Run Code Review
        env:
          GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
          GOOGLE_GEMINI_BASE_URL: https://api.gravitex.ai
        run: |
          gemini "Review this Pull Request for quality, security and performance:
          $(git diff origin/main...HEAD)"

7.2 Batch scripts

#!/bin/bash

# Batch code review
for file in src/**/*.js; do
  echo "Reviewing $file..."
  gemini "Review code quality of $file" < "$file"
done

# Generate project doc outline
gemini "Generate a technical doc outline for the whole project" < README.md

8. FAQ

Checklist:
  1. Env vars correct?
    echo $GOOGLE_GEMINI_BASE_URL
    echo $GEMINI_API_KEY
    
    Expected:
    • GOOGLE_GEMINI_BASE_URL: https://api.gravitex.ai (no /v1 or other path)
    • GEMINI_API_KEY: full sk-… key
  2. Reload env:
    source ~/.zshrc  # or source ~/.bashrc
    
  3. Restart terminal: close and reopen the terminal window.
  4. Validate the key in the GravitexAI console — ensure it’s active and has balance.
Option A — interactive /model:
/model gemini-3.1-pro-preview
/model gemini-3.5-flash
Option B — CLI flag:
gemini --model gemini-3.1-pro-preview "your question"
gemini --model gemini-3.5-flash "quick test"
Method 1: use /save
/save conversation-2025-01-01.txt
Method 2: shell redirection
gemini "your question" > output.txt
gemini "your question" | tee output.txt   # show and save
Use nvm to manage Node:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash

nvm install 18
nvm use 18
nvm alias default 18

node --version
Possible causes and fixes:
  1. Network: GravitexAI provides optimized routes; check status on the console.
  2. Model choice: use gemini-3.5-flash or gemini-3.1-flash-lite-preview for fastest responses.
  3. Token size: reduce request complexity and context length.
Benchmark:
time gemini --model gemini-3.5-flash "Hello"
PowerShell (recommended):
  1. Install Node.js from nodejs.org
  2. Open PowerShell as Administrator
  3. Set env vars:
    [System.Environment]::SetEnvironmentVariable('GOOGLE_GEMINI_BASE_URL', 'https://api.gravitex.ai', 'User')
    [System.Environment]::SetEnvironmentVariable('GEMINI_API_KEY', 'sk-your-key', 'User')
    
  4. Restart PowerShell
  5. Install: npm install -g @google/gemini-cli
Or use WSL for a more native experience.

9. Best Practices

Prompt design

Be specific

❌ “Optimize this code”✅ “Optimize this code for performance, focus on loop efficiency and memory use”

Provide context

❌ “What’s wrong with this function?”✅ “This handles user login and throws an async error — help me find the bug”

Break into steps

❌ “Build the whole project”✅ “Step 1: design DB model; Step 2: build API routes; Step 3: …”

Ask for examples

❌ “Explain closures”✅ “Explain JS closures with 3 practical scenarios and code examples”
1

Define the problem

Clearly describe what you want to solve or build.
2

Get a solution

Use Gemini CLI to draft an initial solution or code.
3

Review & refine

Ask the AI to review its own output and flag issues.
4

Iterate

Improve step by step based on feedback.
5

Add docs

Generate comments and documentation.

10. References

Get going in 5 minutes: follow the “Quick Start” section above and you’ll be using Gemini CLI in no time.