Nativu5/Gemini-FastAPI

Web-based Gemini models wrapped into an OpenAI-compatible API.

What it solves

Normally, to call Google's Gemini models from your own code you need a paid Google API key. This project removes that requirement: it wraps the free, web-based version of Gemini (the one you use in your browser at gemini.google.com) behind a standard OpenAI-style API. So you can build apps that talk to Gemini for free, using the same API format that OpenAI tools and libraries already understand.

How it works

Instead of an API key, the server authenticates using two cookies (__Secure-1PSID and __Secure-1PSIDTS) copied from your own signed-in Google account. It then translates OpenAI-style API requests into calls to Gemini's web interface, and translates the replies back.

Key mechanics:

  • OpenAI-compatible endpoints — GET /v1/models lists available models, POST /v1/chat/completions handles chat (with streaming, images, file uploads, and function/tool calling), and POST /v1/responses is a more advanced endpoint supporting structured output and generated images.
  • Conversation persistence — multi-turn conversations are stored locally in an LMDB database, so context survives across requests and server restarts.
  • Multi-account load balancing — you can configure several Google accounts (each with its own cookies and optional proxy) and the server spreads requests across them.
  • Google search — because it uses the web version of Gemini, answers can include up-to-date search results.
  • Guest fallback — if all cookie-based accounts fail, the server can keep serving text prompts without an account, degrading gracefully instead of crashing.
  • Dynamic model discovery — models are read from Google at startup rather than hardcoded, so newly released models work automatically.

Configuration is done through a YAML file, with environment-variable overrides (useful for Docker and keeping credentials out of config files).

Who it's for

Developers who want to use Gemini's web models programmatically without paying for an API key, and who already have a Google account with Gemini access. It's especially convenient for anyone whose existing code or tools speak the OpenAI API format and want to point them at Gemini instead. The README notes it is for educational and research purposes, uses reverse-engineered APIs, and may not comply with Google's Terms of Service.

Highlights

  • No Google API key required — uses web cookies from your own account instead
  • OpenAI-compatible API — drop-in for tools that already speak OpenAI's format
  • Free — leverages Gemini's web interface rather than paid API tiers
  • Multi-turn conversations persisted in a local LMDB database
  • Multi-modal — handles text, images, and file uploads
  • Multi-account load balancing with per-account proxy support
  • Google search integration for up-to-date answers
  • Streaming, tool calling, and structured output support
  • Docker deployment with cookie persistence across container rebuilds
  • Guest mode keeps the service running even when all accounts fail

Related

  • Project
  • Project
  • Project
  • Project
  • Project