Skip to main content

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 Google Gemini or Vertex AI 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

1. Create Provider Account

Create a provider account for either Google Gemini or Vertex AI:
Provider Support: Both Google Gemini and Vertex AI providers are supported. The gateway automatically handles the necessary transformations for Vertex AI when using the Gemini CLI.

2. Get Configuration Details

Get the base URL and Provider Name from your TrueFoundry AI Gateway playground using the unified code snippet: Screenshot2025 09 24at7 39 04PM Pn

3. Configure Environment Variables

Configure Gemini CLI to use TrueFoundry by setting these environment variables:
export GOOGLE_GEMINI_BASE_URL="https://{controlPlaneURL}/gemini/{providerAccountName}/proxy"
export GEMINI_API_KEY="your-truefoundry-api-key"
Replace the placeholders:
  • controlPlaneURL → Your TrueFoundry Control Plane URL
  • providerAccountName → Your Provider Account name (either Google Gemini or Vertex AI)
  • 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.
I