Reverse Engineered Async API for Google Bard
Project description
Bard-WebAPI
Reverse Engineered Async API for Google Bard
Installation
pip install bard-webapi
Authentication
- Go to https://bard.google.com/ and login with your Google account
- Press F12 for web inspector, go to
Network
tab and refresh the page - Click any request and copy cookie values of
__Secure-1PSID
and__Secure-1PSIDTS
Usage
Initialization
from bard_webapi import BardClient
Secure_1PSID = [COOKIE VALUE HERE]
Secure_1PSIDTS = [COOKIE VALUE HERE]
client = BardClient(Secure_1PSID, Secure_1PSIDTS, proxy=None)
await client.init()
Generate contents from text inputs
response = await client.generate_content("Hello World!")
print(response.text)
Conversations across multiple turns
chat = client.start_chat()
response1 = await chat.send_message("Briefly introduce Europe")
response2 = await chat.send_message("What's the population there?")
print(response1.text, response2.text, sep="\n----------------------------------\n")
Retrieve images in response
response = await client.generate_content("Send me some pictures of cats")
images = response.images
for image in images:
print(f"{image.title}({image.url}) - {image.alt}", sep="\n")
Check Other Answer Choices
response = await client.generate_content("What's the best Japanese dish in your mind? Choose one only.")
candidates = response.candidates
for candidate in candidates:
print(candidate, "\n----------------------------------\n")
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bard-webapi-0.2.0.tar.gz
(8.7 kB
view hashes)
Built Distribution
Close
Hashes for bard_webapi-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ddc904e2631efee5b03d1792fe99984feaab3a00da9bfb97c2d9c5c853acbb1d |
|
MD5 | 5dd1da6e8203c36aa9e10a95eef88e6f |
|
BLAKE2b-256 | 382654bf6c8fc74fd1b2632794f73fbdcca1e58c888e61dba23de408a22e9d69 |