zhiyu1998/Gemi2Api-Server

HanaokaYuzu / Gemini-API 的服务端简单实现,仓库自动更新上游,支持gemini-4-argon、gemini-3.1-pro、gemini-4-neon、gemini-4-hydrogen、gemini-3.5-flash-lite 等

What it solves

This project turns Google Gemini's web interface into a standard OpenAI-compatible API. Instead of using the official paid Gemini API, you provide your Gemini login cookies, and the server exposes a familiar /v1/chat/completions endpoint that existing OpenAI tools can call. It also adds an admin panel for managing cookies, API keys, and monitoring without restarting the service.

How it works

You put your Gemini cookies (__Secure-1PSID and __Secure-1PSIDTS) in a .env file. The server uses the gemini-webapi library to talk to Gemini's web backend and exposes several endpoints: /v1/chat/completions (OpenAI-compatible, supports streaming and reasoning_effort), /v1/models, an image proxy, and an admin panel. Model definitions can be customised in a YAML/JSON file (custom_models.yaml) that maps friendly names to internal Gemini model headers; this file is hot-reloaded on each request. Reasoning effort is controlled via the reasoning_effort parameter (low/medium/high) rather than model-name suffixes. Deployment is supported via Docker Compose, direct uvicorn run, or one-click buttons on Render and HuggingFace.

Who it’s for

Developers who want to use Gemini models through an OpenAI-compatible API without paying for the official API, or who need a self-hosted proxy with an admin panel. It requires having a Gemini account and extracting cookies from the browser (instructions are provided in the README).

Highlights

  • OpenAI-compatible /v1/chat/completions endpoint with streaming and reasoning_effort support
  • Admin panel for live status, cookie updates, API key/rate-limit config, logs, and chat testing
  • Custom model definitions via YAML/JSON with hot reload (no restart needed)
  • Docker Compose deployment and one-click Render/HuggingFace deploy buttons
  • Image proxy endpoint for generated images, with PUBLIC_BASE_URL support for reverse proxies
  • Built-in watermark removal for images (based on external algorithms)

Related

  • Project
  • Project
  • Project
  • Project
  • Project