Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/timkmecl/chatgpt-api-wrapper
Node.js wrapper for connecting to ChatGPT using official OpenAI API
https://github.com/timkmecl/chatgpt-api-wrapper
Last synced: 2 months ago
JSON representation
Node.js wrapper for connecting to ChatGPT using official OpenAI API
- Host: GitHub
- URL: https://github.com/timkmecl/chatgpt-api-wrapper
- Owner: timkmecl
- Created: 2023-01-31T11:31:26.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-03-09T09:01:54.000Z (almost 2 years ago)
- Last Synced: 2024-10-01T15:47:11.556Z (3 months ago)
- Language: TypeScript
- Homepage:
- Size: 88.9 KB
- Stars: 46
- Watchers: 2
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- Awesome-ChatGPT - chatgpt-api-wrapper
- awesome-chatgpt - chatgpt-api-wrapper
README
# ChatGPT API Conversation Wrapper
[![NPM](https://img.shields.io/npm/v/chatgpt-api-wrapper.svg)](https://www.npmjs.com/package/chatgpt-api-wrapper)
[![Downloads](https://img.shields.io/npm/dt/chatgpt-api-wrapper.svg)](https://www.npmjs.com/package/chatgpt-api-wrapper)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](https://platform.openai.com/account/api-keys).
#### 💥 **Deprecated.** *Does not work anymore.* 💥
Based on [this method](https://twitter.com/GodlyIgnorance/status/1620270384150093825) and [this Python API](https://github.com/acheong08/ChatGPT) by [acheong08](https://github.com/acheong08). Also check out [this project](https://github.com/transitive-bullshit/chatgpt-api) for a more advanced API.
## Installation
You can install the package using npm:
```bash
npm install chatgpt-api-wrapper
```Alternatively, you can use the [`src/index.ts`](src/index.ts) file from this repository directly.
## Usage
```js
import ChatGPT from 'chatgpt-api-wrapper';const apiKey = '';
const chatGPT = new ChatGPT(apiKey);const response = await chatGPT.ask('Hello, how are you?');
console.log(response);
```Also see the [example.ts](example.ts) file.
## Methods
### `ask(request: string): Promise`
Sends a request to the ChatGPT API and returns the response.### `retry(request?: string): Promise`
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`
Resets the chat history.