Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@waylaidwanderer/chatgpt-api

Package Overview
Dependencies
Maintainers
1
Versions
168
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@waylaidwanderer/chatgpt-api

An API layer for ChatGPT, powered by @transitive-bullshit's chatgpt-api (chatgpt on npm).

  • 0.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
213
decreased by-21.4%
Maintainers
1
Weekly downloads
 
Created
Source

ChatGPT API Server

This is a simple API server wrapper for ChatGPT. It supports multiple OpenAI accounts, setting proxies for each account, and load-balancing requests between accounts.

Getting Started

Prerequisites

  • Node.js
  • npm
  • An account with ChatGPT
  • A valid NopeCHA API key
  • xvfb (for headless Chrome)

Installation

You can install the package using

npm i -g @waylaidwanderer/chatgpt-api

then run it using chatgpt-api (or xvfb-run chatgpt-api for headless servers).
This takes an optional --settings=<path_to_settings.js> parameter, or looks for settings.js in the current directory if not set, with the following contents:

module.exports = {
    accounts: [
        {
            email: 'account1@example.com',
            password: 'password1',
        },
        {
            email: 'account2@example.com',
            password: 'password2',
            proxy: 'user:pass@ip:port',
        },
        {
            email: 'account3@example.com',
            password: 'password3',
            proxy: 'ip:port',
        },
        // add more accounts as needed...
    ],
    port: 3000, // the port the server will run on (optional, defaults to 3000)
    nopechaKey: 'nopechaKey', // your NopeCHA API key
};

Alternatively, you can install the package locally and run it using node index.js:

  1. Clone this repository
  2. Install dependencies with npm install
  3. Rename settings.example.js to settings.js in the root directory and change the settings where required.
  4. Start the server using xvfb-run node index.js (for headless servers) or node index.js

Usage

To start a conversation with ChatGPT, send a POST request to the server's /conversation endpoint with a JSON body in the following format:

{
    "message": "Hello, how are you today?",
    "conversationId": "your-conversation-id (optional)",
    "parentMessageId": "your-parent-message-id (optional)"
}

The server will return a JSON object containing ChatGPT's response:

{
    "response": "I'm doing well, thank you! How are you?",
    "conversationId": "your-conversation-id",
    "messageId": "your-message-id"
}

If the request is unsuccessful, the server will return a JSON object with an error message and a status code of 503.

If no sessions have finished initializing yet:

{
    "error": "No sessions available."
}

If there was an error sending the message to ChatGPT:

{
    "error": "There was an error communicating with ChatGPT."
}

Contributing

If you'd like to contribute to this project, please create a pull request with a detailed description of your changes.

Acknowledgments

This API server is powered by @transitive-bullshit's chatgpt-api (chatgpt on npm).

License

This project is licensed under the MIT License.

Keywords

FAQs

Package last updated on 07 Jan 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc