Gemini-API

✨ Reverse-engineered Python API for Google Gemini web app

What is Gemini-API?

✨ Reverse-engineered Python API for Google Gemini web app

Overview of Gemini-API

What it is

Gemini-API is a reverse-engineered asynchronous Python wrapper for the Google Gemini web app (formerly known as Bard). It provides a programmatic interface to interact with the Gemini web service, enabling tasks such as text generation, image generation and editing, video and audio generation, and deep research workflows. The library is designed for always-on services and includes automatic cookie refresh functionality. It requires Python 3.11 or higher and is available under the AGPL-3.0 license. The source code is hosted on GitHub and the package is distributed via PyPI under the name gemini-webapi (package name gemini_webapi). The project is categorized under AI tools.

Key features

  • Persistent Cookies – Automatically refreshes cookies in the background, optimized for always-on services.
  • Image Generation & Editing – Natively supports generating and editing images using natural language prompts.
  • Video & Audio Generation – Supports generating video and audio/music content natively.
  • Deep Research – Provides a full deep research workflow including plan creation, status polling, and result retrieval.
  • System Prompt (Gemini Gems) – Allows customization of the model's system prompt using Gemini Gems.
  • Extension Support – Supports generating content with Gemini extensions such as YouTube and Gmail.
  • Classified Outputs – Categorizes text, thoughts, images, videos, and audio in the response.
  • Streaming Mode – Supports stream generation, yielding partial outputs as they are generated.
  • CLI Tool – Includes a standalone command-line interface for quick interactions.
  • Asynchronous – Uses asyncio to run generation tasks and return outputs efficiently.

Use cases

This API can be used to build chatbots, content generation tools, research assistants, and multimedia creation applications that leverage the capabilities of the Google Gemini web app. It is suitable for developers who need to automate interactions with Gemini for tasks such as answering questions, generating images or videos, conducting deep research, and integrating with Google services like YouTube and Gmail via extensions. The persistent cookie handling makes it appropriate for long-running server-side applications.

Getting started

Install or update the package with pip: sh pip install -U gemini_webapi Optionally, to automatically import cookies from a local browser (Firefox only), install with: sh pip install -U gemini_webapi[browser] After installation, obtain the cookie values __Secure-1PSID and __Secure-1PSIDTS from the Gemini web app (https://gemini.google.com) and initialize a client as shown in the repository's README. For detailed usage examples, including initialization, content generation, file input, multi-turn conversations, and streaming, please refer to the repository README.

License and pricing

The project is licensed under AGPL-3.0. It is open source and free to use. Pricing is not stated beyond the open-source license.

Based on the project's public README and repository metadata.

Add this badge to your README

Featured on YunoDB Badge styles & help

Maintain this project? Show that it is featured on YunoDB.

Markdown[![Featured on YunoDB](https://yunodb.com/badge/hanaokayuzugemini-api.svg)](https://yunodb.com/tools/hanaokayuzugemini-api?utm_source=github&utm_medium=badge)
HTML<a href="https://yunodb.com/tools/hanaokayuzugemini-api?utm_source=github&utm_medium=badge"><img src="https://yunodb.com/badge/hanaokayuzugemini-api.svg" alt="Featured on YunoDB" height="20"></a>