- 🍪 Multi-Cookie Use: Have multiple Bard instances
- 🖼️ Google Lens Support: Powerful image recognition
- 📷 Image Output: Access images from Google
- 🌐 Contextual Conversations: Maintain conversation context
- ⚡ Fast Responses: More than 2x faster than
googlebard
- 🪶 Lightweight: Just 2.5kb minzipped
- 📚 Typesafe: Types included out-of-the-box
Warning
Google is trying to stop these 3rd party APIs, so bard-ai
may not work for some of you. Try following the steps on the FAQ. However, if that still does not work, it may be time to migrate to the palm-api
package, for the official PaLM v2 API.
Compared to alternative Bard API googlebard
:
Learn more...
bard-ai
surpasses leading competition GoogleBard by PawanOsman for three key reasons:
bard-ai
is a tiny 2.5kb minzipped, nearly 98% smaller than googlebard
(112.8kb minzipped). This leads to faster downloads, and maximum efficiency.
bard-ai
performs up to a whopping 2.25x faster than googlebard
, when subjected to 4 consecutive requests, as measured with hyperfine
.1
bard-ai
is updated with the latest and most advanced features available in Google Bard itself, including powerful Image Recognition with Google Lens.
Copy the cookie labled __Secure-1PSID
on bard.google.com, and use it in the code here:
import Bard from "bard-ai";
let myBard = new Bard(COOKIE);
console.log(await myBard.ask("Hello, world!"));
Continue to explore full features, including Google Lens integration, with the docs.
A special shoutout to these amazing indviduals:
@acheong08 Original Python Bard API |
@ThatXliner Maintainer |
@Aldhanekaa Typescript and Feature Developer, Maintainer |
@RFS-ADRENO TypeScript Developer, Maintainer |
However, we thank every person that helps in the development process of this library, no matter that be in code, ideas, or anything else.
Read the docs to get started.
Footnotes
-
Run with
hyperfine --runs 3
betweenbard-ai
v2.0 andgooglebard
. Equivalent code was used in the runs:bard-ai
:import Bard from "bard-ai"; let bot = new Bard(COOKIE); console.log(await bot.ask("Hello world!")); console.log(await bot.ask("What is 1+1?")); console.log(await bot.ask("What about 2+2?")); console.log(await bot.ask("Goodbye."));
googlebard
:import { Bard } from "googlebard"; let bot = new Bard(`__Secure-1PSID=${COOKIE}`); console.log(await bot.ask("Hello world!")); console.log(await bot.ask("What is 1+1?")); console.log(await bot.ask("What about 2+2?")); console.log(await bot.ask("Goodbye."));
Result:
↩Benchmark 1: node bard-ai.js Time (mean ± σ): 18.346 s ± 0.768 s [User: 0.307 s, System: 0.067 s] Range (min … max): 17.531 s … 19.057 s 3 runs Benchmark 2: node googlebard.js Time (mean ± σ): 37.179 s ± 3.714 s [User: 1.416 s, System: 0.191 s] Range (min … max): 34.230 s … 41.349 s 3 runs Summary 'node bard-ai.js' ran 2.03 ± 0.22 times faster than 'node googlebard.js'