chatgpt-api-wrapper
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

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.

Package Sidebar

Install

npm i chatgpt-api-wrapper

Weekly Downloads

0

Version

0.1.2

License

MIT

Unpacked Size

13.6 kB

Total Files

8

Last publish

Collaborators

  • timkmecl