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'