A friendly, MIT-licensed alternative to Gemini-WebAPI for interacting with Google Gemini Web.
Project description
Gemini-WebCookie
A powerful and flexible library for interacting with Google Gemini Web, supporting both Cookie-based and Anonymous (No-Cookie) modes.
Highlights (From Version 0.1.4)
Starting from version 0.1.4, Gemini-WebCookie is no longer just a replacement for Gemini-WebAPI but has evolved with powerful independent features:
- Anonymous Mode: Operates completely without cookies (
__Secure-1PSID). - Context Preservation: Automatically manages chat history (CID, RID, RCID) even in anonymous mode.
- Background Auto-Refresh: System automatically updates tokens and maintains sessions in the background.
- Full Feature Support: Chat, Image Generation, Gems Management, and File Uploads.
Installation
pip install gemini-webcookie
Usage
1. Anonymous Mode (No Cookies Required)
This is a major feature that goes beyond standard Gemini wrappers:
import asyncio
from gemini_webcookie import GeminiClient
async def main():
# Initialize without parameters for anonymous mode
client = GeminiClient()
await client.init()
chat = client.start_chat()
response = await chat.send_message("Hello, who are you?")
print(f"AI: {response.text}")
# Context is automatically preserved for the next question
response2 = await chat.send_message("What can you help me with?")
print(f"AI: {response2.text}")
await client.close()
asyncio.run(main())
2. Cookie-based Mode (Full Features)
from gemini_webcookie import GeminiClient
client = GeminiClient(
secure_1psid="YOUR_1PSID",
secure_1psidts="YOUR_1PSIDTS"
)
License
This project is dual-licensed under the MIT License and the Apache License 2.0. You may choose either license according to your needs.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters