4Z API

Gemini CLI Relay Setup

Overview

Gemini CLI is Google's open-source command-line AI tool that brings Gemini into your terminal. With a relay (proxy), you can use it on restricted networks.

Why Gemini CLI?

  • Gemini 2.5 Pro: 1M-token context window
  • Built-in tools: Google Search grounding, files, shell, web fetch
  • Extensible: MCP for custom integrations
  • Terminal-first: Built for CLI developers
  • Open source: Apache 2.0

Installation

Quick install

Run with npx (no install)

# Official repo
npx https://github.com/google-gemini/gemini-cli

Install globally with npm

npm install -g @google/gemini-cli

Homebrew (macOS/Linux)

brew install gemini-cli

Requirements

  • Node.js 20+
  • macOS, Linux, or Windows

Configure a relay (proxy)

1. Environment variables

# API key
export GEMINI_API_KEY=sk-xxxxx

# Relay base URL
export GOOGLE_GEMINI_BASE_URL=https://4zapi.com

# CMD
set GEMINI_API_KEY=sk-xxxxx
set GOOGLE_GEMINI_BASE_URL=https://4zapi.com

Note: You can also add these to .bashrc, .zshrc, or another shell rc file.

Quick start

Basic usage

Current directory

gemini

Multiple directories

gemini --include-directories ../lib,../docs

Specific model

gemini -m gemini-3.5-flash-lite

Non-interactive / scripts

Text response:

gemini -p "Explain this repository architecture"

Structured JSON:

gemini -p "Explain this repository architecture" --output-format json

Quick examples

New project

cd new-project/
gemini
> Write a Discord bot that answers from my FAQ.md

Existing code

git clone https://github.com/google-gemini/gemini-cli
cd gemini-cli
gemini
> Summarize all changes from yesterday

Main features

Code understanding & generation

  • Query and edit large codebases
  • Generate apps from PDFs, images, or sketches
  • Debug with natural language

Automation & integration

  • Automate tasks like PR queries or complex rebases
  • Connect capabilities via MCP servers
  • Run non-interactively in scripts

Advanced

  • Built-in Google Search for live info
  • Conversation checkpoints
  • Customize behavior with GEMINI.md

Common commands

Explore a codebase

> Describe the main components of this architecture
> What security mechanisms exist?
> Write a step-by-step onboarding guide for new developers

Work with existing code

> Draft an implementation for GitHub issue #123
> Help migrate this repo to the latest Java. Start with a plan

Automate workflows

> Make slides of the last 7 days of git history grouped by feature and teammate
> Build a fullscreen wallboard of our hottest GitHub issues

System interaction

> Convert all images here to PNG and rename by EXIF date
> Organize my PDF invoices by spend month

GitHub integration

Use the Gemini CLI GitHub Action:

  • Pull request review: automated review with contextual feedback
  • Issue triage: auto-label and prioritize issues
  • On-demand help: mention @gemini-cli in issues/PRs
  • Custom workflows: automated, scheduled, and on-demand flows

Troubleshooting

  1. Confirm env vars:

    echo $GEMINI_API_KEY
    echo $GOOGLE_GEMINI_BASE_URL
    
  2. Check network / relay:

    curl -I https://4zapi.com
    
  3. Read error output

  4. SOCKS proxy format example: socks5://<user>:<pass>@<proxy>:<port>

  5. Report a bug from the CLI:

    /bug
    

Release channels

Preview

New preview every Tuesday 23:59 UTC:

npm install -g @google/gemini-cli@preview

Stable

New stable every Tuesday 20:00 UTC:

npm install -g @google/gemini-cli@latest

Nightly

Daily at 00:00 UTC:

npm install -g @google/gemini-cli@nightly

MCP servers

In ~/.gemini/settings.json configure MCP servers:

> @github list my open pull requests
> @slack post today's commit summary to #dev
> @database run a query for inactive users

Related resources

  • Official roadmap
  • NPM package registry
  • GitHub Issues
  • Security advisories

Uninstall

Follow the official uninstall guide.