Gemini CLI

Powering Gemini CLI with XAI

Gemini CLI is the official command-line tool from Google, allowing you to interact directly with the powerful Gemini family of models in your terminal.

Due to the various restrictions on Google accounts, XAI has seamlessly adapted the Gemini CLI. XAI provides free support through a load-balanced pool of 10 Gemini API Keys.

Prerequisites

Before you begin, make sure you have:

  • Node.js (version 18 or higher) and npm installed.

Step 1: Install Gemini CLI

First, install the Gemini CLI globally on your system using npm (Node Package Manager). Open your terminal and run the following command:

npm install -g @google/gemini-cli

After a successful installation, you will be able to use the gemini command from anywhere in your terminal.

Step 2: Configure Environment Variables

Configuring environment variables is the key step to running Gemini CLI through XAI. We need to set two variables: one to specify the API endpoint, and another for your API Key.

Add the following two lines to your shell's configuration file (e.g., ~/.zshrc or ~/.bashrc).

export GOOGLE_GEMINI_BASE_URL="https://api.xaixapi.com"
export GEMINI_API_KEY="sk-XvskBeymPs0X6HSju25MQ9WU8jtITF5GKG7GmV9TCvYVlk1B"

After adding the lines, run source ~/.zshrc (or your corresponding configuration file) or restart your terminal for the changes to take effect.

Step 3: Start Using

All configurations are now complete! You can now start the Gemini CLI directly in your terminal.

gemini

Once the program starts, you can begin asking questions immediately. Because we have configured the environment variables, the Gemini CLI will automatically use your XAI API Key and connect through our service, requiring no additional manual authentication steps.

You: >> Write a Python function to calculate the Fibonacci sequence

Enjoy!