Ready to start? Read the Docs
- π€ Invoke Google Bard directly with
askAI
- π Create instances of Bard with
Bard.Chat
- π€ Import and Export conversations with
Bard.Chat.export
- π§βπ» Get all the metadata you need with the
useJSON
flag
- π³ Tree-shakeable: Maximize efficiency
- πͺΆ Tiny: Just 1.3kb minzipped
- π Fast: Up to 150% faster than
googlebard
- π Typesafe: Types included out-of-the-box
- π Straightforward API: Learn in minutes
- π² Free Forever: Authenticate and use without cost.
- π¨ No dependencies: Uses native
fetch
bard-ai
was built to provide free AI to everyone, through Google Bard.
It's completely free, and takes minimal setup.
Originally based off of acheong08's Python Bard API Code.
Compared to leading JS Bard API googlebard
:
Learn more...
Currently, the most popular JavaScript Bard is GoogleBard by PawanOsman.
However, there are 3 main reasons why bard-ai
is superior:
After being minified and gzipped, bard-ai
is 1.3KB, while google-bard
is 112.8KB (checked with Bundlephobia). That makes bard-ai
~99% smaller!
This library is up to 150% faster, as tested with hyperfine --warmup 1 --runs 3
between bard-ai
and googlebard
1.
googlebard
overcomplicates many things, including importing the cookies to importing and exporting conversations. bard-ai
has been built to make it simple and easy to use.
Read the documentation, available at bard-ai-docs.vercel.app.
- Introduction
- Pre-Requisites
- Basics
- Advanced
- Typescript Support
- Polyfilling Fetch
Go ahead! It's easy to learn... Trust me!
Footnotes
-
Run
hyperfine --warmup 1 --runs 3
betweenbard-ai
v1.2.2 andgooglebard
with following code forgooglebard
(in "googlebard.js"):import { Bard } from "googlebard"; let cookies = `__Secure-1PSID=MY_KEY`; let bot = new Bard(cookies); let response = await bot.ask("Hello world!"); console.log(response);
And following code for
bard-ai
(in "bard-ai.js"):import Bard, { askAI } from "bard-ai"; await Bard.init("MY_KEY"); console.log(await askAI("Hello world!"));
With this benchmark output:
β©Benchmark 1: node bard-ai.js Time (mean Β± Ο): 6.951 s Β± 2.272 s [User: 0.181 s, System: 0.044 s] Range (min β¦ max): 5.333 s β¦ 9.549 s 3 runs Benchmark 2: node googlebard.js Time (mean Β± Ο): 7.691 s Β± 1.029 s [User: 0.389 s, System: 0.073 s] Range (min β¦ max): 6.510 s β¦ 8.394 s 3 runs Summary 'node bard-ai.js' ran 1.11 Β± 0.39 times faster than 'node googlebard.js'