📅 You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP
Socket
Sign inDemoInstall
Socket

chatgpt-api-wrapper

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chatgpt-api-wrapper

Node.js client for talking to ChatGPT API in a conversational manner.

0.1.2
latest
Source
npm
Version published
Maintainers
1
Created
Source

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.

Keywords

openai

FAQs

Package last updated on 03 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts