gcli2api: turn GeminiCLI and Antigravity credentials into OpenAI, Gemini and Claude API endpoints
将 GeminiCLI 和 Antigravity 转换为 OpenAI 、GEMINI 和 Claude API 接口
At a glance
- What is it?
- gcli2api is a Python proxy that exposes the Google accounts behind GeminiCLI and Antigravity as OpenAI-, Gemini- and Claude-compatible API endpoints, with credential rotation, a web console and one-line installers for Termux, Windows, Linux, macOS and Docker. It is a self-hosted gateway, not a hosted service.
- Who is it for?
- Run gcli2api if you have Google accounts with GeminiCLI or Antigravity access and want to reach them from any OpenAI-, Gemini- or Claude-format client behind one endpoint. Start with the Docker command and a strong password, use the separate API and panel passwords in production, and add more credential files so the built-in rotation can keep going when one hits its quota.
- Can I use it commercially?
- Check first. The repository uses a licence we do not classify automatically, so read its LICENSE file before any commercial use.
- Is it still maintained?
- Yes. The repository last received commits 1 day ago.
- What is it written in?
- Mainly Python, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on September 15, 2026, and from our analysis. They are not legal advice.
DEEP OPEN-SOURCE ANALYSIS
What gcli2api does and who runs it
gcli2api sits between your clients and Google's Gemini backends. The README's one-line summary is that it converts GeminiCLI and Antigravity into interfaces compatible with the OpenAI, Gemini and Claude APIs. You authenticate Google accounts through its web console, and it then answers requests in whichever of those three formats your client speaks.
That design tells you who it is for: developers who have Google accounts with GeminiCLI or Antigravity access and want to use them from tools written for other APIs, without rewriting each tool. Because you self-host it and it holds your Google OAuth credentials, it is not something to hand to untrusted users; it is infrastructure you run for yourself or your team. The project is written in Python, requires Python 3.12 or newer, and ships a Dockerfile, a docker-compose.yml and install scripts for several platforms.
The three API formats it speaks
The README lists the endpoints in detail. The OpenAI-compatible surface is /v1/chat/completions and /v1/models, and it accepts both the OpenAI messages structure and the Gemini contents structure, detecting and converting between them without a manual switch, including multimodal text-and-image input. The Gemini-native surface is /v1/models/{model}:generateContent and streamGenerateContent, with authentication by Bearer token, an x-goog-api-key header or a key URL parameter. The Claude-compatible surface is /v1/messages, following the Claude API spec, including the system parameter, and converting to the backend format automatically.
Antigravity gets its own parallel set under /antigravity/: an OpenAI-format chat endpoint, Gemini-format generateContent and streamGenerateContent, and a Claude-format /antigravity/v1/messages, covering all Antigravity models with automatic model-name mapping and thinking-mode detection. The value of this is that one running instance can serve an OpenAI SDK, a Gemini SDK and a Claude client at the same time, all backed by the same pool of Google credentials.
Installing and deploying gcli2api
The README gives an installer per platform. On Linux, for example:
curl -o install.sh "https://raw.githubusercontent.com/su-kaka/gcli2api/refs/heads/master/install.sh" && chmod +x install.sh && ./install.shThere are matching scripts for Termux (termux-install.sh), macOS (darwin-install.sh) and Windows (an install.ps1 run through iex), and restart helpers such as start.sh or start.bat. There are also one-click buttons for Zeabur and Render.
Docker is the most self-contained route. The README's basic run command, using a single shared password, is:
docker run -d --name gcli2api --network host -e PASSWORD=pwd -e PORT=7861 -v $(pwd)/data/creds:/app/creds ghcr.io/su-kaka/gcli2api:latestFor production the README recommends splitting the password so the chat endpoints and the control panel are protected separately:
docker run -d --name gcli2api --network host -e API_PASSWORD=api_pwd -e PANEL_PASSWORD=panel_pwd -e PORT=7861 -v $(pwd)/data/creds:/app/creds ghcr.io/su-kaka/gcli2api:latestThere is a docker-compose.yml as well, with commented-out blocks for Redis, MongoDB and PostgreSQL for distributed credential storage, and the Dockerfile preloads jemalloc to keep memory use from creeping up over long runs.
Configuring it and pointing a client at it
After the service is up, the README's setup steps are to open the console at http://127.0.0.1:7861, complete the OAuth flow with the default password pwd, and then configure your client. The console offers two OAuth modes: GCLI mode for Google Cloud Gemini credentials and Antigravity mode for Antigravity credentials.
For an OpenAI-compatible client, the base URL is http://127.0.0.1:7861/v1 and the API key is your password, set through API_PASSWORD or PASSWORD. For a Gemini-native client, the base is http://127.0.0.1:7861 with the password sent as a Bearer token or an x-goog-api-key header. The two-password split matters here: the API password is what your applications carry, while the panel password guards credential upload and system configuration, so leaking the former does not expose the latter.
Credential rotation, models and reliability features
The part that makes gcli2api more than a format shim is its credential manager. The README describes automatic rotation across multiple Google OAuth credentials, load balancing across concurrent requests, automatic fault detection that disables a failing credential, per-credential usage and quota statistics, and manual enable, disable and delete, including batch operations and ZIP upload of many credentials at once. Credential health is checked in real time, error codes such as 429, 403 and 500 are tracked, and an automatic ban mechanism is configurable.
The README says every model has a 1M-token context window and each credential file provides 1000 requests of quota, which is why rotation is central: capacity scales with the number of credentials you add. The model list includes gemini-2.5-pro, gemini-3-pro-preview and gemini-3.1-pro-preview, thinking variants such as gemini-2.5-pro-high and -low, a search-augmented gemini-2.5-pro-search, and Antigravity image models like gemini-3.1-flash-image with resolution and aspect-ratio suffixes. Two behaviour modifiers are notable: a fake-streaming suffix for clients that need streaming when the backend does not support it, and an anti-truncation prefix that uses synthetic tool calls to stop answers being cut off.
Licence, maturity and cautions
The licensing needs care. GitHub reports NOASSERTION, the badge says CNC-1.0, and pyproject.toml declares it as CNC-1.0 with an Other/Proprietary License classifier. That is not one of the common permissive licences, so anyone planning to redistribute or offer it as a service should read the LICENSE file itself rather than assume MIT-style terms. pyproject.toml marks the project as 4 - Beta and version 0.1.0, with a full test suite and dev tooling declared.
The operational cautions follow from what it is. It holds Google OAuth credentials and, by design, lets clients use Google accounts through formats those accounts do not natively offer, so keep it on a private network or behind the separated passwords, never expose the panel to the internet, and change the default pwd immediately. The README documents proxy support, configurable 429 retries and a multi-level logging system for when a credential or the upstream misbehaves. The last push was on 2026-09-14, so it is actively maintained.
Editorial conclusion
Run gcli2api if you have Google accounts with GeminiCLI or Antigravity access and want to reach them from any OpenAI-, Gemini- or Claude-format client behind one endpoint. Start with the Docker command and a strong password, use the separate API and panel passwords in production, and add more credential files so the built-in rotation can keep going when one hits its quota.
Frequently asked questions
Are the Gemini API keys used by gcli2api free?
gcli2api does not use paid Gemini API keys. You authorise Google accounts through its console with GeminiCLI or Antigravity OAuth, and the README says each credential file provides 1000 requests of quota; capacity grows as you add more credentials.
Is the API key the client sends the same as a Google API key?
No. Clients authenticate to gcli2api with your own password (set via API_PASSWORD or PASSWORD), not a Google API key. gcli2api then talks to Google using the OAuth credentials you authorised in its console.
How large a context window do the models support?
The README states that all models exposed by gcli2api have a 1M-token context window, and it lists models such as gemini-2.5-pro, gemini-3-pro-preview and gemini-3.1-pro-preview.
How do I point an OpenAI-format client at gcli2api?
Set the base URL to http://127.0.0.1:7861/v1 and use your password as the API key. The endpoint /v1/chat/completions accepts both OpenAI and Gemini request structures and converts between them automatically.
Community notes