Skip to main content

Gemini Icon GeminiKit

GeminiKit is an unofficial Python wrapper developed through reverse-engineering. This tool utilizes cookie values to interact with Google Gemini for testing purposes.


Installation

To install GeminiKit, you can use pip:

pip install -U geminikit

or

pip install git+https://github.com/rekcah-pavi/geminikit

Get Cookie File (chrome-net-export-log)

For a detailed video guide, click here.

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 to 1 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. Extract Cookies from 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

Sync
from geminikit import get_cookies_from_file
from geminikit import Gemini

with open("chrome-net-export-log.json", 'r') as f:
    cookies = get_cookies_from_file(f.read())

gemini = Gemini(cookies)
Async
from geminikit import get_cookies_from_file
from geminikit import Asynic_Gemini as Gemini

import asyncio
import aiofiles #pip install aiofiles

async def main():
    async with aiofiles.open("chrome-net-export-log.json", mode='r') as f:
        cookies = get_cookies_from_file(await f.read())

    gemini = await Gemini.create(cookies)

asyncio.run(main())

Ask a Message

Sync
res = gemini.ask("hello")
print(res['text'])
Async
res = await gemini.ask("hello")
print(res['text'])

Ask continuous message

Sync
response = gemini.ask("tell me a joke")
print(res['text'])
#user value must be a dictionary containing SNlM0e, conversation_id, response_id, choice_id (available inside the response dictionary)
res = gemini.ask("another one",user=response)
print(res['text'])
Async
 response = await gemini.ask("tell me a joke")
 print(res['text'])
 #user value must be a dictionary containing SNlM0e, conversation_id, response_id, choice_id (available inside the response dictionary)
 res = await gemini.ask("another one",user=response)
 print(res['text'])

Text to Voice

Sync
res = gemini.speech("hello")
#res = gemini.speech("hello", lang_code="en")
with open("a.wav", "wb") as f:
  f.write(res)
Async
import aiofiles #pip install aiofiles
res = await gemini.speech("hello")
#res = gemini.speech("hello", lang_code="en")
async with aiofiles.open("a.wav", mode='wb') as f:
        await f.write(res)

Ask with Photo

Sync
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(res['text'])
Async
import aiofiles #pip install aiofiles

async with aiofiles.open("cat.jpg", mode='rb') as f:
        img_data = await f.read()
        img_link = await gemini.upload_image(img_data)

photo = ['cat.jpg', img_link]  # photo name (if not available, use 'none.jpg'), link

res = await gemini.ask("What is in this photo?", photo=photo)
print(res['text'])

Save Response Images

Sync
res = gemini.ask("send me some wallpapers")

print(res['text'])

#Or 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)
Async
import aiofiles #pip install aiofiles


res = await gemini.ask("send me some wallpapers")

print(res['text'])

#Or You can access URLs directly
for url in res['image_urls']:
    img_name  = url.split("/")[-1]
    img_bytes = await gemini.get_img_bytes(url)
    async with aiofiles.open(img_name, mode='wb') as f:
        await f.write(img_bytes)

Save Generated Images

Sync
res = gemini.ask("Generate an image of a cat holding a rose.")

print(res['text'])

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)
Async
import aiofiles #pip install aiofiles

res = await gemini.ask("Generate an image of a cat holding a rose.")

print(res['text'])

for url in res['generated_image_urls']:
    img_name  = url.split("/")[-1][:10] + ".png"
    img_bytes = await gemini.get_img_bytes(url)

    async with aiofiles.open(img_name, mode='wb') as f:
        await f.write(img_bytes)

Get Sharable URL

Sync
res = gemini.ask("Hi")
url = gemini.share(res['conversation_id'], res['response_id'], res['choice_id'], res['req_id'], res['fsid'], title="test by me")
print(url)
Async
res = await gemini.ask("Hi")
url = await gemini.share(res['conversation_id'], res['response_id'], res['choice_id'], res['req_id'], res['fsid'], title="test by me")
print(url)

Metadata

Release files for geminikit 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for geminikit 1.2.1
File Size Uploaded
geminikit-1.2.1.tar.gz 11.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for geminikit 1.2.1
File Interpreter ABI Platform
geminikit-1.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 23.5 kB

Release files / geminikit-1.2.1.tar.gz

Download URL geminikit-1.2.1.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d775c029bf5ff889041f01f579fb2ea12cf48e4fbfa5397ce54b4dc056237d55
BLAKE2b-256 checksum
How to use checksums
4859fb957676cbda45936aad499e24db39b67f2ab7cc6707ab8f176bafa9705a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.10

Release files / geminikit-1.2.1-py3-none-any.whl

Download URL geminikit-1.2.1-py3-none-any.whl
Size 12.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1f194fcda075f17cd055d2a7539755c155c6268d8d75121e26ee3eee23054646
BLAKE2b-256 checksum
How to use checksums
bd43e570aacddd48de0777cd7d61c9e59df21362bf2d9e8a4ecd3705028ce300
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.10

Release history Release notifications | RSS feed

This release

1.2.1 This release

2 release files

1.2.0

2 release files

1.1.9

2 release files

1.1.8

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page