Gemini-FastAPI  by Nativu5

Gemini models accessible via OpenAI-compatible API

Created 7 months ago
380 stars

Top 75.1% on SourcePulse

GitHubView on GitHub
Project Summary

This project provides an OpenAI-compatible API wrapper for Google's web-based Gemini models, targeting developers and researchers who need programmatic access without requiring official API keys. It offers a free, convenient way to integrate Gemini's capabilities, including search and multi-modal support, into applications by leveraging existing Google account cookies.

How It Works

Gemini-FastAPI functions by reverse-engineering the authentication and API calls used by Gemini's web interface. Instead of relying on Google's official API keys, it utilizes secure_1psid and secure_1psidts cookies obtained from a user's Google account session. This approach allows it to expose Gemini models through a familiar OpenAI-like REST API, enabling features like conversation persistence and multi-modal input without direct integration with Google's paid services.

Quick Start & Requirements

  • Installation: Recommended via uv sync after cloning the repository (git clone https://github.com/Nativu5/Gemini-FastAPI.git && cd Gemini-FastAPI). Alternatively, use pip install -e ..
  • Prerequisites: Python 3.12, a Google account with web access to Gemini, and the __Secure-1PSID and __Secure-1PSIDTS cookies extracted from the Gemini web interface.
  • Running: Execute uv run python run.py or python run.py. The server defaults to http://localhost:8000. Docker deployment options are also available.
  • Configuration: Requires editing config/config.yaml or setting environment variables (prefixed with CONFIG_) to provide necessary cookie credentials.

Highlighted Details

  • No API Key Required: Authenticates using web cookies, bypassing the need for Google API keys.
  • Google Search Integration: Leverages Gemini's web search capabilities for up-to-date information.
  • Conversation Persistence: Utilizes LMDB for storing and resuming multi-turn conversations.
  • Multi-modal Support: Capable of processing text, images, and file uploads.
  • Multi-account Load Balancing: Distributes requests across multiple authenticated accounts, with per-account proxy support.

Maintenance & Community

The project is built upon HanaokaYuzu/Gemini-API and inspired by zhiyu1998/Gemi2Api-Server. No specific community channels (like Discord/Slack) or active maintainer information beyond the repository owner is detailed in the README.

Licensing & Compatibility

The license is not explicitly stated. However, the project disclaimer emphasizes its use for "educational and research purposes" and notes that it employs "reverse-engineered APIs" which "may not comply with Google's Terms of Service." This suggests potential limitations for commercial use or integration into production environments requiring strict ToS adherence.

Limitations & Caveats

This project relies on reverse-engineered APIs and web cookies, which are subject to change or invalidation by Google at any time. Its use may violate Google's Terms of Service, and it is explicitly intended for educational and research purposes only, carrying inherent risks for broader deployment.

Health Check
Last Commit

1 month ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
6
Star History
66 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.