What is Gemini CLI?

The Gemini command line interface (CLI) is Google’s official AI coding assistant that runs directly in your terminal. It understands your codebase and helps you code faster through natural language commands.

Prerequisites

Before integrating Gemini CLI with TrueFoundry, ensure you have:
  1. TrueFoundry Account: A TrueFoundry account with at least one Gemini Provider Account configured and a Personal Access Token (Generate here)
  2. Gemini CLI Installation: Install Gemini CLI by running:
    npm install -g @google/gemini-cli
    

Setup Configuration

First, get the base URL and Provider Name from your TrueFoundry AI Gateway playground using the unified code snippet: Screenshot2025 09 24at7 39 04PM Pn Configure Gemini CLI to use TrueFoundry by setting these environment variables:
export GOOGLE_GEMINI_BASE_URL="https://{controlPlaneURL}/gemini/{googleGeminiProviderName}/proxy"
export GEMINI_API_KEY="your-truefoundry-api-key"
Replace the placeholders:
  • controlPlaneURL → Your TrueFoundry Control Plane URL
  • googleGeminiProviderName → Your Gemini Provider Account name
  • your-truefoundry-api-key → Your TrueFoundry Personal Access Token

Using Gemini CLI

  1. Start the CLI:
    gemini
    
  2. Setup Authentication:
    • If you see authentication options, choose Use Gemini API Key
    • If not prompted, type /auth and select the Use Gemini API Key option
Screenshot2025 09 24at7 46 24PM Pn
  1. Start using Gemini:
    # Ask about your code
    > Explain this function
    
    # Get code suggestions
    > Write a function to validate email addresses
    
    # Debug issues
    > Why is this giving me a syntax error?
    
You can now use Gemini CLI with all requests going through your TrueFoundry AI Gateway.
Why not Vertex AI?Gemini CLI supports both Vertex AI and Gemini API. However, Vertex AI mode constructs URLs automatically based on your GCP project and region, ignoring the GOOGLE_GEMINI_BASE_URL environment variable. Since TrueFoundry needs to route requests through our gateway, we use Direct Gemini mode which allows base URL customization.