gemini-web-to-api  by ntthanh2603

Local API for Google Gemini's capabilities

Created 6 months ago
352 stars

Top 78.9% on SourcePulse

GitHubView on GitHub
Project Summary

This project provides a reverse-engineered REST API for Google Gemini's web application, enabling developers to access Gemini models without traditional API keys. It targets researchers and developers seeking to integrate Gemini into applications, test locally, or experiment with its capabilities using a standardized interface compatible with OpenAI, Claude, and Gemini SDKs. The primary benefit is simplified access and local development leveraging existing browser session cookies.

How It Works

The project reverse-engineers the gemini.google.com web interface to create a local API server. It authenticates by utilizing browser cookies (__Secure-1PSID and __Secure-1PSIDTS) directly, eliminating the need for API key management. The server then exposes standardized API endpoints that mimic OpenAI, Claude, and Gemini protocols, allowing seamless integration with existing tools and workflows. This approach facilitates local testing and development by abstracting away the complexities of direct web scraping or official API interactions.

Quick Start & Requirements

  • Primary install / run command:
    • Docker: docker run -d -p 4981:4981 -e GEMINI_1PSID="your_psid_here" -e GEMINI_1PSIDTS="your_psidts_here" ghcr.io/ntthanh2603/gemini-web-to-api:latest
    • Source (Docker Compose): docker compose up -d --build
    • Source (Go): go run cmd/server/main.go
  • Non-default prerequisites: Browser cookies (__Secure-1PSID, __Secure-1PSIDTS) obtained from gemini.google.com. Docker is required for Docker-based installations. Go 1.21+ is needed for direct execution.
  • Links: GitHub: https://github.com/ntthanh2603/gemini-web-to-api, Gemini Web: gemini.google.com, API Docs: http://localhost:4981/docs (once running).

Highlighted Details

  • Universal AI Bridge: Supports OpenAI, Claude, and Gemini protocols through a single server instance.
  • Drop-in Replacement: Designed to work seamlessly with existing OpenAI, Claude, and Gemini SDKs.
  • Smart Session Management: Features automatic cookie rotation to maintain persistent sessions.
  • High Performance: Developed in Go with the Fiber framework for speed and efficiency.
  • Production Ready: Includes Docker Compose support, interactive Scalar UI documentation, and health checks.

Maintenance & Community

The project is maintained by the "Gemini Web To API team." Contribution guidelines are provided via pull requests. No specific community channels (e.g., Discord, Slack) or roadmap links are detailed in the README.

Licensing & Compatibility

This project is licensed under the MIT License. The MIT license generally permits commercial use and integration into closed-source projects, though the project's own disclaimers regarding Google's Terms of Service and intended use should be carefully considered.

Limitations & Caveats

This project is strictly intended for research and educational purposes and explicitly prohibits commercial use. It relies on reverse-engineered web cookies and may not comply with Google's Terms of Service. Users are advised that they employ this tool at their own risk, as the author disclaims responsibility for any account actions or data loss. Its functionality is dependent on the stability of the Gemini web interface and its authentication mechanisms.

Health Check
Last Commit

3 days ago

Responsiveness

Inactive

Pull Requests (30d)
7
Issues (30d)
3
Star History
114 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.