1.0.1 • Published 2 years ago

@ryzvision/bing-chat v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Bing Chat API (modified)

This package is a Node.js wrapper around Bing Chat by Microsoft. TS batteries included. ✨

Install

npm install @ryzvision/bing-chat

Make sure you're using node >= 18 so fetch is available.

Usage

You need access to Bing Chat OR a valid cookie from someone who has access.

The cookie you need from Bing is the _U cookie (or just all of the cookies concatenated together; both will work).

import { BingChat } from '@ryzvision/bing-chat'

async function example() {
  const api = new BingChat({
    cookie: process.env.BING_COOKIE
  })

  const res = await api.sendMessage('Hello World!')
  console.log(res.text)
}

If you are in CJS type, then you should use async function

(async () => {
  const { BingChat } = await import('@ryzvision/bing-chat')

  const api = new BingChat({
    cookie: process.env.BING_COOKIE
  })

  const res = await api.sendMessage('Hello World!')
  console.log(res.text)

})()
const res = await api.sendMessage('Write a 500 word essay on frogs.', {
  // print the partial response as the AI is "typing"
  onProgress: (partialResponse) => console.log(partialResponse.text)
})

// print the full text at the end
console.log(res.text)

Compatibility

  • This package is ESM-only.
  • This package supports node >= 18.
  • This module assumes that fetch is installed globally.
  • If you want to build a website using bing-chat, we recommend using it only from your backend API

Credit

License