Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
N

node-chatgpt-api

> AI 编程
Open source

A client implementation for ChatGPT and Bing AI. Available as a Node.js module, REST API server, and CLI app.

4.2K stars0 likes3 views
WebsiteGitHub

About

A client implementation for ChatGPT and Bing AI. Available as a Node.js module, REST API server, and CLI app.

Updates

2023-03-01

Support for the official ChatGPT model has been added! You can now use the gpt-3.5-turbo model with the official OpenAI API, using ChatGPTClient. This is the same model that ChatGPT uses, and it's the most powerful model available right now. Usage of this model is not free, however it is 10x cheaper (priced at $0.002 per 1k tokens) than text-davinci-003.

See OpenAI's post, Introducing ChatGPT and Whisper APIs for more information.

To use it, set modelOptions.model to gpt-3.5-turbo, and ChatGPTClient will handle the rest. The default model used in ChatGPTClient is now gpt-3.5-turbo. You can still set userLabel, chatGptLabel and promptPrefix (system instructions) as usual.

There may be a higher chance of your account being banned if you continue to automate chat.openai.com. Continue doing so at your own risk.

Previous Updates
2023-02-19

I've added an experimental ChatGPTBrowserClient which depends on a reverse proxy server that makes use of a Cloudflare bypass, allowing you to talk to ChatGPT (chat.openai.com) without requiring browser automation. All you need is your access token from https://chat.openai.com/api/auth/session.

As always, please note that if you choose to go this route, you are exposing your access token to a closed-source third-party server. If you are concerned about this, you may choose to either use a free ChatGPT account to minimize risks, or continue using ChatGPTClient instead with the text-davinci-003 model.

2023-02-15

The method we were using to access the ChatGPT underlying models has been patched, unfortunately. Your options right now are to either use the official OpenAI API with the text-davinci-003 model (which costs money), or use a browser-based solution to interface with ChatGPT's backend (which is less powerful, more rate-limited and is not supported by this library at this time).

2023-02-11

With the help of @PawanOsman, we've figured out a way to continue using the ChatGPT underlying models. To hopefully prevent losing access again, we've decided to provide reverse proxy servers compatible with the OpenAI API. I've updated ChatGPTClient to support using a reverse proxy server instead of the OpenAI API server. See Using a Reverse Proxy for more information on available proxy servers and how they work.

Please note that if you choose to go this route, you are exposing your access token to a closed-source third-party server. If you are concerned about this, you may choose to either use a free ChatGPT account to minimize risks, or continue using the official OpenAI API instead with the text-davinci-003 model.

2023-02-10

I've found a new working model for text-chat-davinci-002, text-chat-davinci-002-sh-alpha-aoruigiofdj83. This is the underlying model that the ChatGPT Plus "Turbo" version uses. Responses are blazing fast. I've updated the library to use this model.

Bad timing; text-chat-davinci-002-sh-alpha-aoruigiofdj83 was removed shortly after, possibly due to a new model somewhere out there?

2023-02-09

Experience the power of Bing's GPT-4 version of ChatGPT with BingAIClient (experimental). The API server and CLI still need to be updated to support this, but you can use the client directly right now. Please note that if your account is still wait-listed, you will not be able to use this client.

2023-02-08

Even though text-chat-davinci-002-20221122 is back up again, it seems like it's constantly overloaded and returns a 429 error. It's likely that OpenAI only dedicated a small amount of resources to this model to prevent it being widely used by the public. Additionally, I've heard that newer versions are now access-locked to OpenAI employees and partners, so it's unlikely that we'll be able to find any workarounds until the model is officially released.

You may use the text-davinci-003 model instead as a drop-in replacement. Keep in mind that text-davinci-003 is not as good as text-chat-davinci-002 (which is trained via RHLF and fine-tuned to be a conversational AI), though results are still pretty good in most cases. Please note that using text-davinci-003 will cost you credits ($).

I will be re-adding support for the browser-based ChatGPT for the API server and CLI. Please star and watch this repository for updates.

2023-02-07

The roller coaster has reached the next stop. text-chat-davinci-002-20221122 is back up again.

Trying to use text-chat-davinci-002-20221122 with the OpenAI API now returns a 404 error. You may use the text-davinci-003 model instead as a drop-in replacement. Keep in mind that text-davinci-003 is not as good as text-chat-davinci-002 (which is trained via RHLF and fine-tuned to be a conversational AI), though results are still very good. Please note that using text-davinci-003 will cost you credits ($).

Please hold for further updates as we investigate further workarounds.

2023-02-02

Trying to use text-chat-davinci-002-20230126 with the OpenAI API now returns a 404 error. Someone has already found the new model name, but they are unwilling to share at this time. I will update this repository once I find the new model. If you have any leads, please open an issue or a pull request.

In the meantime, I've added support for models like text-davinci-003, which you can use as a drop-in replacement. Keep in mind that text-davinci-003 is not as good as text-chat-davinci-002 (which is trained via RHLF and fine-tuned to be a conversational AI), though results are still very good. Please note that using text-davinci-003 will cost you credits ($).

Discord user @pig#8932 has found a working text-chat-davinci-002 model, text-chat-davinci-002-20221122. I've updated the library to use this model.

ChatGPT API

A client implementation for ChatGPT and Bing AI. Available as a Node.js module, REST API server, and CLI app.

Table of Contents

  • Features
  • Getting Started
    • Prerequisites
    • Usage
      • Module
      • API Server
      • CLI
    • Using a Reverse Proxy
  • Projects
  • Web Client
  • Caveats
  • Contributing
  • License

Features

  • Includes an API server (with Docker support) you can run to use ChatGPT in non-Node.js applications.
  • Includes a CLI interface where you can chat with ChatGPT.
  • Includes clients that you can use in your own Node.js applications.
  • ChatGPTClient: support for the official ChatGPT underlying model, gpt-3.5-turbo, via OpenAI's API.
    • Replicates chat threads from the official ChatGPT website (with conversation IDs and message IDs), with persistent conversations using Keyv.
      • Conversations are stored in memory by default, but you can optionally install a storage adapter to persist conversations to a database.
      • The keyv-file adapter is also included in this package, and can be used to store conversations in a JSON file if you're using the API server or CLI (see settings.example.js).
    • Supports configurable prompt prefixes, and custom names for the user and ChatGPT.
      • In essence, this allows you to make a chatbot with any personality you want.
      • This is currently only configurable on a global level, but I plan to add support for per-conversation customization.
    • Retains support for models like text-davinci-003
  • BingAIClient: support for Bing's version of ChatGPT, powered by GPT-4.
    • Includes a built-in jailbreak you can activate which enables unlimited chat messages per conversation, unlimited messages per day, and brings Sydney back.
  • ChatGPTBrowserClient: support for the official ChatGPT website, using a reverse proxy server for a Cloudflare bypass.
    • There may be a high chance of your account being banned if you continue to automate chat.openai.com. Continue doing so at your own risk.

Getting Started

Prerequisites

  • Node.js >= 16.0.0
  • npm
  • Docker (optional, for API server)
  • OpenAI API key

Usage

Module

bash
npm i @waylaidwanderer/chatgpt-api
BingAIClient

See demos/use-bing-client.js.

ChatGPTClient

See demos/use-client.js.

ChatGPTBrowserClient

See demos/use-browser-client.js.

API Server

Setup

You can install the package using

bash
npm i -g @waylaidwanderer/chatgpt-api

then run it using chatgpt-api. 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:

settings.js
…

Alternatively, you can install and run the package directly.

  1. Clone this repository: git clone https://github.com/waylaidwanderer/node-chatgpt-api
  2. Install dependencies with npm install (if not using Docker)
  3. Rename settings.example.js to settings.js in the root directory and change the settings where required.
  4. Start the server:
    • using npm start or npm run server (if not using Docker)
    • using docker-compose up (requires Docker)

Endpoints

POST /conversation

Start or continue a conversation. Optional parameters are only necessary for conversations that span multiple requests.

Field Description
message The message to be displayed to the user.
conversationId (Optional) An ID for the conversation you want to continue.
jailbreakConversationId (Optional, for BingAIClient only) Set to true to start a conversation in jailbreak mode. After that, this should be the ID for the jailbreak conversation (given in the response as a parameter also

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScriptapiapi-restapi-serverbing

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
CategoryAI 编程
PricingOpen source

> Related tools

G
GitHub Copilot
GitHub 官方 AI 编程助手,覆盖补全、Chat 与 Agent 模式。
C
Cursor
AI 原生代码编辑器,对话改代码、多文件 Agent 与规则体系是其核心。
S
skills
Skills for Real Engineers. Straight from my .agents directory.