Basics
Ask AI

ask Method

Make sure you read through the Authentication page first, if you haven't already.

The most basic method under the Bard class that allows you to query Google Bard.

Example

import Bard from "bard-ai";
 
let myBard = new Bard(COOKIE);
 
console.log(await myBard.ask("Hello, world!"));

Parameters

ParameterTypeDescription
messagestringThe message you are querying Bard with. Required.
configobjectSome advanced options you can pass in.

Usage

The most simple usage simply involves passing your message into Bard.ask. The response of askAI by default is a string in Markdown format, and it includes images, codeblocks, and other Markdown accessories.

Config

Pass in a configuration JSON, like this:

myBard.ask("Hello, world!", {
  format: Bard.JSON,
  image: "./image.png",
  ids: { ...ids },
});
Config OptionTypeDescription
formatBard.MD or Bard.JSONReturn markdown or JSON, respectively
imagestring | BufferGive Bard an image to process with Google Lens. See Google Lens
idsobjectContinue a Chat with a one-time query. See exporting/importing chats.