Skip to main content
Deno 2 is finally here 🎉️
Learn more

BingAI API

A BingAI implementation using Deno

This is a Deno implementation of @waylaidwanderer’s ChatGPT/BingAI NodeJS implementation

About BingAI

Currently, you have to waitlist yourself to be able to access it. You can join the waitlist here. If you already have access to it, you will be able to use this package.

Prerequisites

  • Deno v1.25.0 or up
  • A Microsoft account with New Bing access

Cookies

  1. First head to Bing.
  2. Next you will need to open up DevTools and go to the Application tab.
  3. You will have to look for a cookie under the name of KievRPSSecAuth.

Usage

Normal Usage

import * as bingchat from "https://deno.land/x/bingchat@v1.0.0/mod.ts";

(async() => {
    const bot = new bingchat.BingAIClient({
        cookies: [
            {
                name: "KievRPSSecAuth",
                value: "COOKIE_HERE"
            }
        ]
    })

    const res = await bot.sendMessage("Hello")
    console.log(res.response)
})()

Conversation Usage

import * as bingchat from "https://deno.land/x/bingchat@v1.0.0/mod.ts";

(async() => {
    const bot = new bingchat.BingAIClient({
        cookies: [
            {
                name: "KievRPSSecAuth",
                value: "COOKIE_HERE"
            }
        ]
    })

    const response = await bot.sendMessage("Hello")
    console.log(response.response)

    const response2 = await bot.sendMessage("What did I say previously?", {
        conversationId: response.conversationId,
        conversationSignature: response.conversationSignature,
        clientId: response.clientId,
        invocationId: response.invocationId
    })
    console.log(response2.response)
})()

On Progress

import * as bingchat from "https://deno.land/x/bingchat@v1.0.0/mod.ts";

(async() => {
    const bot = new bingchat.BingAIClient({
        cookies: [
            {
                name: "KievRPSSecAuth",
                value: "COOKIE_HERE"
            }
        ]
    })

    await bot.sendMessage("Hello", {
        onProgress: (data: string) => {
            console.log(data)
        }
    })
})()

Credits