gitmyhub

gcli2api

Python ★ 5.0k updated 1d ago

将 GeminiCLI 和 Antigravity 转换为 OpenAI 、GEMINI 和 Claude API 接口

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.

PythonDockerSQLiteMongoDBOAuthsetup: moderatecomplexity 3/5

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.

Where it fits