0.1.2 • Published 2 years ago

chatgpt-api-wrapper v0.1.2

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

ChatGPT API Conversation Wrapper

NPM Downloads

A simple Node.js wrapper for connecting to ChatGPT using official OpenAI API, which allows you to easily send requests and get responses from the API in a conversational manner.

You only need to provide your OpenAI API key (no session tokens or using pupeteer for browser automation) - get it here.

Based on this method and this Python API by acheong08.

Installation

You can install the package using npm:

npm install chatgpt-api-wrapper

Alternatively, you can use the src/index.ts file from this repository directly.

Usage

import ChatGPT from 'chatgpt-api-wrapper';

const apiKey = '<YOUR_API_KEY>';
const chatGPT = new ChatGPT(apiKey);

const response = await chatGPT.ask('Hello, how are you?');
console.log(response);

Also see the example.ts file.

Methods

ask(request: string): Promise<any>

Sends a request to the ChatGPT API and returns the response.

retry(request?: string): Promise<any>

Retries a request to the ChatGPT API and returns the response. If the request argument is not provided, it retries the previous request, otherwise it sends a new request in place of the previous one.

resetConversation(): Promise<void>

Resets the chat history.

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago