How to use Bard API for free (7 min)
Baca selengkapnya
:10 key points from the YouTube video "How to use the new Google Bard API for free":
* The video discusses how to use the Google Bard API for free in Python.
* The process involves obtaining a token from the browser's cookie section on part.google.com.
* The speaker explains how to access the token by right-clicking on the browser, going to "Inspect," navigating to the application, and finding the necessary cookie.
* The obtained token is then stored in a .env file, and the video demonstrates how to set up the Python environment to use this token.
* The tutorial concludes with an example Python script that imports the necessary modules, authenticates with the Google Bard API, and queries information, showcasing a sample question about the current stock price of Nvidia.
* Accessing Bard API Token: You can extract a free API token from the cookies section of your browser when using bard.google.com. Look for "_secure-1p_sid" cookie and the value within is your token.
* Using Token in Python: Save the extracted token in a .env file and access it within your Python program using the os and dotenv modules.
* Bard Class and Authentication: Import the bard API and instantiate a Bard class object with your token for authentication.
* Sending Queries and Receiving Responses: Use the Bard.get_answer() method to send your query and receive a dictionary response containing information like the current stock price of a company (as shown in the video).
* Limitations and Alternatives: Free API access may have limitations on call frequency. Consider alternative methods like Bard's built-in interface or paid Google Cloud Platform access for increased capabilities.