Skip to content

EvanZhouDev/bard-ai

Repository files navigation

bard-ai v2 Banner

Docs | NPM | FAQ

Features

Highlights

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.

Comparison

Compared to alternative Bard API googlebard:

bard-ai Compared to GoogleBard
Learn more...

bard-ai surpasses leading competition GoogleBard by PawanOsman for three key reasons:

Size

bard-ai is a tiny 2.5kb minzipped, nearly 98% smaller than googlebard (112.8kb minzipped). This leads to faster downloads, and maximum efficiency.

Speed

bard-ai performs up to a whopping 2.25x faster than googlebard, when subjected to 4 consecutive requests, as measured with hyperfine.1

Features

bard-ai is updated with the latest and most advanced features available in Google Bard itself, including powerful Image Recognition with Google Lens.

Quick Start

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.

Contributors

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

  1. Run with hyperfine --runs 3 between bard-ai v2.0 and googlebard. 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'