Bard 
Reverse engineering of Google's Gemini chatbot API, formerly BARD.
Installation
$ pip3 install --upgrade GoogleBard1
Authentication
Go to https://bard.google.com/
- F12 for console
- Copy the values
- Session: Go to Application → Cookies →
__Secure-1PSIDand__Secure-1PSIDTS. Copy the value of those cookie.
- Session: Go to Application → Cookies →
Usage
$ python3 -m Bard -h
usage: Bard.py [-h] --session SESSION --session_ts SESSION_TS
options:
-h, --help show this help message and exit
--session SESSION __Secure-1PSID cookie
--session_ts SESSION_TS
__secure_1psidts cookie.
Quick mode
$ export BARD_QUICK="true"
$ export BARD__Secure_1PSID="<__Secure-1PSID>"
$ export BARD__Secure_1PSIDTS="<__Secure-1PSIDTS>"
$ python3 -m Bard
Environment variables can be placed in .zshrc.
Example bash shortcut:
# USAGE1: bard QUESTION
# USAGE2: echo "QUESTION" | bard
bard () {
export BARD_QUICK=true
export BARD__Secure_1PSID=<__Secure-1PSID>
export BARD__Secure_1PSIDTS=<__Secure-1PSIDTS>
python3 -m Bard "${@:-$(</dev/stdin)}" | tail -n+7
}
Implementation:
from os import environ
from Bard import Chatbot
Secure_1PSID = environ.get("BARD__Secure_1PSID")
Secure_1PSIDTS = environ.get("BARD__Secure_1PSIDTS")
chatbot = Chatbot(Secure_1PSID, Secure_1PSIDTS)
answer = chatbot.ask("Hello, how are you?")
print(answer['content']
Async Implementation:
import asyncio
from os import environ
from Bard import AsyncChatbot
Secure_1PSID = environ.get("BARD__Secure_1PSID")
Secure_1PSIDTS = environ.get("BARD__Secure_1PSIDTS")
async def main():
chatbot = await AsyncChatbot.create(Secure_1PSID, Secure_1PSIDTS)
response = await chatbot.ask("Hello, how are you?")
print(response['content'])
asyncio.run(main())
[!IMPORTANT] The cookies expire after a short period; ensure you update them as frequent as possible.
Developer Documentation
Credits:
- discordtehe - Derivative of his original reverse engineering
Metadata
Release files for GoogleBard1 2.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| GoogleBard1-2.1.4.tar.gz | 6.5 kB | Without provenance | Details for GoogleBard1-2.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| GoogleBard1-2.1.4-py3-none-any.whl | Python 3 | none | any | Details for GoogleBard1-2.1.4-py3-none-any.whl |
Total release size: 13.3 kB
Release files / GoogleBard1-2.1.4.tar.gz
| Download URL | GoogleBard1-2.1.4.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f21a0960cee121a7e5d1c13e444d3bef85bc585af25f0aa3433c76640a668b9b
|
|
BLAKE2b-256 checksum How to use checksums |
74094f6616798faf77d175116c693fe50de03869165ce6ed566f642f0270b09a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.0
|
Release files / GoogleBard1-2.1.4-py3-none-any.whl
| Download URL | GoogleBard1-2.1.4-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7afb22c21b9861e66792855186b77c1107afa2f7167f1734d4db62602fa97644
|
|
BLAKE2b-256 checksum How to use checksums |
60862e6b5efe1d813404dc247fc92a799a1fb261a21e298f009797bb9dfe1b58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.0
|
Security for GoogleBard1 2.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.