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.2.tar.gz
(9.1 kB
view hashes)
Built Distribution
geminikit-1.1.2-py3-none-any.whl
(10.8 kB
view hashes)
Close
Hashes for geminikit-1.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8bd0f384711e35b2cf16bb8ca827b31becd7cdcf30d34cf52f5cfed8887fd43 |
|
MD5 | 4b52b00f870d284d822bd5d6e5a493ee |
|
BLAKE2b-256 | bd5c41efbe08575ab47c7530142b01d9a4edfa7ae8b7ad1314322025954ae3d3 |