Gemini-API
An asynchronous Python wrapper for the Google Gemini web app (formerly Bard), offering text, image, video, audio, chat, streaming, and deep research capabilities through a reverse-engineered client.
Visit HanaokaYuzu/Gemini-APIOverview
Gemini-API is a reverse-engineered asynchronous Python wrapper for the Google Gemini web app (formerly Bard). It provides a simple, elegant interface inspired by Google Generative AI's official API and supports asynchronous generation, streaming, multi-turn conversations, media outputs, Gemini Gems, extensions, and deep research.
Key Features
- Persistent cookies with automatic background refresh for always-on services.
- Native image generation and editing, plus video and audio/music generation.
- Deep research workflow with plan creation, status polling, and result retrieval.
- System prompts through Gemini Gems and support for Gemini extensions such as YouTube and Gmail.
- Classified outputs for text, thoughts, images, videos, and audio, with streaming mode for partial results.
- Asynchronous client and standalone CLI for quick interactions.
Use Cases
- Building always-on services and chatbots that need automatic cookie refresh.
- Creating multi-turn conversational applications with history handling and streaming responses.
- Generating and saving images, videos, and audio through natural-language prompts.
- Running deep research workflows and retrieving structured results.
Getting Started
- Install or update the package with pip: pip install -U gemini_webapi.
- Optionally install with browser support using pip install -U gemini_webapi[browser] to import cookies from a local Firefox browser.
- Log in to Gemini, copy the __Secure-1PSID and __Secure-1PSIDTS cookie values, initialize GeminiClient, and call init with desired timeout and refresh settings.
Deployment & Requirements
- Python 3.11 or higher.
- Valid Gemini web cookies (__Secure-1PSID and __Secure-1PSIDTS) unless browser-cookie3 cookie import is used.
- Optional browser-cookie3 dependency for automatic cookie import; currently only Firefox is supported.
- In containerized deployments, set GEMINI_COOKIE_PATH to a writable path to persist auto-refreshed cookies.
Before You Adopt
- License: AGPL-3.0. Review its terms before using, modifying, or distributing the project.
- The project is a reverse-engineered wrapper rather than an officially documented Gemini web API client.
- Image generation availability can vary by region and account.
- Video and audio generation may require an active subscription.
- Cookie extraction may be more reliable with Firefox because recent Chromium-based browsers can limit cookie renewal.