Guide

Gemini CLI with a custom endpoint and free models

Gemini CLI is Google's open-source coding agent for the terminal. It can send its requests to a custom base URL. This guide points Gemini CLI at FreeLLMAPI, which serves the native Gemini API on /v1beta. Your requests then go to your pool of free providers, which can include free Gemini API keys.

The 2026 change to the Gemini CLI free tier

Read this first. Google changed the free use of Gemini CLI in 2026. The Gemini CLI quota page says: "Unpaid tier and Google One users: Gemini CLI was replaced by Antigravity CLI on June 18th, 2026."

Google's announcement says that Gemini CLI stays available through paid Gemini API keys and for enterprise customers.

  • Google login on the free tier: no longer served by Gemini CLI for consumer accounts.
  • Gemini API key with a custom base URL: the Gemini CLI configuration reference still documents GOOGLE_GEMINI_BASE_URL. With this variable, Gemini CLI sends its requests to the URL that you set, not to Google.
  • Free Gemini API keys: Google AI Studio still lists a free tier for the Gemini API. FreeLLMAPI can use those keys, together with keys from other providers.

This guide uses the second method. FreeLLMAPI answers the requests and sends each one to a free model in your pool.

Step 1: Install FreeLLMAPI and Gemini CLI

Install both

curl -fsSL https://freellmapi.co/install.sh | bash
npm install -g @google/gemini-cli

Open http://localhost:3001. Add at least two free provider keys on the Keys page. A free Google AI Studio key is a good first key. Copy your unified key from the same page.

Step 2: Point Gemini CLI at the gateway

Set two environment variables and start Gemini CLI. The base URL is the server origin, without /v1beta. Gemini CLI adds the API path itself.

macOS or Linux

export GOOGLE_GEMINI_BASE_URL=http://localhost:3001
export GEMINI_API_KEY=<unified-key>
gemini

Windows PowerShell

$env:GOOGLE_GEMINI_BASE_URL="http://localhost:3001"
$env:GEMINI_API_KEY="<unified-key>"
gemini

When Gemini CLI asks for an authentication method, select Use Gemini API key. To save the choice, set it in ~/.gemini/settings.json:

~/.gemini/settings.json

{
  "security": {
    "auth": {
      "selectedType": "gemini-api-key"
    }
  }
}
Important: use GEMINI_API_KEY. A Gemini CLI issue reports that version 0.44.x fails with "Invalid auth method selected" when GOOGLE_API_KEY is used with GOOGLE_GEMINI_BASE_URL. If GOOGLE_API_KEY is set, remove it with unset GOOGLE_API_KEY.

Step 3: Map Gemini model names to free models

Gemini CLI asks for Gemini model names, for example gemini-2.5-flash. FreeLLMAPI does not send these names to Google directly. It resolves them through the Gemini family map on the Keys, Agents tab. Map each family (Pro, Flash and Flash-Lite) to Auto or to a pinned catalog model.

  • With Auto, the router selects a free model for each request. When one provider sends a 429 error, it tries the next one.
  • Catalog ids also work as model names. Start Gemini CLI with gemini -m <catalog-id>, or set GEMINI_MODEL.
  • Gemini CLI is an agent with tools. Map the families to models with tool calling and a large context window.

The first table shows the free Gemini models in the catalog today. The second table shows other free models that you can map to a Gemini family.

Free Gemini API models with tool calling (Google AI Studio)
ModelFree onContextFree limits (best offer)ToolsVision
Gemini 3.8 FlashGoogle AI Studio1MRecurring provider quotaYesYes
Gemini Flash (latest alias)Google AI Studio-10 req/min
20 req/day
250,000 tokens/min
~3M
YesYes
Gemini 3.7 FlashGoogle AI Studio1M10 req/min
20 req/day
250,000 tokens/min
~3M
YesYes
Gemini 3.6 FlashGoogle AI Studio1M10 req/min
20 req/day
250,000 tokens/min
~3M
YesYes
Gemini 3.5 FlashGoogle AI Studio1M10 req/min
20 req/day
250,000 tokens/min
~3M
YesYes
Gemini 3.8 LiveGoogle AI Studio-10 req/min
20 req/day
250,000 tokens/min
~3M
YesYes
Gemini 3.8 Live Extended ThinkingGoogle AI Studio-10 req/min
20 req/day
250,000 tokens/min
~3M
YesYes
Gemini 3.5 Flash LiteGoogle AI Studio1M15 req/min
20 req/day
250,000 tokens/min
~3M
YesYes

Showing 8 of 14 matching free models. See all models.

Live data from the FreeLLMAPI catalog (version 2026.11.19, checked 19 November 2026). Free limits change often. The catalog is checked every day.

Other free models for Gemini CLI: tool calling and 128K+ context
ModelFree onContextFree limits (best offer)ToolsVision
GLM 5.3UnoRouter1M1 req/min
1 req/min per model
YesNo
GLM 5.3 FlashNVIDIA NIM, UnoRouter1M40 req/min
40 RPM
YesYes
Qwen3.8 Flash NextAMD Radeon Cloud262KRecurring daily account allowanceYesNo
Qwen3.8 FlashElectronHub1M$0.25/week shared recurring creditYesYes
GPT-5.6 LunaElectronHub1M$0.25/week shared recurring creditYesYes
Dots3 Note PreviewKilo Gateway, OpenRouter512K20 req/min
50 req/day
50 req/day account-wide (1,000 after a $10 purchase)
YesYes
DeepSeek V4 FlashAMD Radeon Cloud, BazaarLink, ElectronHub1M10 req/min
50 req/day
Shared rate limit
YesNo
Qwen3.8 27BElectronHub, Groq, OVH AI Endpoints262K30 req/min
250 req/day
70,000 tokens/min
~6M
YesYes

Showing 8 of 104 matching free models. See all models.

Live data from the FreeLLMAPI catalog (version 2026.11.19, checked 19 November 2026). Free limits change often. The catalog is checked every day.

Gemini free tier limits

Google's rate limit page says that limits apply per project, not per API key. More keys in one project do not give more quota. Google also says that limits are not guaranteed and that you can see your current limits in Google AI Studio. Preview models have lower limits.

A free Gemini Flash key allows few requests per day. One Gemini CLI task can send many requests. Add keys from other providers, so the router can continue when the Gemini quota stops. The native surface supports generateContent, streamGenerateContent with ?alt=sse, countTokens and the models list.

FreeLLMAPI accepts the key in the x-goog-api-key header, as a Bearer token or in Gemini's ?key= query parameter. Prefer a header, because a key in a URL can leak into shell history and proxy logs.

Troubleshooting

ProblemCauseFix
Gemini CLI opens a Google loginThe auth type is not set to Gemini API keySelect Use Gemini API key, or set security.auth.selectedType
"Invalid auth method selected"GOOGLE_API_KEY is used with a custom base URLUse GEMINI_API_KEY and unset GOOGLE_API_KEY
Requests go to Google, not to the gatewayGOOGLE_GEMINI_BASE_URL is not set in this shellExport the variable, then start gemini again
404 on model callsThe base URL includes /v1betaUse the origin http://localhost:3001 only
Tool calls failThe Gemini family maps to a model with weak tool callingMap the family to a model from the tables above
"All models rate-limited after N attempts"All keys are at their limitAdd keys from more providers, or wait for the cooldowns
Use every one of these through one key. FreeLLMAPI is an open-source, self-hosted router that puts all these free tiers behind a single OpenAI-compatible endpoint and fails over when one is rate-limited. Browse the catalog or go live.

Frequently asked questions

Is Gemini CLI still free?

Google ended free Gemini CLI use with a Google login for unpaid and Google One users on 18 June 2026. The CLI still supports a custom base URL, so it can run on a free gateway such as FreeLLMAPI.

How do I use Gemini CLI with a custom endpoint?

Set GOOGLE_GEMINI_BASE_URL to the endpoint origin and GEMINI_API_KEY to its key, then select Use Gemini API key. The endpoint must speak the native Gemini API on /v1beta.

Can Gemini CLI use models that are not Gemini?

Yes, through FreeLLMAPI. The gateway maps the Gemini Pro, Flash and Flash-Lite family names to Auto or to any catalog model, for example a Qwen or GLM model.

What are the Gemini API free tier limits?

Google sets the limits per project, not per key, and shows the current values in Google AI Studio. The table on this page shows today's free Gemini models and their limits from the FreeLLMAPI catalog.

Why do I get 'Invalid auth method selected'?

A Gemini CLI issue reports this error in version 0.44.x when GOOGLE_API_KEY is used with GOOGLE_GEMINI_BASE_URL. Use GEMINI_API_KEY and unset GOOGLE_API_KEY.

Sources

All guides · Browse all free models

Keep reading

All posts →
Guide

Best free LLM APIs 2026

Ten genuinely free LLM APIs worth using — ranked, with real limits.

Guide

Unlimited free AI tokens?

No free AI API is unlimited. The closest real thing: 10.1 billion free tokens a month behind one key.

Guide

How to get a free LLM API key

Get a working key in minutes — no credit card required.