geminikit


Namegeminikit JSON
Version 1.2.1 PyPI version JSON
download
home_pagehttps://github.com/rekcah-pavi/geminikit
SummaryThe python package that returns Response of Google Gemini through Cookies.
upload_time2024-10-05 02:59:22
maintainerNone
docs_urlNone
authorpaviththanan
requires_python>=3.6
licenseNone
keywords python api gemini google gemini large language model chatbot api google api chatbot
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # <img src="https://www.gstatic.com/lamda/images/gemini_sparkle_v002_d4735304ff6292a690345.svg" width="35px" alt="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.

<br>

## Installation

To install GeminiKit, you can use pip:

```bash
pip install -U geminikit
```
or

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

***
 ## Get Cookie File (chrome-net-export-log)
<details>
 

For a detailed video guide, [click here](https://youtu.be/IUCJg2KWcJs).

### 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](https://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

```python
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)
```

</details>

***

## Usage

### Setup Gemini

<details open>
  <summary>Sync</summary>

  ```python
  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)
```
</details>


<details>
  <summary>Async</summary>
 
```python
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())
```
</details>



### Ask a Message


<details open>
  <summary>Sync</summary>

  ```python
res = gemini.ask("hello")
print(res['text'])
```
</details>


<details>
  <summary>Async</summary>
 
```python
res = await gemini.ask("hello")
print(res['text'])
```
</details>



### Ask continuous message
<details open>
  <summary>Sync</summary>

  ```python

 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'])
```
</details>


<details>
  <summary>Async</summary>
 
```python
 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'])
 ```
</details>




### Text to Voice

<details open>
  <summary>Sync</summary>

  ```python
res = gemini.speech("hello")
#res = gemini.speech("hello", lang_code="en")
with open("a.wav", "wb") as f:
    f.write(res)
```
</details>


<details>
  <summary>Async</summary>
 
```python
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)
```
</details>



### Ask with Photo

<details open>
  <summary>Sync</summary>

  ```python
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'])
```
</details>


<details>
  <summary>Async</summary>
 
```python
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'])


```
</details>





### Save Response Images

<details open>
  <summary>Sync</summary>

  ```python
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)
```
</details>


<details>
  <summary>Async</summary>
 
```python
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)

```
</details>






### Save Generated Images

<details open>
  <summary>Sync</summary>

  ```python
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)
```
</details>


<details>
  <summary>Async</summary>
 
```python
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)

```
</details>




### Get Sharable URL

<details open>
  <summary>Sync</summary>

  ```python
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)
```
</details>


<details>
  <summary>Async</summary>
 
```python
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)
```
</details>





            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/rekcah-pavi/geminikit",
    "name": "geminikit",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "Python, API, Gemini, Google Gemini, Large Language Model, Chatbot API, Google API, Chatbot",
    "author": "paviththanan",
    "author_email": "rkpavi06@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/48/59/fb957676cbda45936aad499e24db39b67f2ab7cc6707ab8f176bafa9705a/geminikit-1.2.1.tar.gz",
    "platform": null,
    "description": "# <img src=\"https://www.gstatic.com/lamda/images/gemini_sparkle_v002_d4735304ff6292a690345.svg\" width=\"35px\" alt=\"Gemini Icon\" /> GeminiKit\n\n**GeminiKit** is an unofficial Python wrapper developed through reverse-engineering. This tool utilizes cookie values to interact with Google Gemini for testing purposes.\n\n<br>\n\n## Installation\n\nTo install GeminiKit, you can use pip:\n\n```bash\npip install -U geminikit\n```\nor\n\n```bash\npip install git+https://github.com/rekcah-pavi/geminikit\n```\n\n***\n ## Get Cookie File (chrome-net-export-log)\n<details>\n \n\nFor a detailed video guide, [click here](https://youtu.be/IUCJg2KWcJs).\n\n### 1. Close All Tabs\n\nEnsure all tabs are closed in Google Chrome.\n\n### 2. Access Network Export\n\n- Open a new tab and navigate to `chrome://net-export/`.\n\n### 3. Configure Logging Settings\n\n- Check the box labeled `Include cookies and credentials`.\n- Set the `Maximum log size` to `1 MB`.\n- Click the `Start logging` button.\n\n### 4. Perform Actions\n\n- Open a new tab and go to [gemini.google.com](https://gemini.google.com).\n- Log in to your Gemini account.\n- Send a sample message and wait for Gemini's response.\n\n### 5. Stop Logging\n\n- Return to the logging tab and click the `Stop logging` button.\n\n### 6. Retrieve Cookies\n\n- The cookies will be saved in a JSON file.\n\n### 7. Extract Cookies from File\n\n```python\nfrom geminikit import get_cookies_from_file\n\nwith open(\"chrome-net-export-log.json\", 'r') as f:\n    cookies = get_cookies_from_file(f.read())\n\nprint(cookies)\n```\n\n</details>\n\n***\n\n## Usage\n\n### Setup Gemini\n\n<details open>\n  <summary>Sync</summary>\n\n  ```python\n  from geminikit import get_cookies_from_file\n  from geminikit import Gemini\n\n  with open(\"chrome-net-export-log.json\", 'r') as f:\n      cookies = get_cookies_from_file(f.read())\n\n  gemini = Gemini(cookies)\n```\n</details>\n\n\n<details>\n  <summary>Async</summary>\n \n```python\nfrom geminikit import get_cookies_from_file\nfrom geminikit import Asynic_Gemini as Gemini\n\nimport asyncio\nimport aiofiles #pip install aiofiles\n\nasync def main():\n    async with aiofiles.open(\"chrome-net-export-log.json\", mode='r') as f:\n        cookies = get_cookies_from_file(await f.read())\n\n    gemini = await Gemini.create(cookies)\n\nasyncio.run(main())\n```\n</details>\n\n\n\n### Ask a Message\n\n\n<details open>\n  <summary>Sync</summary>\n\n  ```python\nres = gemini.ask(\"hello\")\nprint(res['text'])\n```\n</details>\n\n\n<details>\n  <summary>Async</summary>\n \n```python\nres = await gemini.ask(\"hello\")\nprint(res['text'])\n```\n</details>\n\n\n\n### Ask continuous message\n<details open>\n  <summary>Sync</summary>\n\n  ```python\n\n response = gemini.ask(\"tell me a joke\")\n print(res['text'])\n #user value must be a dictionary containing SNlM0e, conversation_id, response_id, choice_id (available inside the response dictionary)\n res = gemini.ask(\"another one\",user=response)\n print(res['text'])\n```\n</details>\n\n\n<details>\n  <summary>Async</summary>\n \n```python\n response = await gemini.ask(\"tell me a joke\")\n print(res['text'])\n #user value must be a dictionary containing SNlM0e, conversation_id, response_id, choice_id (available inside the response dictionary)\n res = await gemini.ask(\"another one\",user=response)\n print(res['text'])\n ```\n</details>\n\n\n\n\n### Text to Voice\n\n<details open>\n  <summary>Sync</summary>\n\n  ```python\nres = gemini.speech(\"hello\")\n#res = gemini.speech(\"hello\", lang_code=\"en\")\nwith open(\"a.wav\", \"wb\") as f:\n    f.write(res)\n```\n</details>\n\n\n<details>\n  <summary>Async</summary>\n \n```python\nimport aiofiles #pip install aiofiles\nres = await gemini.speech(\"hello\")\n#res = gemini.speech(\"hello\", lang_code=\"en\")\nasync with aiofiles.open(\"a.wav\", mode='wb') as f:\n        await f.write(res)\n```\n</details>\n\n\n\n### Ask with Photo\n\n<details open>\n  <summary>Sync</summary>\n\n  ```python\nwith open(\"cat.jpg\", \"rb\") as f:\n    img_link = gemini.upload_image(f.read())\n\nphoto = ['cat.jpg', img_link]  # photo name (if not available, use 'none.jpg'), link\n\nres = gemini.ask(\"What is in this photo?\", photo=photo)\nprint(res['text'])\n```\n</details>\n\n\n<details>\n  <summary>Async</summary>\n \n```python\nimport aiofiles #pip install aiofiles\n\nasync with aiofiles.open(\"cat.jpg\", mode='rb') as f:\n        img_data = await f.read()\n        img_link = await gemini.upload_image(img_data)\n\nphoto = ['cat.jpg', img_link]  # photo name (if not available, use 'none.jpg'), link\n\nres = await gemini.ask(\"What is in this photo?\", photo=photo)\nprint(res['text'])\n\n\n```\n</details>\n\n\n\n\n\n### Save Response Images\n\n<details open>\n  <summary>Sync</summary>\n\n  ```python\nres = gemini.ask(\"send me some wallpapers\")\n\nprint(res['text'])\n\n#Or You can access URLs directly\nfor url in res['image_urls']:\n    img_name  = url.split(\"/\")[-1]\n    img_bytes = gemini.get_img_bytes(url)\n    with open(img_name, 'wb') as f:\n        f.write(img_bytes)\n```\n</details>\n\n\n<details>\n  <summary>Async</summary>\n \n```python\nimport aiofiles #pip install aiofiles\n\n\nres = await gemini.ask(\"send me some wallpapers\")\n\nprint(res['text'])\n\n#Or You can access URLs directly\nfor url in res['image_urls']:\n    img_name  = url.split(\"/\")[-1]\n    img_bytes = await gemini.get_img_bytes(url)\n    async with aiofiles.open(img_name, mode='wb') as f:\n        await f.write(img_bytes)\n\n```\n</details>\n\n\n\n\n\n\n### Save Generated Images\n\n<details open>\n  <summary>Sync</summary>\n\n  ```python\nres = gemini.ask(\"Generate an image of a cat holding a rose.\")\n\nprint(res['text'])\n\nfor url in res['generated_image_urls']:\n    img_name  = url.split(\"/\")[-1][:10] + \".png\"\n    img_bytes = gemini.get_img_bytes(url)\n    with open(img_name, 'wb') as f:\n        f.write(img_bytes)\n```\n</details>\n\n\n<details>\n  <summary>Async</summary>\n \n```python\nimport aiofiles #pip install aiofiles\n\nres = await gemini.ask(\"Generate an image of a cat holding a rose.\")\n\nprint(res['text'])\n\nfor url in res['generated_image_urls']:\n    img_name  = url.split(\"/\")[-1][:10] + \".png\"\n    img_bytes = await gemini.get_img_bytes(url)\n\n    async with aiofiles.open(img_name, mode='wb') as f:\n        await f.write(img_bytes)\n\n```\n</details>\n\n\n\n\n### Get Sharable URL\n\n<details open>\n  <summary>Sync</summary>\n\n  ```python\nres = gemini.ask(\"Hi\")\nurl = gemini.share(res['conversation_id'], res['response_id'], res['choice_id'], res['req_id'], res['fsid'], title=\"test by me\")\nprint(url)\n```\n</details>\n\n\n<details>\n  <summary>Async</summary>\n \n```python\nres = await gemini.ask(\"Hi\")\nurl = await gemini.share(res['conversation_id'], res['response_id'], res['choice_id'], res['req_id'], res['fsid'], title=\"test by me\")\nprint(url)\n```\n</details>\n\n\n\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "The python package that returns Response of Google Gemini through Cookies.",
    "version": "1.2.1",
    "project_urls": {
        "Homepage": "https://github.com/rekcah-pavi/geminikit"
    },
    "split_keywords": [
        "python",
        " api",
        " gemini",
        " google gemini",
        " large language model",
        " chatbot api",
        " google api",
        " chatbot"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bd43e570aacddd48de0777cd7d61c9e59df21362bf2d9e8a4ecd3705028ce300",
                "md5": "ce8314b693606883b768ee7f12e1353a",
                "sha256": "1f194fcda075f17cd055d2a7539755c155c6268d8d75121e26ee3eee23054646"
            },
            "downloads": -1,
            "filename": "geminikit-1.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ce8314b693606883b768ee7f12e1353a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 12447,
            "upload_time": "2024-10-05T02:59:20",
            "upload_time_iso_8601": "2024-10-05T02:59:20.981781Z",
            "url": "https://files.pythonhosted.org/packages/bd/43/e570aacddd48de0777cd7d61c9e59df21362bf2d9e8a4ecd3705028ce300/geminikit-1.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4859fb957676cbda45936aad499e24db39b67f2ab7cc6707ab8f176bafa9705a",
                "md5": "0983dd6b9486d1c946b583846b2b9cb4",
                "sha256": "d775c029bf5ff889041f01f579fb2ea12cf48e4fbfa5397ce54b4dc056237d55"
            },
            "downloads": -1,
            "filename": "geminikit-1.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "0983dd6b9486d1c946b583846b2b9cb4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 11099,
            "upload_time": "2024-10-05T02:59:22",
            "upload_time_iso_8601": "2024-10-05T02:59:22.535927Z",
            "url": "https://files.pythonhosted.org/packages/48/59/fb957676cbda45936aad499e24db39b67f2ab7cc6707ab8f176bafa9705a/geminikit-1.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-05 02:59:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rekcah-pavi",
    "github_project": "geminikit",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "geminikit"
}
        
Elapsed time: 1.17893s