Home Artificial Intelligence Access Google Bard Easily with Python Package Bard-API Bard-API Conclusion

Access Google Bard Easily with Python Package Bard-API Bard-API Conclusion

3
Access Google Bard Easily with Python Package Bard-API
Bard-API
Conclusion

Bard-API is a Python package developed by Daniel Park, and it allows users to access the Bard within the user environment easily. Establishing every little thing takes around 5 minutes, and we will use the Bard-API immediately. Let’s try to try this.

First, we would want the __Secure-1PSID Cookies of your Google Bard Account value from. To realize that, go to the Google Bard website and press F12 to access the console.

Select the Application tab and choose the Cookies from the Storage menu drop-down. Within the Cookies, select the accounts and take a look at to search out the __Secure-1PSID and duplicate the values. To summarize what we do, I provide them within the image below.

Image by Writer

After we get the values, we want to put in the Bard-API package with the next code.

pip install bardapi

For the following part, we must set the __Secure-1PSID into the Bard-API environment. You possibly can use the next code to try this.

from bardapi import Bard
import os

#Replace XXXX with the values you get from __Secure-1PSID
os.environ['_BARD_API_KEY']="XXXX"

With all of the preparation ready, we will now access the Google Bard in the environment.

# set your input text
input_text = "what's google bard?"

print(Bard().get_answer(input_text)['content'])

Image by Writer

That’s it. With just a few lines of code, you’ll be able to now access the Google Bard with a Python package. You possibly can at all times visit the documentation or the Google Bard FAQ for more information.

3 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here