openai.createChat

Returns a Chat object that keeps a chat history and calls OpenAI API to receive replies.

Syntax

createChat(initialMessage?, model?)

Parameters

Return value

An instance of Chat class with the following methods:

Example

let chat = openai.createChat("You are a nice assistant")
await chat.send("Hello")
"Hello, how are you?"
await chat.send("I am fine")
"That's good to hear."

See also