Advanced
Using Google Lens

Using Google Lens

With bard-ai v2, you now have access to a powerful AI image system, Google Lens. Pass in images to Bard.ask() or Chat.ask(), and Bard will be able to process them.

Images can be a jpeg, jpg, png, or webp.

You can pass in the image as a Buffer or as a path, in the image option in config. Here's an example...

Path

import Bard from "bard-ai";
 
let myBard = new Bard(COOKIE);
 
console.log(
  await myBard.ask("What city is this?", {
    image: "./city_image.png",
  })
);

Buffer

import Bard from "bard-ai";
import fs from "fs";
 
let cityImage = fs.readFileSync("./city_image.png");
 
let myBard = new Bard(COOKIE);
 
console.log(
  await myBard.ask("What city is this?", {
    image: cityImage,
  })
);

Compounded with the fact that you can get image output, Google Lens is a powerful feature.