Zero-Cost Guide to Deploying an AI Coding Assistant on Windows

    This guide provides step-by-step instructions for deploying the open-source command-line tool Gemini CLI as an AI coding assistant on Windows. It covers prerequisite checks, tool installation, free API key generation, environment variable configuration, and connectivity verification, ideal for developers with basic terminal experience looking to trial an AI coding assistant at zero cost in about half an hour.

    1. Introduction

    Many developers want to use natural language directly in the Windows command line to let AI read code, write scripts, and explain errors. The open-source command-line tool Gemini CLI can achieve this, utilizing a free API key available with a personal Google account. This article uses Gemini CLI as an example, detailing every step from environment checks to your first conversation. By following this guide, you can get everything running in about half an hour.

    This guide is intended for readers who have basic terminal operation experience, use Windows 10 or Windows 11, and wish to try an AI coding assistant on their personal computers at a low cost. It assumes you accept the premise that free quotas are limited and rate-limiting rules may change. This article does not cover enterprise account configuration or private deployments.

    2. Pre-Installation Checks

    Before starting the installation, confirm the following four items.

    1. Node.js Environment: Open PowerShell and execute the following two commands:
    1. node -v
    2. npm -v

    If both commands output version numbers, you are good to go. It is recommended to install the current LTS version of Node.js, which can be downloaded from the official website. Gemini CLI has minimum version requirements for Node, so refer to the project’s README for specifics.

    1. Terminal Permissions: In most cases, a standard terminal is sufficient for installation. You only need an administrator terminal if the npm global directory is located in a protected path like Program Files. In Windows 11, press Win + X and select “Terminal (Admin)”. When the User Account Control prompt appears, confirm it is your own action and click “Yes”.

    2. Network Connectivity: Ensure your machine can access Google services. If a proxy is required, temporarily set the environment variables in your terminal:

    1. $env:HTTP_PROXY = "http://127.0.0.1:7890"
    2. $env:HTTPS_PROXY = "http://127.0.0.1:7890"

    The port 7890 is just a common example. Please check your proxy software’s settings page for the actual HTTP port and replace the number accordingly. These two commands only take effect for the current window and will be lost once closed. If you want them to persist, you can add them to your system environment variables, but the proxy software must remain running for internet access.

    1. Google Account: Used to log in to Google AI Studio to obtain the API key.

    3. Installing Gemini CLI

    Execute the following commands in your terminal sequentially:

    1. npm install -g @google/gemini-cli
    2. gemini --version

    The first command installs the tool globally. The second command outputs the version number, indicating a successful installation.

    If you receive a prompt saying “gemini is not recognized”, it means the npm global directory is not added to your PATH. Run npm config get prefix to find the path, which usually looks like C:\Users\YourUsername\AppData\Roaming\npm. Add this path to your user environment variables Path, close all terminal windows, and try again after reopening.

    Before installing, verify the package name. Only install from the official npm source, and confirm the package name and publisher through the project’s official repository (the gemini-cli under the google-gemini organization on GitHub) to avoid mistakenly installing third-party packages with the same name.

    4. Applying for a Free API Key

    1. Open Google AI Studio and log in with your Google account.
    2. Navigate to the API key page, typically found at aistudio.google.com/apikey, and click to create an API key.
    3. Copy the generated string. The key is only fully displayed at creation; if lost, it must be regenerated.

    The scope of free quotas, per-minute and per-day request limits, and the list of available models are subject to change. Before applying, please check the official Google AI for Developers documentation for pricing or rate limits to confirm current rules. The free tier is usually sufficient for personal daily Q&A and small scripting tasks. If you need large-scale batch calls, you should evaluate costs directly under a paid plan.

    5. Configuring the Key and First Launch

    It is recommended to save the key as a user-level environment variable to avoid entering it every time you start. Execute the following command in a standard PowerShell window, replacing the text inside the quotes with your actual key:

    1. [Environment]::SetEnvironmentVariable("GEMINI_API_KEY", "replace_with_your_key_here", "User")

    Then close and reopen your terminal, and execute the following command to check:

    1. if ($env:GEMINI_API_KEY) { "Set" } else { "Not Set" }

    If it outputs “Set”, you are good to go. Do not print the actual key content, nor screenshot it or paste it into chats.

    The tool’s configuration directory is located in the .gemini folder under your user home directory, specifically %USERPROFILE%\.gemini\. If a settings.json file already exists there, you can adjust behavioral options inside it. If the file does not exist, there is no need to create it manually; the tool will use default values.

    Execute gemini in any project directory. Upon first launch, follow the prompts to select the authentication method using the Gemini API key, and the tool will read the GEMINI_API_KEY you have already set.

    6. Verifying Connectivity

    Verify connectivity in two steps.

    The first step is an interactive conversation. Type gemini in your terminal, and after entering the interactive interface, type “Introduce yourself in one sentence”. Receiving a response from the model indicates that the setup is successful and you are ready to start using your AI coding assistant.