explaingit

su-kaka/gcli2api

4,751PythonAudience · developerComplexity · 3/5Setup · moderate

TLDR

A Python server that bridges Google's free Gemini CLI to standard AI API formats (OpenAI, Gemini, Claude), so any app that already talks to those APIs can use Gemini without paying for API keys.

Mindmap

mindmap
  root((gcli2api))
    What it does
      API proxy server
      Credential rotation
      Format translation
    Tech Stack
      Python
      Docker
      SQLite
      OAuth
    Use Cases
      Free Gemini API access
      Multi-account balancing
      Image generation via API
    Audience
      Developers
      AI app builders
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Route your AI coding tool's API calls through a free Gemini account instead of paying for OpenAI or Anthropic API access.

USE CASE 2

Run a local server that load-balances across multiple Google accounts, automatically rotating credentials when one runs low on quota.

USE CASE 3

Use Gemini image generation models through a standard API endpoint with custom resolution and aspect ratio parameters.

USE CASE 4

Deploy a multi-instance setup with MongoDB for teams sharing Gemini quota across multiple users.

Tech stack

PythonDockerSQLiteMongoDBOAuth

Getting it running

Difficulty · moderate Time to first run · 30min

Requires a Google account and completing an OAuth login through Gemini CLI before the server can make requests.

In plain English

gcli2api is a Python tool that turns Google's Gemini CLI tool and a service called Antigravity into API servers that other software can talk to. It translates between the formats those tools use internally and the standard API formats used by OpenAI, Gemini, and Claude, so existing apps and coding tools that already know how to talk to those APIs can route their requests through Gemini without any changes to the calling software. The README is written primarily in Chinese. The core idea is credential bridging. Instead of paying for Gemini API keys directly, users can log in through Google's OAuth flow and have gcli2api manage those login credentials. The server rotates through multiple saved credentials automatically, spreads load across them, detects when one stops working, and disables it. Each credential provides a quota of requests. A web dashboard lets you upload, enable, disable, and monitor credentials through a browser. The server exposes several API endpoints depending on which format the calling software expects: an OpenAI-compatible chat endpoint, a native Gemini endpoint, and a Claude-format endpoint. It handles streaming responses, multi-turn conversation context, and thinking-mode models that separate reasoning steps from final answers. Installation is available for Windows, Linux, macOS, Termux (Android terminal), and Docker. The Docker path is the simplest for most users: one command starts the server with a password and a mounted credential folder. The default storage is a local SQLite database, with an optional MongoDB mode for deployments running multiple instances. The project supports Gemini 2.5 Pro and related models, plus image generation models through Antigravity. Model names can include suffixes to control resolution and aspect ratio for image outputs.

Copy-paste prompts

Prompt 1
Set up gcli2api with Docker so my OpenAI-compatible app can route requests to Gemini 2.5 Pro for free using my Google account, show me the Docker command and how to add credentials.
Prompt 2
How do I add multiple Google credentials to gcli2api and configure automatic rotation when one account runs out of quota?
Prompt 3
Configure gcli2api to expose a Claude-format endpoint so I can use it with apps that talk to the Anthropic API without any code changes.
Open on GitHub → Explain another repo

← su-kaka on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.