node-chatgpt-api  by waylaidwanderer

Node.js module for ChatGPT/Bing AI, plus REST API server and CLI app

created 2 years ago
4,209 stars

Top 11.9% on sourcepulse

GitHubView on GitHub
Project Summary

This project provides a versatile Node.js client for interacting with OpenAI's ChatGPT and Bing AI models. It offers a Node.js module, a REST API server, and a CLI application, enabling developers and users to integrate advanced AI chat capabilities into various applications and workflows.

How It Works

The library offers three primary clients: ChatGPTClient for the official OpenAI API (gpt-3.5-turbo, text-davinci-003), BingAIClient for Bing's GPT-4 powered chat, and ChatGPTBrowserClient for direct interaction with chat.openai.com via a reverse proxy. ChatGPTClient replicates conversation threads using message and conversation IDs, with optional persistent storage via Keyv. BingAIClient includes a "jailbreak" mode for unlimited messages. The clients support customizable prompts, user labels, and AI labels for persona control.

Quick Start & Requirements

  • Install: npm i @waylaidwanderer/chatgpt-api or npm i -g @waylaidwanderer/chatgpt-api for global CLI/server use.
  • Prerequisites: Node.js >= 16.0.0. Docker is optional for the API server.
  • API Key: An OpenAI API key is required for ChatGPTClient. Bing AI requires a userToken or cookies.
  • Docs: Getting Started, API Server, CLI

Highlighted Details

  • Supports official gpt-3.5-turbo via OpenAI API, priced per token.
  • Experimental BingAIClient with GPT-4 and a "jailbreak" mode.
  • ChatGPTBrowserClient uses a reverse proxy for Cloudflare bypass to access chat.openai.com.
  • API server supports REST endpoints and Server-Sent Events (SSE) for streaming responses.
  • Persistent conversation storage via Keyv adapters (e.g., keyv-file).

Maintenance & Community

  • Active development with multiple contributors.
  • Projects using the library are listed in the README, including PandoraAI, LibreChat, and halbot.
  • Discord community link is available in the README.

Licensing & Compatibility

  • MIT License. Permissive for commercial use and integration into closed-source projects.

Limitations & Caveats

Automating chat.openai.com carries a risk of account bans. The ChatGPTBrowserClient exposes your access token to a third-party server. ChatGPTClient conversations are limited to approximately the last 3000 tokens, potentially causing earlier messages to be forgotten.

Health Check
Last commit

1 year ago

Responsiveness

1 day

Pull Requests (30d)
0
Issues (30d)
0
Star History
13 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.