geminikit


Namegeminikit JSON
Version 1.2.0 PyPI version JSON
download
home_pagehttps://github.com/rekcah-pavi/geminikit
SummaryThe python package that returns Response of Google Gemini through Cookies.
upload_time2024-08-07 06:54:42
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 httpx
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
user = None
while True:
 text = input("Ask: ")
 res = gemini.ask(text,user=user)
 user = res
 print(res['text'])
```
</details>


<details>
  <summary>Async</summary>
 
```python
import asyncio

user = None
while True:
 await asyncio.sleep(0)
 text = input("Ask: ")
 res = await gemini.ask(text,user=user)
 user = res
 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/6d/25/c185524c0e8edaa47b92d635ad72ae456e5276172a7859f07a45983bd5c3/geminikit-1.2.0.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\nuser = None\nwhile True:\n text = input(\"Ask: \")\n res = gemini.ask(text,user=user)\n user = res\n print(res['text'])\n```\n</details>\n\n\n<details>\n  <summary>Async</summary>\n \n```python\nimport asyncio\n\nuser = None\nwhile True:\n await asyncio.sleep(0)\n text = input(\"Ask: \")\n res = await gemini.ask(text,user=user)\n user = res\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.0",
    "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": "814989d945a892635524d930bc3d5b5a81e3972691209f25bba491e3bae09931",
                "md5": "6374509b8c7da2c3d532fabd7c782af4",
                "sha256": "3d164e9278c2d20d1cb85206918b3fbb3baaab383084c6a7558c051fb679ddc3"
            },
            "downloads": -1,
            "filename": "geminikit-1.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6374509b8c7da2c3d532fabd7c782af4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 12178,
            "upload_time": "2024-08-07T06:54:40",
            "upload_time_iso_8601": "2024-08-07T06:54:40.918621Z",
            "url": "https://files.pythonhosted.org/packages/81/49/89d945a892635524d930bc3d5b5a81e3972691209f25bba491e3bae09931/geminikit-1.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6d25c185524c0e8edaa47b92d635ad72ae456e5276172a7859f07a45983bd5c3",
                "md5": "a0aaaee933c7888cfba2b46640b09fd1",
                "sha256": "72244c5eeefac4bfee2952d6a1703e2f7cccee0ce0de88b827cf145de344336b"
            },
            "downloads": -1,
            "filename": "geminikit-1.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a0aaaee933c7888cfba2b46640b09fd1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 10768,
            "upload_time": "2024-08-07T06:54:42",
            "upload_time_iso_8601": "2024-08-07T06:54:42.332484Z",
            "url": "https://files.pythonhosted.org/packages/6d/25/c185524c0e8edaa47b92d635ad72ae456e5276172a7859f07a45983bd5c3/geminikit-1.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-07 06:54:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rekcah-pavi",
    "github_project": "geminikit",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "httpx",
            "specs": []
        }
    ],
    "lcname": "geminikit"
}
        
Elapsed time: 0.26970s