$ show su-kaka/gcli2api
GCLI2API is a production-grade API proxy that converts Google Gemini CLI and Antigravity credentials into OpenAI, Gemini, and Claude compatible API endpoints. It manages OAuth credentials with automatic rotation, error-based cooldowns, and load balancing, providing a unified interface for multiple backend services. The system includes a web-based control panel for credential management, real-time logs, configuration editing, and batch operations. The architecture is a FastAPI web application with modular routers for each API format (OpenAI, Gemini, Claude) and two backend modes (geminicli, antigravity). Format converters handle bidirectional translation between Anthropic, OpenAI, and Gemini schemas, including tool calls, streaming, and thinking blocks. Storage is abstracted via an adapter pattern supporting SQLite, MongoDB, and PostgreSQL, with optional Redis caching for credential pools. Key features include streaming support with fake streaming fallback, anti-truncation via synthetic tool calls, thought signature preservation across format conversions, and a keepalive service. The system relies on httpx for async HTTP, Pydantic for data models, and external Google Cloud APIs for OAuth and quota management. Deployment is supported via Docker, docker-compose, and platform-specific install scripts for Linux, macOS, Windows, and Termux. This is a pure application with no data research or ML components. It demonstrates strong engineering practices in credential management, format conversion, and async I/O, though it suffers from some code duplication between backend modes and limited test coverage.
The LLM identified 5 files worth highlighting for reuse:
Provides a reusable async HTTP client with proxy support, configurable timeouts, and streaming capabilities. Used across the application for all external API calls, it encapsulates connection pooling and error handling, making it easy to extract into other projects.
Singleton credential manager with lazy initialization, automatic token refresh, and error recording. It centralizes OAuth credential lifecycle management, including cooldown tracking and load balancing, and can be reused in any project requiring multi-credential rotation.
Defines an abstract storage backend interface with fallback logic, allowing seamless switching between SQLite, MongoDB, and PostgreSQL. The adapter pattern decouples business logic from storage implementation, making it a reusable foundation for data persistence in other applications.
High-performance asynchronous logging system using a deque-based queue, background writer thread, batch writes, and overflow protection. It handles high-throughput logging without blocking the main event loop and can be extracted as a standalone logging utility.
Encodes and decodes thought signatures within tool call IDs to preserve them across format conversions between Anthropic and Gemini. This non-obvious technique enables round-trip fidelity for thinking blocks, demonstrating deep understanding of both API schemas.