The python package that returns Response of Google Gemini through Cookies.
Project description
GeminiKit
An unofficial Python wrapper, geminikit, has been developed through reverse-engineering. This tool utilizes cookie values to interact with Google Gemini for testing purposes.
Installation
pip install -U geminikit
or
pip install git+https://github.com/rekcah-pavi/geminikit
Log Cookies
video guide
1. Close All Tabs
Ensure all tabs are closed in Google Chrome.
2. Access Network Export
- Open a new tab and navigate to
chrome://net-export/
.
3. Configure Logging Settings
- Check the box labeled
Include cookies and credentials
. - Set the
Maximum log size
to1 MB
. - Click the
Start logging
button.
4. Perform Actions
- Open a new tab and go to gemini.google.com.
- Log in to your Gemini account.
- Send a sample message and wait for Gemini's response.
5. Stop Logging
- Return to the logging tab and click the
Stop logging
button.
6. Retrieve Cookies
- The cookies will be saved in a JSON file.
7. Get cookies from your saved file
from geminikit import get_cookies_from_file
with open("chrome-net-export-log.json",'r') as f:
cookies = get_cookies_from_file(f.read())
print(cookies)
Usage
Setup gemini
from geminikit import Gemini
gemini = Gemini(cookies)
Ask a message
res = gemini.ask("hello")
print(res['text'])
Text to Voice
res = gemini.speech("hello")
with open("a.wav","wb") as f:
f.write(res)
Ask with photo
with open("cat.jpg","rb") as f:
img_link = gemini.upload_image(f.read())
photo = ['cat.jpg', img_link] # photo name (if not available, use 'none.jpg'), link
res = gemini.ask("What is in this photo?",photo=photo)
print(print(res['text'])
Save responce images
res = gemini.ask("send me some wallpapers")
print(res['text'])
#Also, you can access URLs directly.
for url in res['image_urls']:
img_name = url.split("/")[-1]
img_bytes = gemini.get_img_bytes(url)
with open(img_name,'wb') as f:
f.write(img_bytes)
Save generated images
res = gemini.ask("Generate an image of a cat holding a rose.")
print(res['text'])
#You can't access URLs directly.
for url in res['generated_image_urls']:
img_name = url.split("/")[-1][:10]+".png"
img_bytes = gemini.get_img_bytes(url)
with open(img_name,'wb') as f:
f.write(img_bytes)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
geminikit-1.1.3.tar.gz
(9.2 kB
view details)
Built Distribution
geminikit-1.1.3-py3-none-any.whl
(10.8 kB
view details)
File details
Details for the file geminikit-1.1.3.tar.gz
.
File metadata
- Download URL: geminikit-1.1.3.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f49e1b244ef1c186e52f289ea7e0b2c9c0a1446766c56a3515b3e7c62830806 |
|
MD5 | 14fa05dfd89b4dbb17e326470c70eda0 |
|
BLAKE2b-256 | a76fa1f4a4f22eb985511857ec3a494f692cc135f2c88540fce61fe9e1ed12c2 |
File details
Details for the file geminikit-1.1.3-py3-none-any.whl
.
File metadata
- Download URL: geminikit-1.1.3-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 277b59dbd672b347dde48e3ecc13e1a0cd00a78de067e6741c0e1953dde5acc4 |
|
MD5 | 8a7ac1d270db7d53df835b912ddc561b |
|
BLAKE2b-256 | 6bf0f4fdafa75cca371e2aeb33e8c90da532737492e0acfaef3aeaaa0bc67253 |