{"_id":"@catalystclan/chatgpt","_rev":"3-dc5f0785c1d5fededa533d4802e3309f","name":"@catalystclan/chatgpt","dist-tags":{"beta":"5.0.10-beta.2","latest":"5.2.4-beta.0"},"versions":{"5.0.10-beta.0":{"name":"@catalystclan/chatgpt","version":"5.0.10-beta.0","description":"Node.js client for the official ChatGPT API.","author":{"name":"Travis Fischer","email":"travis@transitivebullsh.it"},"repository":{"type":"git","url":"git+https://github.com/transitive-bullshit/chatgpt-api.git"},"license":"MIT","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"source":"./src/index.ts","types":"./build/index.d.ts","exports":{".":{"import":"./build/index.mjs","types":"./build/index.d.ts","require":"./build/index.js","default":"./build/index.mjs"}},"bin":{"chatgpt":"bin/cli.js"},"engines":{"node":">=14"},"scripts":{"build":"tsup","dev":"tsup --watch","clean":"del build","prebuild":"run-s clean","predev":"run-s clean","pretest":"run-s build","docs":"typedoc","prepare":"husky install","pre-commit":"lint-staged","test":"run-p test:*","test:prettier":"prettier '**/*.{js,jsx,ts,tsx}' --check"},"dependencies":{"@dqbd/tiktoken":"^0.4.0","cac":"^6.7.14","conf":"^11.0.1","eventsource-parser":"^0.0.5","keyv":"^4.5.2","p-timeout":"^6.1.1","quick-lru":"^6.1.1","read-pkg-up":"^9.1.0","uuid":"^9.0.0"},"devDependencies":{"@keyv/redis":"^2.5.6","@trivago/prettier-plugin-sort-imports":"^4.1.1","@types/node":"^18.15.0","@types/uuid":"^9.0.1","del-cli":"^5.0.0","dotenv-safe":"^8.2.0","husky":"^8.0.2","lint-staged":"^13.2.0","npm-run-all":"^4.1.5","ora":"^6.1.2","prettier":"^2.8.4","tsup":"^6.6.3","tsx":"^3.12.3","typedoc":"^0.23.26","typedoc-plugin-markdown":"^3.13.6","typescript":"^4.9.3"},"lint-staged":{"*.{ts,tsx}":["prettier --write"]},"keywords":["openai","chatgpt","chat","gpt","gpt-3","gpt3","gpt4","chatbot","machine learning","conversation","conversational ai","ai","ml","bot"],"gitHead":"2b4efd44e9b911f47874c3814e0f86142531c9e2","bugs":{"url":"https://github.com/transitive-bullshit/chatgpt-api/issues"},"homepage":"https://github.com/transitive-bullshit/chatgpt-api#readme","_id":"@catalystclan/chatgpt@5.0.10-beta.0","_nodeVersion":"19.8.1","_npmVersion":"9.5.1","dist":{"integrity":"sha512-SDW+Gl1rOtCAvAsMRoRxHqqrpLDo5lMluy4HrCOJL4gq9BJAdGsDKxVmdJro+WSpyGQJ7IPd1271qZ8zkOlnDg==","shasum":"de8d4523755a05541274005e779fff5863b02b29","tarball":"https://registry.npmjs.org/@catalystclan/chatgpt/-/chatgpt-5.0.10-beta.0.tgz","fileCount":9,"unpackedSize":190222,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHOwM2YXgvQaxH7DmRMjrCJqqbvrGytIPPFlKTXn3Zc8AiAtgW00R3FgF543bofpEJoOLT981XfNpGywOdYwqdytTQ=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkG9erACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr/PA/+JoGMewit6oqC+eZo+PgNP3NY5ngoT9KVQuEA28uszkfoxQnM\r\nOARCNaBDcf8+BaanrxntN9k1xvWfqC/1UnsvG2naL74nmvKHNvNB6rPsCpfa\r\nd+uE9iwvbIbidV3CI/F0spaJ+0cAk7BT8PaNaJQdgs/u+KUEpyt9Mvzd2RZ5\r\nka/F6m1i2zyu9FuaeTTTfZb5qY4LDq7mTNDH8A0BLYltSMamGlIubHiuLRth\r\nx0gun4pr4iKdf+a8mhtpfocK+e4qHKzdT/csrAfs02sCVWxfw3ZB90Z/4mIg\r\n388GPJzXHOz5qL75le+sH6CtFjyWurAcQv62UQlopEqvb3im99ybmg4Ponwr\r\n6B08/914GV7WcIfvi1RNS25HSShXdvoj18qV8e5nvQ3RBnpA826KdiSB7QK4\r\nDam1Zcx4i+h3ZBLusIl0sUfyzeVRLgmOjehNMG1tIX10Yw15C0s+Zv/FbgVy\r\nuZEW5czeykhDHfG+kH0pocZSO2n/KQcJO1FkcLJ4DR4zhlb6kVDv+wm/YMQS\r\nwxljNb4Sp52lfOfmo85D0wQoViSa29JGlxPDQFeMd4mU5loQNon+u9O39Z+G\r\njqYRbzfmJj8I6fVdhL2EO87Ao8yf+9yorHgjrFhfP9NwuhwYeN9Y44q/TWi4\r\n/dxf7PwqcVi9TPr6YJZHD7sjmV/rE4cWOSg=\r\n=ND9d\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"jakelaoyu","email":"jake.laoyu@gmail.com"},"directories":{},"maintainers":[{"name":"jakelaoyu","email":"jake.laoyu@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chatgpt_5.0.10-beta.0_1679546283400_0.573779176858624"},"_hasShrinkwrap":false},"5.0.10-beta.1":{"name":"@catalystclan/chatgpt","version":"5.0.10-beta.1","description":"Node.js client for the official ChatGPT API.","author":{"name":"Travis Fischer","email":"travis@transitivebullsh.it"},"repository":{"type":"git","url":"git+https://github.com/transitive-bullshit/chatgpt-api.git"},"license":"MIT","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"source":"./src/index.ts","types":"./build/index.d.ts","exports":{".":{"import":"./build/index.mjs","types":"./build/index.d.ts","require":"./build/index.js","default":"./build/index.mjs"}},"bin":{"chatgpt":"bin/cli.js"},"engines":{"node":">=14"},"scripts":{"build":"tsup","dev":"tsup --watch","clean":"del build","prebuild":"run-s clean","predev":"run-s clean","pretest":"run-s build","docs":"typedoc","prepare":"husky install","pre-commit":"lint-staged","test":"run-p test:*","test:prettier":"prettier '**/*.{js,jsx,ts,tsx}' --check"},"dependencies":{"@dqbd/tiktoken":"^0.4.0","cac":"^6.7.14","conf":"^11.0.1","eventsource-parser":"^0.0.5","keyv":"^4.5.2","p-timeout":"npm:@esm2cjs/p-timeout@^6.0.0","quick-lru":"^6.1.1","read-pkg-up":"^9.1.0","uuid":"^9.0.0"},"devDependencies":{"@keyv/redis":"^2.5.6","@trivago/prettier-plugin-sort-imports":"^4.1.1","@types/node":"^18.15.0","@types/uuid":"^9.0.1","del-cli":"^5.0.0","dotenv-safe":"^8.2.0","husky":"^8.0.2","lint-staged":"^13.2.0","npm-run-all":"^4.1.5","ora":"^6.1.2","prettier":"^2.8.4","tsup":"^6.6.3","tsx":"^3.12.3","typedoc":"^0.23.26","typedoc-plugin-markdown":"^3.13.6","typescript":"^4.9.3"},"lint-staged":{"*.{ts,tsx}":["prettier --write"]},"keywords":["openai","chatgpt","chat","gpt","gpt-3","gpt3","gpt4","chatbot","machine learning","conversation","conversational ai","ai","ml","bot"],"readme":"# ChatGPT API <!-- omit in toc -->\n\n> Node.js client for the official [ChatGPT](https://openai.com/blog/chatgpt/) API.\n\n[![NPM](https://img.shields.io/npm/v/chatgpt.svg)](https://www.npmjs.com/package/chatgpt) [![Build Status](https://github.com/transitive-bullshit/chatgpt-api/actions/workflows/test.yml/badge.svg)](https://github.com/transitive-bullshit/chatgpt-api/actions/workflows/test.yml) [![MIT License](https://img.shields.io/badge/license-MIT-blue)](https://github.com/transitive-bullshit/chatgpt-api/blob/main/license) [![Prettier Code Formatting](https://img.shields.io/badge/code_style-prettier-brightgreen.svg)](https://prettier.io)\n\n- [Intro](#intro)\n- [Updates](#updates)\n- [CLI](#cli)\n- [Install](#install)\n- [Usage](#usage)\n  - [Usage - ChatGPTAPI](#usage---chatgptapi)\n  - [Usage - ChatGPTUnofficialProxyAPI](#usage---chatgptunofficialproxyapi)\n    - [Reverse Proxy](#reverse-proxy)\n    - [Access Token](#access-token)\n- [Docs](#docs)\n- [Demos](#demos)\n- [Projects](#projects)\n- [Compatibility](#compatibility)\n- [Credits](#credits)\n- [License](#license)\n\n## Intro\n\nThis package is a Node.js wrapper around [ChatGPT](https://openai.com/blog/chatgpt) by [OpenAI](https://openai.com). TS batteries included. ✨\n\n<p align=\"center\">\n  <img alt=\"Example usage\" src=\"/media/demo.gif\">\n</p>\n\n## Updates\n\n<details open>\n<summary><strong>March 1, 2023</strong></summary>\n\n<br/>\n\nThe [official OpenAI chat completions API](https://platform.openai.com/docs/guides/chat) has been released, and it is now the default for this package! 🔥\n\n| Method                      | Free?  | Robust?  | Quality?                |\n| --------------------------- | ------ | -------- | ----------------------- |\n| `ChatGPTAPI`                | ❌ No  | ✅ Yes   | ✅️ Real ChatGPT models |\n| `ChatGPTUnofficialProxyAPI` | ✅ Yes | ☑️ Maybe | ✅ Real ChatGPT         |\n\n**Note**: We strongly recommend using `ChatGPTAPI` since it uses the officially supported API from OpenAI. We may remove support for `ChatGPTUnofficialProxyAPI` in a future release.\n\n1. `ChatGPTAPI` - Uses the `gpt-3.5-turbo-0301` model with the official OpenAI chat completions API (official, robust approach, but it's not free)\n2. `ChatGPTUnofficialProxyAPI` - Uses an unofficial proxy server to access ChatGPT's backend API in a way that circumvents Cloudflare (uses the real ChatGPT and is pretty lightweight, but relies on a third-party server and is rate-limited)\n\n</details>\n\n<details>\n<summary><strong>Previous Updates</strong></summary>\n\n<br/>\n\n<details>\n<summary><strong>Feb 19, 2023</strong></summary>\n\n<br/>\n\nWe now provide three ways of accessing the unofficial ChatGPT API, all of which have tradeoffs:\n\n| Method                      | Free?  | Robust?  | Quality?          |\n| --------------------------- | ------ | -------- | ----------------- |\n| `ChatGPTAPI`                | ❌ No  | ✅ Yes   | ☑️ Mimics ChatGPT |\n| `ChatGPTUnofficialProxyAPI` | ✅ Yes | ☑️ Maybe | ✅ Real ChatGPT   |\n| `ChatGPTAPIBrowser` (v3)    | ✅ Yes | ❌ No    | ✅ Real ChatGPT   |\n\n**Note**: I recommend that you use either `ChatGPTAPI` or `ChatGPTUnofficialProxyAPI`.\n\n1. `ChatGPTAPI` - (Used to use) `text-davinci-003` to mimic ChatGPT via the official OpenAI completions API (most robust approach, but it's not free and doesn't use a model fine-tuned for chat)\n2. `ChatGPTUnofficialProxyAPI` - Uses an unofficial proxy server to access ChatGPT's backend API in a way that circumvents Cloudflare (uses the real ChatGPT and is pretty lightweight, but relies on a third-party server and is rate-limited)\n3. `ChatGPTAPIBrowser` - (_deprecated_; v3.5.1 of this package) Uses Puppeteer to access the official ChatGPT webapp (uses the real ChatGPT, but very flaky, heavyweight, and error prone)\n\n</details>\n\n<details>\n<summary><strong>Feb 5, 2023</strong></summary>\n\n<br/>\n\nOpenAI has disabled the leaked chat model we were previously using, so we're now defaulting to `text-davinci-003`, which is not free.\n\nWe've found several other hidden, fine-tuned chat models, but OpenAI keeps disabling them, so we're searching for alternative workarounds.\n\n</details>\n\n<details>\n<summary><strong>Feb 1, 2023</strong></summary>\n\n<br/>\n\nThis package no longer requires any browser hacks – **it is now using the official OpenAI completions API** with a leaked model that ChatGPT uses under the hood. 🔥\n\n```ts\nimport { ChatGPTAPI } from 'chatgpt'\n\nconst api = new ChatGPTAPI({\n  apiKey: process.env.OPENAI_API_KEY\n})\n\nconst res = await api.sendMessage('Hello World!')\nconsole.log(res.text)\n```\n\nPlease upgrade to `chatgpt@latest` (at least [v4.0.0](https://github.com/transitive-bullshit/chatgpt-api/releases/tag/v4.0.0)). The updated version is **significantly more lightweight and robust** compared with previous versions. You also don't have to worry about IP issues or rate limiting.\n\nHuge shoutout to [@waylaidwanderer](https://github.com/waylaidwanderer) for discovering the leaked chat model!\n\n</details>\n</details>\n\nIf you run into any issues, we do have a pretty active [Discord](https://discord.gg/v9gERj825w) with a bunch of ChatGPT hackers from the Node.js & Python communities.\n\nLastly, please consider starring this repo and <a href=\"https://twitter.com/transitive_bs\">following me on twitter <img src=\"https://storage.googleapis.com/saasify-assets/twitter-logo.svg\" alt=\"twitter\" height=\"24px\" align=\"center\"></a> to help support the project.\n\nThanks && cheers,\n[Travis](https://twitter.com/transitive_bs)\n\n## CLI\n\nTo run the CLI, you'll need an [OpenAI API key](https://platform.openai.com/overview):\n\n```bash\nexport OPENAI_API_KEY=\"sk-TODO\"\nnpx chatgpt \"your prompt here\"\n```\n\nBy default, the response is streamed to stdout, the results are stored in a local config file, and every invocation starts a new conversation. You can use `-c` to continue the previous conversation and `--no-stream` to disable streaming.\n\n```\nUsage:\n  $ chatgpt <prompt>\n\nCommands:\n  <prompt>  Ask ChatGPT a question\n  rm-cache  Clears the local message cache\n  ls-cache  Prints the local message cache path\n\nFor more info, run any command with the `--help` flag:\n  $ chatgpt --help\n  $ chatgpt rm-cache --help\n  $ chatgpt ls-cache --help\n\nOptions:\n  -c, --continue          Continue last conversation (default: false)\n  -d, --debug             Enables debug logging (default: false)\n  -s, --stream            Streams the response (default: true)\n  -s, --store             Enables the local message cache (default: true)\n  -t, --timeout           Timeout in milliseconds\n  -k, --apiKey            OpenAI API key\n  -n, --conversationName  Unique name for the conversation\n  -h, --help              Display this message\n  -v, --version           Display version number\n```\n\n## Install\n\n```bash\nnpm install chatgpt\n```\n\nMake sure you're using `node >= 18` so `fetch` is available (or `node >= 14` if you install a [fetch polyfill](https://github.com/developit/unfetch#usage-as-a-polyfill)).\n\n## Usage\n\nTo use this module from Node.js, you need to pick between two methods:\n\n| Method                      | Free?  | Robust?  | Quality?                |\n| --------------------------- | ------ | -------- | ----------------------- |\n| `ChatGPTAPI`                | ❌ No  | ✅ Yes   | ✅️ Real ChatGPT models |\n| `ChatGPTUnofficialProxyAPI` | ✅ Yes | ☑️ Maybe | ✅ Real ChatGPT         |\n\n1. `ChatGPTAPI` - Uses the `gpt-3.5-turbo-0301` model with the official OpenAI chat completions API (official, robust approach, but it's not free). You can override the model, completion params, and system message to fully customize your assistant.\n\n2. `ChatGPTUnofficialProxyAPI` - Uses an unofficial proxy server to access ChatGPT's backend API in a way that circumvents Cloudflare (uses the real ChatGPT and is pretty lightweight, but relies on a third-party server and is rate-limited)\n\nBoth approaches have very similar APIs, so it should be simple to swap between them.\n\n**Note**: We strongly recommend using `ChatGPTAPI` since it uses the officially supported API from OpenAI. We may remove support for `ChatGPTUnofficialProxyAPI` in a future release.\n\n### Usage - ChatGPTAPI\n\nSign up for an [OpenAI API key](https://platform.openai.com/overview) and store it in your environment.\n\n```ts\nimport { ChatGPTAPI } from 'chatgpt'\n\nasync function example() {\n  const api = new ChatGPTAPI({\n    apiKey: process.env.OPENAI_API_KEY\n  })\n\n  const res = await api.sendMessage('Hello World!')\n  console.log(res.text)\n}\n```\n\nYou can override the default `model` (`gpt-3.5-turbo-0301`) and any [OpenAI chat completion params](https://platform.openai.com/docs/api-reference/chat/create) using `completionParams`:\n\n```ts\nconst api = new ChatGPTAPI({\n  apiKey: process.env.OPENAI_API_KEY,\n  completionParams: {\n    temperature: 0.5,\n    top_p: 0.8\n  }\n})\n```\n\nIf you want to track the conversation, you'll need to pass the `parentMessageId` like this:\n\n```ts\nconst api = new ChatGPTAPI({ apiKey: process.env.OPENAI_API_KEY })\n\n// send a message and wait for the response\nlet res = await api.sendMessage('What is OpenAI?')\nconsole.log(res.text)\n\n// send a follow-up\nres = await api.sendMessage('Can you expand on that?', {\n  parentMessageId: res.id\n})\nconsole.log(res.text)\n\n// send another follow-up\nres = await api.sendMessage('What were we talking about?', {\n  parentMessageId: res.id\n})\nconsole.log(res.text)\n```\n\nYou can add streaming via the `onProgress` handler:\n\n```ts\nconst res = await api.sendMessage('Write a 500 word essay on frogs.', {\n  // print the partial response as the AI is \"typing\"\n  onProgress: (partialResponse) => console.log(partialResponse.text)\n})\n\n// print the full text at the end\nconsole.log(res.text)\n```\n\nYou can add a timeout using the `timeoutMs` option:\n\n```ts\n// timeout after 2 minutes (which will also abort the underlying HTTP request)\nconst response = await api.sendMessage(\n  'write me a really really long essay on frogs',\n  {\n    timeoutMs: 2 * 60 * 1000\n  }\n)\n```\n\nIf you want to see more info about what's actually being sent to [OpenAI's chat completions API](https://platform.openai.com/docs/api-reference/chat/create), set the `debug: true` option in the `ChatGPTAPI` constructor:\n\n```ts\nconst api = new ChatGPTAPI({\n  apiKey: process.env.OPENAI_API_KEY,\n  debug: true\n})\n```\n\nWe default to a basic `systemMessage`. You can override this in either the `ChatGPTAPI` constructor or `sendMessage`:\n\n```ts\nconst res = await api.sendMessage('what is the answer to the universe?', {\n  systemMessage: `You are ChatGPT, a large language model trained by OpenAI. You answer as concisely as possible for each responseIf you are generating a list, do not have too many items.\nCurrent date: ${new Date().toISOString()}\\n\\n`\n})\n```\n\nNote that we automatically handle appending the previous messages to the prompt and attempt to optimize for the available tokens (which defaults to `4096`).\n\n<details>\n<summary>Usage in CommonJS (Dynamic import)</summary>\n\n```js\nasync function example() {\n  // To use ESM in CommonJS, you can use a dynamic import\n  const { ChatGPTAPI } = await import('chatgpt')\n\n  const api = new ChatGPTAPI({ apiKey: process.env.OPENAI_API_KEY })\n\n  const res = await api.sendMessage('Hello World!')\n  console.log(res.text)\n}\n```\n\n</details>\n\n### Usage - ChatGPTUnofficialProxyAPI\n\nThe API for `ChatGPTUnofficialProxyAPI` is almost exactly the same. You just need to provide a ChatGPT `accessToken` instead of an OpenAI API key.\n\n```ts\nimport { ChatGPTUnofficialProxyAPI } from 'chatgpt'\n\nasync function example() {\n  const api = new ChatGPTUnofficialProxyAPI({\n    accessToken: process.env.OPENAI_ACCESS_TOKEN\n  })\n\n  const res = await api.sendMessage('Hello World!')\n  console.log(res.text)\n}\n```\n\nSee [demos/demo-reverse-proxy](./demos/demo-reverse-proxy.ts) for a full example:\n\n```bash\nnpx tsx demos/demo-reverse-proxy.ts\n```\n\n`ChatGPTUnofficialProxyAPI` messages also contain a `conversationid` in addition to `parentMessageId`, since the ChatGPT webapp can't reference messages across different accounts & conversations.\n\n#### Reverse Proxy\n\nYou can override the reverse proxy by passing `apiReverseProxyUrl`:\n\n```ts\nconst api = new ChatGPTUnofficialProxyAPI({\n  accessToken: process.env.OPENAI_ACCESS_TOKEN,\n  apiReverseProxyUrl: 'https://your-example-server.com/api/conversation'\n})\n```\n\nKnown reverse proxies run by community members include:\n\n| Reverse Proxy URL                                | Author                                       | Rate Limits       | Last Checked |\n| ------------------------------------------------ | -------------------------------------------- | ----------------- | ------------ |\n| `https://bypass.duti.tech/api/conversation`        | [@acheong08](https://github.com/acheong08)   | 5 req / 10 seconds by IP | 3/11/2023    |\n| `https://gpt.pawan.krd/backend-api/conversation` | [@PawanOsman](https://github.com/PawanOsman) | ?                 | 2/19/2023    |\n\nNote: info on how the reverse proxies work is not being published at this time in order to prevent OpenAI from disabling access.\n\n#### Access Token\n\nTo use `ChatGPTUnofficialProxyAPI`, you'll need an OpenAI access token from the ChatGPT webapp. To do this, you can use any of the following methods which take an `email` and `password` and return an access token:\n\n- Node.js libs\n  - [ericlewis/openai-authenticator](https://github.com/ericlewis/openai-authenticator)\n  - [michael-dm/openai-token](https://github.com/michael-dm/openai-token)\n  - [allanoricil/chat-gpt-authenticator](https://github.com/AllanOricil/chat-gpt-authenticator)\n- Python libs\n  - [acheong08/OpenAIAuth](https://github.com/acheong08/OpenAIAuth)\n\nThese libraries work with email + password accounts (e.g., they do not support accounts where you auth via Microsoft / Google).\n\nAlternatively, you can manually get an `accessToken` by logging in to the ChatGPT webapp and then opening `https://chat.openai.com/api/auth/session`, which will return a JSON object containing your `accessToken` string.\n\nAccess tokens last for days.\n\n**Note**: using a reverse proxy will expose your access token to a third-party. There shouldn't be any adverse effects possible from this, but please consider the risks before using this method.\n\n## Docs\n\nSee the [auto-generated docs](./docs/classes/ChatGPTAPI.md) for more info on methods and parameters.\n\n## Demos\n\nMost of the demos use `ChatGPTAPI`. It should be pretty easy to convert them to use `ChatGPTUnofficialProxyAPI` if you'd rather use that approach. The only thing that needs to change is how you initialize the api with an `accessToken` instead of an `apiKey`.\n\nTo run the included demos:\n\n1. clone repo\n2. install node deps\n3. set `OPENAI_API_KEY` in .env\n\nA [basic demo](./demos/demo.ts) is included for testing purposes:\n\n```bash\nnpx tsx demos/demo.ts\n```\n\nA [demo showing on progress handler](./demos/demo-on-progress.ts):\n\n```bash\nnpx tsx demos/demo-on-progress.ts\n```\n\nThe on progress demo uses the optional `onProgress` parameter to `sendMessage` to receive intermediary results as ChatGPT is \"typing\".\n\nA [conversation demo](./demos/demo-conversation.ts):\n\n```bash\nnpx tsx demos/demo-conversation.ts\n```\n\nA [persistence demo](./demos/demo-persistence.ts) shows how to store messages in Redis for persistence:\n\n```bash\nnpx tsx demos/demo-persistence.ts\n```\n\nAny [keyv adaptor](https://github.com/jaredwray/keyv) is supported for persistence, and there are overrides if you'd like to use a different way of storing / retrieving messages.\n\nNote that persisting message is required for remembering the context of previous conversations beyond the scope of the current Node.js process, since by default, we only store messages in memory. Here's an [external demo](https://github.com/transitive-bullshit/chatgpt-twitter-bot/blob/main/src/index.ts#L86-L95) of using a completely custom database solution to persist messages.\n\n**Note**: Persistence is handled automatically when using `ChatGPTUnofficialProxyAPI` because it is connecting indirectly to ChatGPT.\n\n## Projects\n\nAll of these awesome projects are built using the `chatgpt` package. 🤯\n\n- [Twitter Bot](https://github.com/transitive-bullshit/chatgpt-twitter-bot) powered by ChatGPT ✨\n  - Mention [@ChatGPTBot](https://twitter.com/ChatGPTBot) on Twitter with your prompt to try it out\n- [ChatGPT API Server](https://github.com/waylaidwanderer/node-chatgpt-api) - API server for this package with support for multiple OpenAI accounts, proxies, and load-balancing requests between accounts.\n- [ChatGPT Prompts](https://github.com/pacholoamit/chatgpt-prompts) - A collection of 140+ of the best ChatGPT prompts from the community.\n- [Lovelines.xyz](https://lovelines.xyz?ref=chatgpt-api)\n- [Chrome Extension](https://github.com/gragland/chatgpt-everywhere) ([demo](https://twitter.com/gabe_ragland/status/1599466486422470656))\n- [VSCode Extension #1](https://github.com/mpociot/chatgpt-vscode) ([demo](https://twitter.com/marcelpociot/status/1599180144551526400), [updated version](https://github.com/timkmecl/chatgpt-vscode), [marketplace](https://marketplace.visualstudio.com/items?itemName=timkmecl.chatgpt))\n- [VSCode Extension #2](https://github.com/barnesoir/chatgpt-vscode-plugin) ([marketplace](https://marketplace.visualstudio.com/items?itemName=JayBarnes.chatgpt-vscode-plugin))\n- [VSCode Extension #3](https://github.com/gencay/vscode-chatgpt) ([marketplace](https://marketplace.visualstudio.com/items?itemName=gencay.vscode-chatgpt))\n- [VSCode Extension #4](https://github.com/dogukanakkaya/chatgpt-code-vscode-extension) ([marketplace](https://marketplace.visualstudio.com/items?itemName=dogukanakkaya.chatgpt-code))\n- [Raycast Extension #1](https://github.com/abielzulio/chatgpt-raycast) ([demo](https://twitter.com/abielzulio/status/1600176002042191875))\n- [Raycast Extension #2](https://github.com/domnantas/raycast-chatgpt)\n- [Telegram Bot #1](https://github.com/realies/chatgpt-telegram-bot)\n- [Telegram Bot #2](https://github.com/dawangraoming/chatgpt-telegram-bot)\n- [Telegram Bot #3](https://github.com/RainEggplant/chatgpt-telegram-bot) (group privacy mode, ID-based auth)\n- [Telegram Bot #4](https://github.com/ArdaGnsrn/chatgpt-telegram) (queue system, ID-based chat thread)\n- [Deno Telegram Bot](https://github.com/Ciyou/chatbot-telegram)\n- [Go Telegram Bot](https://github.com/m1guelpf/chatgpt-telegram)\n- [Telegram Bot for YouTube Summaries](https://github.com/codextde/youtube-summary)\n- [GitHub ProBot](https://github.com/oceanlvr/ChatGPTBot)\n- [Discord Bot #1](https://github.com/onury5506/Discord-ChatGPT-Bot)\n- [Discord Bot #2](https://github.com/Nageld/ChatGPT-Bot)\n- [Discord Bot #3](https://github.com/leinstay/gptbot)\n- [Discord Bot #4 (selfbot)](https://github.com/0x7030676e31/cumsocket)\n- [Discord Bot #5](https://github.com/itskdhere/ChatGPT-Discord-BOT)\n- [Discord Bot #6 (Shakespeare bot)](https://gist.github.com/TheBrokenRail/4b37e7c44e8f721d8bd845050d034c16)\n- [WeChat Bot #1](https://github.com/AutumnWhj/ChatGPT-wechat-bot)\n- [WeChat Bot #2](https://github.com/fuergaosi233/wechat-chatgpt)\n- [WeChat Bot #3](https://github.com/wangrongding/wechat-bot) (\n- [WeChat Bot #4](https://github.com/darknightlab/wechat-bot)\n- [WeChat Bot #5](https://github.com/sunshanpeng/wechaty-chatgpt)\n- [QQ Bot (plugin for Yunzai-bot)](https://github.com/ikechan8370/chatgpt-plugin)\n- [QQ Bot (plugin for KiviBot)](https://github.com/KiviBotLab/kivibot-plugin-chatgpt)\n- [QQ Bot (oicq)](https://github.com/easydu2002/chat_gpt_oicq)\n- [QQ Bot (oicq + RabbitMQ)](https://github.com/linsyking/ChatGPT-QQBot)\n- [QQ Bot (go-cqhttp)](https://github.com/PairZhu/ChatGPT-QQRobot)\n- [EXM smart contracts](https://github.com/decentldotland/molecule)\n- [Flutter ChatGPT API](https://github.com/coskuncay/flutter_chatgpt_api)\n- [Carik Bot](https://github.com/luridarmawan/Carik)\n- [Github Action for reviewing PRs](https://github.com/kxxt/chatgpt-action/)\n- [WhatsApp Bot #1](https://github.com/askrella/whatsapp-chatgpt) (DALL-E + Whisper support 💪)\n- [WhatsApp Bot #2](https://github.com/amosayomide05/chatgpt-whatsapp-bot)\n- [WhatsApp Bot #3](https://github.com/pascalroget/whatsgpt) (multi-user support)\n- [WhatsApp Bot #4](https://github.com/noelzappy/chatgpt-whatsapp) (schedule periodic messages)\n- [WhatsApp Bot #5](https://github.com/hujanais/bs-chat-gpt3-api) (RaspberryPi + ngrok + Twilio)\n- [WhatsApp Bot #6](https://github.com/dannysantino/whatsgpt) (Session and chat history storage with MongoStore)\n- [Matrix Bot](https://github.com/matrixgpt/matrix-chatgpt-bot)\n- [Rental Cover Letter Generator](https://sharehouse.app/ai)\n- [Assistant CLI](https://github.com/diciaup/assistant-cli)\n- [Teams Bot](https://github.com/formulahendry/chatgpt-teams-bot)\n- [Askai](https://github.com/yudax42/askai)\n- [TalkGPT](https://github.com/ShadovvBeast/TalkGPT)\n- [ChatGPT With Voice](https://github.com/thanhsonng/chatgpt-voice)\n- [iOS Shortcut](https://github.com/leecobaby/shortcuts/blob/master/other/ChatGPT_EN.md)\n- [Slack Bot #1](https://github.com/trietphm/chatgpt-slackbot/)\n- [Slack Bot #2](https://github.com/lokwkin/chatgpt-slackbot-node/) (with queueing mechanism)\n- [Slack Bot #3](https://github.com/NessunKim/slack-chatgpt/)\n- [Slack Bot #4](https://github.com/MarkusGalant/chatgpt-slackbot-serverless/) ( Serverless AWS Lambda )\n- [Electron Bot](https://github.com/ShiranAbir/chaty)\n- [Kodyfire CLI](https://github.com/nooqta/chatgpt-kodyfire)\n- [Twitch Bot](https://github.com/BennyDeeDev/chatgpt-twitch-bot)\n- [Continuous Conversation](https://github.com/DanielTerletzkiy/chat-gtp-assistant)\n- [Figma plugin](https://github.com/frederickk/chatgpt-figma-plugin)\n- [NestJS server](https://github.com/RusDyn/chatgpt_nestjs_server)\n- [NestJS ChatGPT Starter Boilerplate](https://github.com/mitkodkn/nestjs-chatgpt-starter)\n- [Wordsmith: Add-in for Microsoft Word](https://github.com/xtremehpx/Wordsmith)\n- [QuizGPT: Create Kahoot quizzes with ChatGPT](https://github.com/Kladdy/quizgpt)\n- [openai-chatgpt: Talk to ChatGPT from the terminal](https://github.com/gmpetrov/openai-chatgpt)\n- [Clippy the Saleforce chatbot](https://github.com/sebas00/chatgptclippy) ClippyJS joke bot\n- [ai-assistant](https://github.com/youking-lib/ai-assistant) Chat assistant\n- [Feishu Bot](https://github.com/linjungz/feishu-chatgpt-bot)\n- [DomainGPT: Discover available domain names](https://github.com/billylo1/DomainGPT)\n- [AI Poem Generator](https://aipoemgenerator.com/)\n- [Next.js ChatGPT With Firebase](https://github.com/youngle316/chatgpt)\n- [ai-commit – GPT-3 Commit Message Generator](https://github.com/insulineru/ai-commit)\n- [AItinerary – ChatGPT itinerary Generator](https://aitinerary.ai)\n\nIf you create a cool integration, feel free to open a PR and add it to the list.\n\n## Compatibility\n\n- This package is ESM-only.\n- This package supports `node >= 14`.\n- This module assumes that `fetch` is installed.\n  - In `node >= 18`, it's installed by default.\n  - In `node < 18`, you need to install a polyfill like `unfetch/polyfill` ([guide](https://github.com/developit/unfetch#usage-as-a-polyfill)) or `isomorphic-fetch` ([guide](https://github.com/matthew-andrews/isomorphic-fetch#readme)).\n- If you want to build a website using `chatgpt`, we recommend using it only from your backend API\n\n## Credits\n\n- Huge thanks to [@waylaidwanderer](https://github.com/waylaidwanderer), [@abacaj](https://github.com/abacaj), [@wong2](https://github.com/wong2), [@simon300000](https://github.com/simon300000), [@RomanHotsiy](https://github.com/RomanHotsiy), [@ElijahPepe](https://github.com/ElijahPepe), and all the other contributors 💪\n- The original browser version was inspired by this [Go module](https://github.com/danielgross/whatsapp-gpt) by [Daniel Gross](https://github.com/danielgross)\n- [OpenAI](https://openai.com) for creating [ChatGPT](https://openai.com/blog/chatgpt/) 🔥\n\n## License\n\nMIT © [Travis Fischer](https://transitivebullsh.it)\n\nIf you found this project interesting, please consider [sponsoring me](https://github.com/sponsors/transitive-bullshit) or <a href=\"https://twitter.com/transitive_bs\">following me on twitter <img src=\"https://storage.googleapis.com/saasify-assets/twitter-logo.svg\" alt=\"twitter\" height=\"24px\" align=\"center\"></a>\n","readmeFilename":"readme.md","gitHead":"33a5edee1f5ea29934c2e9dd6d8db43c873a258e","bugs":{"url":"https://github.com/transitive-bullshit/chatgpt-api/issues"},"homepage":"https://github.com/transitive-bullshit/chatgpt-api#readme","_id":"@catalystclan/chatgpt@5.0.10-beta.1","_nodeVersion":"19.8.1","_npmVersion":"9.5.1","dist":{"integrity":"sha512-ReemT+vTU+mf7wV2WWTPfB1pqlHsANkLgitC7/rWX0TH++MF9fjE3/O1DQfcpAsOQ5VcAZuflrnoOmsDpVmcYA==","shasum":"81d7f5d3267c160015488b9499e422ba957691e7","tarball":"https://registry.npmjs.org/@catalystclan/chatgpt/-/chatgpt-5.0.10-beta.1.tgz","fileCount":9,"unpackedSize":190245,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQClnCYTu7Okd3On1R5P7WLcvVEQCZEuIY0cRg9gt/d0JgIhAObjoPYuJJtek8lVYbDAuA0o3l/3LBZRkahOlkIRNsej"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkG+ZSACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmosZg//QtrSsewG3U/q/FHjjUva0gXPoHWGeEsxXg+Od2ZPJPeLXcnK\r\nlAlVUpQ2w+C44LgECJS66IdZN86vLIni6SLTjz3Drj2/LLu2mDx0CeNOkSo0\r\nkGgLrqz7hsl7lAs1ycyWYObPqqIqtFelBOwuMlabnfmaxU4M7a1i7yGTFkev\r\nrRDt+HToPm5qD6njd4BEz1e9XUSZ0b+el4J3AVhRbrT9YaY8FFjhjbIlZ71q\r\nHhmcHi5pTYVw/139eoVJFLtD5iAfVusFCz/cmjbh8USOulWfi/B+kfmaxRs2\r\nAybOAltogHrIIdqGoG2Rb2OPX6WpP0ijqlPGgtPzXPLryV7Hcq9uRqRNcM3u\r\nsXgKVSzRWcxN8pM60MTk+44O7V2Mjd/aLJrvqLQc2/IhEyjf/w+OKQ+YTT7K\r\nwUJQvFg1M+31y5D2GRG/vTrt7QKJ3PyiHM+M4EMU4z6wR39tXIIxRN7OHCgw\r\nYcNDz9VUkjnkzxhvkPq1VLY4gbT9NX2v6XI9bIgorxAwbdzo9C9nIrR/hynW\r\nH4bRQUUKPOOQxPkzhlFf5Iz4X8zEWtGU5NG/JJ6RQKdJT0tXS7e2MuCGmJ9h\r\n2n0+BOviKofbBAQCmO71vaNOmigiO1AptREgOA9GOuyJojOI+XL6OWSQvUQO\r\nWMgFctDymZE8GMiY8XY9ATf4bLXWEZhGp4s=\r\n=oM7F\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"jakelaoyu","email":"jake.laoyu@gmail.com"},"directories":{},"maintainers":[{"name":"jakelaoyu","email":"jake.laoyu@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chatgpt_5.0.10-beta.1_1679550034276_0.4821458968600487"},"_hasShrinkwrap":false},"5.0.10-beta.2":{"name":"@catalystclan/chatgpt","version":"5.0.10-beta.2","description":"Node.js client for the official ChatGPT API.","author":{"name":"Travis Fischer","email":"travis@transitivebullsh.it"},"repository":{"type":"git","url":"git+https://github.com/transitive-bullshit/chatgpt-api.git"},"license":"MIT","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"source":"./src/index.ts","types":"./build/index.d.ts","exports":{".":{"import":"./build/index.mjs","types":"./build/index.d.ts","require":"./build/index.js","default":"./build/index.mjs"}},"bin":{"chatgpt":"bin/cli.js"},"engines":{"node":">=14"},"scripts":{"build":"tsup","dev":"tsup --watch","clean":"del build","prebuild":"run-s clean","predev":"run-s clean","pretest":"run-s build","docs":"typedoc","prepare":"husky install","pre-commit":"lint-staged","test":"run-p test:*","test:prettier":"prettier '**/*.{js,jsx,ts,tsx}' --check"},"dependencies":{"@dqbd/tiktoken":"^0.4.0","cac":"^6.7.14","conf":"^11.0.1","eventsource-parser":"^0.0.5","keyv":"^4.5.2","p-timeout":"npm:@esm2cjs/p-timeout@^6.0.0","quick-lru":"^5.1.1","read-pkg-up":"^7.0.1","uuid":"^9.0.0"},"devDependencies":{"@keyv/redis":"^2.5.6","@trivago/prettier-plugin-sort-imports":"^4.1.1","@types/node":"^18.15.0","@types/uuid":"^9.0.1","del-cli":"^5.0.0","dotenv-safe":"^8.2.0","husky":"^8.0.2","lint-staged":"^13.2.0","npm-run-all":"^4.1.5","ora":"^6.1.2","prettier":"^2.8.4","tsup":"^6.6.3","tsx":"^3.12.3","typedoc":"^0.23.26","typedoc-plugin-markdown":"^3.13.6","typescript":"^4.9.3"},"lint-staged":{"*.{ts,tsx}":["prettier --write"]},"keywords":["openai","chatgpt","chat","gpt","gpt-3","gpt3","gpt4","chatbot","machine learning","conversation","conversational ai","ai","ml","bot"],"readme":"# ChatGPT API <!-- omit in toc -->\n\n> Node.js client for the official [ChatGPT](https://openai.com/blog/chatgpt/) API.\n\n[![NPM](https://img.shields.io/npm/v/chatgpt.svg)](https://www.npmjs.com/package/chatgpt) [![Build Status](https://github.com/transitive-bullshit/chatgpt-api/actions/workflows/test.yml/badge.svg)](https://github.com/transitive-bullshit/chatgpt-api/actions/workflows/test.yml) [![MIT License](https://img.shields.io/badge/license-MIT-blue)](https://github.com/transitive-bullshit/chatgpt-api/blob/main/license) [![Prettier Code Formatting](https://img.shields.io/badge/code_style-prettier-brightgreen.svg)](https://prettier.io)\n\n- [Intro](#intro)\n- [Updates](#updates)\n- [CLI](#cli)\n- [Install](#install)\n- [Usage](#usage)\n  - [Usage - ChatGPTAPI](#usage---chatgptapi)\n  - [Usage - ChatGPTUnofficialProxyAPI](#usage---chatgptunofficialproxyapi)\n    - [Reverse Proxy](#reverse-proxy)\n    - [Access Token](#access-token)\n- [Docs](#docs)\n- [Demos](#demos)\n- [Projects](#projects)\n- [Compatibility](#compatibility)\n- [Credits](#credits)\n- [License](#license)\n\n## Intro\n\nThis package is a Node.js wrapper around [ChatGPT](https://openai.com/blog/chatgpt) by [OpenAI](https://openai.com). TS batteries included. ✨\n\n<p align=\"center\">\n  <img alt=\"Example usage\" src=\"/media/demo.gif\">\n</p>\n\n## Updates\n\n<details open>\n<summary><strong>March 1, 2023</strong></summary>\n\n<br/>\n\nThe [official OpenAI chat completions API](https://platform.openai.com/docs/guides/chat) has been released, and it is now the default for this package! 🔥\n\n| Method                      | Free?  | Robust?  | Quality?                |\n| --------------------------- | ------ | -------- | ----------------------- |\n| `ChatGPTAPI`                | ❌ No  | ✅ Yes   | ✅️ Real ChatGPT models |\n| `ChatGPTUnofficialProxyAPI` | ✅ Yes | ☑️ Maybe | ✅ Real ChatGPT         |\n\n**Note**: We strongly recommend using `ChatGPTAPI` since it uses the officially supported API from OpenAI. We may remove support for `ChatGPTUnofficialProxyAPI` in a future release.\n\n1. `ChatGPTAPI` - Uses the `gpt-3.5-turbo-0301` model with the official OpenAI chat completions API (official, robust approach, but it's not free)\n2. `ChatGPTUnofficialProxyAPI` - Uses an unofficial proxy server to access ChatGPT's backend API in a way that circumvents Cloudflare (uses the real ChatGPT and is pretty lightweight, but relies on a third-party server and is rate-limited)\n\n</details>\n\n<details>\n<summary><strong>Previous Updates</strong></summary>\n\n<br/>\n\n<details>\n<summary><strong>Feb 19, 2023</strong></summary>\n\n<br/>\n\nWe now provide three ways of accessing the unofficial ChatGPT API, all of which have tradeoffs:\n\n| Method                      | Free?  | Robust?  | Quality?          |\n| --------------------------- | ------ | -------- | ----------------- |\n| `ChatGPTAPI`                | ❌ No  | ✅ Yes   | ☑️ Mimics ChatGPT |\n| `ChatGPTUnofficialProxyAPI` | ✅ Yes | ☑️ Maybe | ✅ Real ChatGPT   |\n| `ChatGPTAPIBrowser` (v3)    | ✅ Yes | ❌ No    | ✅ Real ChatGPT   |\n\n**Note**: I recommend that you use either `ChatGPTAPI` or `ChatGPTUnofficialProxyAPI`.\n\n1. `ChatGPTAPI` - (Used to use) `text-davinci-003` to mimic ChatGPT via the official OpenAI completions API (most robust approach, but it's not free and doesn't use a model fine-tuned for chat)\n2. `ChatGPTUnofficialProxyAPI` - Uses an unofficial proxy server to access ChatGPT's backend API in a way that circumvents Cloudflare (uses the real ChatGPT and is pretty lightweight, but relies on a third-party server and is rate-limited)\n3. `ChatGPTAPIBrowser` - (_deprecated_; v3.5.1 of this package) Uses Puppeteer to access the official ChatGPT webapp (uses the real ChatGPT, but very flaky, heavyweight, and error prone)\n\n</details>\n\n<details>\n<summary><strong>Feb 5, 2023</strong></summary>\n\n<br/>\n\nOpenAI has disabled the leaked chat model we were previously using, so we're now defaulting to `text-davinci-003`, which is not free.\n\nWe've found several other hidden, fine-tuned chat models, but OpenAI keeps disabling them, so we're searching for alternative workarounds.\n\n</details>\n\n<details>\n<summary><strong>Feb 1, 2023</strong></summary>\n\n<br/>\n\nThis package no longer requires any browser hacks – **it is now using the official OpenAI completions API** with a leaked model that ChatGPT uses under the hood. 🔥\n\n```ts\nimport { ChatGPTAPI } from 'chatgpt'\n\nconst api = new ChatGPTAPI({\n  apiKey: process.env.OPENAI_API_KEY\n})\n\nconst res = await api.sendMessage('Hello World!')\nconsole.log(res.text)\n```\n\nPlease upgrade to `chatgpt@latest` (at least [v4.0.0](https://github.com/transitive-bullshit/chatgpt-api/releases/tag/v4.0.0)). The updated version is **significantly more lightweight and robust** compared with previous versions. You also don't have to worry about IP issues or rate limiting.\n\nHuge shoutout to [@waylaidwanderer](https://github.com/waylaidwanderer) for discovering the leaked chat model!\n\n</details>\n</details>\n\nIf you run into any issues, we do have a pretty active [Discord](https://discord.gg/v9gERj825w) with a bunch of ChatGPT hackers from the Node.js & Python communities.\n\nLastly, please consider starring this repo and <a href=\"https://twitter.com/transitive_bs\">following me on twitter <img src=\"https://storage.googleapis.com/saasify-assets/twitter-logo.svg\" alt=\"twitter\" height=\"24px\" align=\"center\"></a> to help support the project.\n\nThanks && cheers,\n[Travis](https://twitter.com/transitive_bs)\n\n## CLI\n\nTo run the CLI, you'll need an [OpenAI API key](https://platform.openai.com/overview):\n\n```bash\nexport OPENAI_API_KEY=\"sk-TODO\"\nnpx chatgpt \"your prompt here\"\n```\n\nBy default, the response is streamed to stdout, the results are stored in a local config file, and every invocation starts a new conversation. You can use `-c` to continue the previous conversation and `--no-stream` to disable streaming.\n\n```\nUsage:\n  $ chatgpt <prompt>\n\nCommands:\n  <prompt>  Ask ChatGPT a question\n  rm-cache  Clears the local message cache\n  ls-cache  Prints the local message cache path\n\nFor more info, run any command with the `--help` flag:\n  $ chatgpt --help\n  $ chatgpt rm-cache --help\n  $ chatgpt ls-cache --help\n\nOptions:\n  -c, --continue          Continue last conversation (default: false)\n  -d, --debug             Enables debug logging (default: false)\n  -s, --stream            Streams the response (default: true)\n  -s, --store             Enables the local message cache (default: true)\n  -t, --timeout           Timeout in milliseconds\n  -k, --apiKey            OpenAI API key\n  -n, --conversationName  Unique name for the conversation\n  -h, --help              Display this message\n  -v, --version           Display version number\n```\n\n## Install\n\n```bash\nnpm install chatgpt\n```\n\nMake sure you're using `node >= 18` so `fetch` is available (or `node >= 14` if you install a [fetch polyfill](https://github.com/developit/unfetch#usage-as-a-polyfill)).\n\n## Usage\n\nTo use this module from Node.js, you need to pick between two methods:\n\n| Method                      | Free?  | Robust?  | Quality?                |\n| --------------------------- | ------ | -------- | ----------------------- |\n| `ChatGPTAPI`                | ❌ No  | ✅ Yes   | ✅️ Real ChatGPT models |\n| `ChatGPTUnofficialProxyAPI` | ✅ Yes | ☑️ Maybe | ✅ Real ChatGPT         |\n\n1. `ChatGPTAPI` - Uses the `gpt-3.5-turbo-0301` model with the official OpenAI chat completions API (official, robust approach, but it's not free). You can override the model, completion params, and system message to fully customize your assistant.\n\n2. `ChatGPTUnofficialProxyAPI` - Uses an unofficial proxy server to access ChatGPT's backend API in a way that circumvents Cloudflare (uses the real ChatGPT and is pretty lightweight, but relies on a third-party server and is rate-limited)\n\nBoth approaches have very similar APIs, so it should be simple to swap between them.\n\n**Note**: We strongly recommend using `ChatGPTAPI` since it uses the officially supported API from OpenAI. We may remove support for `ChatGPTUnofficialProxyAPI` in a future release.\n\n### Usage - ChatGPTAPI\n\nSign up for an [OpenAI API key](https://platform.openai.com/overview) and store it in your environment.\n\n```ts\nimport { ChatGPTAPI } from 'chatgpt'\n\nasync function example() {\n  const api = new ChatGPTAPI({\n    apiKey: process.env.OPENAI_API_KEY\n  })\n\n  const res = await api.sendMessage('Hello World!')\n  console.log(res.text)\n}\n```\n\nYou can override the default `model` (`gpt-3.5-turbo-0301`) and any [OpenAI chat completion params](https://platform.openai.com/docs/api-reference/chat/create) using `completionParams`:\n\n```ts\nconst api = new ChatGPTAPI({\n  apiKey: process.env.OPENAI_API_KEY,\n  completionParams: {\n    temperature: 0.5,\n    top_p: 0.8\n  }\n})\n```\n\nIf you want to track the conversation, you'll need to pass the `parentMessageId` like this:\n\n```ts\nconst api = new ChatGPTAPI({ apiKey: process.env.OPENAI_API_KEY })\n\n// send a message and wait for the response\nlet res = await api.sendMessage('What is OpenAI?')\nconsole.log(res.text)\n\n// send a follow-up\nres = await api.sendMessage('Can you expand on that?', {\n  parentMessageId: res.id\n})\nconsole.log(res.text)\n\n// send another follow-up\nres = await api.sendMessage('What were we talking about?', {\n  parentMessageId: res.id\n})\nconsole.log(res.text)\n```\n\nYou can add streaming via the `onProgress` handler:\n\n```ts\nconst res = await api.sendMessage('Write a 500 word essay on frogs.', {\n  // print the partial response as the AI is \"typing\"\n  onProgress: (partialResponse) => console.log(partialResponse.text)\n})\n\n// print the full text at the end\nconsole.log(res.text)\n```\n\nYou can add a timeout using the `timeoutMs` option:\n\n```ts\n// timeout after 2 minutes (which will also abort the underlying HTTP request)\nconst response = await api.sendMessage(\n  'write me a really really long essay on frogs',\n  {\n    timeoutMs: 2 * 60 * 1000\n  }\n)\n```\n\nIf you want to see more info about what's actually being sent to [OpenAI's chat completions API](https://platform.openai.com/docs/api-reference/chat/create), set the `debug: true` option in the `ChatGPTAPI` constructor:\n\n```ts\nconst api = new ChatGPTAPI({\n  apiKey: process.env.OPENAI_API_KEY,\n  debug: true\n})\n```\n\nWe default to a basic `systemMessage`. You can override this in either the `ChatGPTAPI` constructor or `sendMessage`:\n\n```ts\nconst res = await api.sendMessage('what is the answer to the universe?', {\n  systemMessage: `You are ChatGPT, a large language model trained by OpenAI. You answer as concisely as possible for each responseIf you are generating a list, do not have too many items.\nCurrent date: ${new Date().toISOString()}\\n\\n`\n})\n```\n\nNote that we automatically handle appending the previous messages to the prompt and attempt to optimize for the available tokens (which defaults to `4096`).\n\n<details>\n<summary>Usage in CommonJS (Dynamic import)</summary>\n\n```js\nasync function example() {\n  // To use ESM in CommonJS, you can use a dynamic import\n  const { ChatGPTAPI } = await import('chatgpt')\n\n  const api = new ChatGPTAPI({ apiKey: process.env.OPENAI_API_KEY })\n\n  const res = await api.sendMessage('Hello World!')\n  console.log(res.text)\n}\n```\n\n</details>\n\n### Usage - ChatGPTUnofficialProxyAPI\n\nThe API for `ChatGPTUnofficialProxyAPI` is almost exactly the same. You just need to provide a ChatGPT `accessToken` instead of an OpenAI API key.\n\n```ts\nimport { ChatGPTUnofficialProxyAPI } from 'chatgpt'\n\nasync function example() {\n  const api = new ChatGPTUnofficialProxyAPI({\n    accessToken: process.env.OPENAI_ACCESS_TOKEN\n  })\n\n  const res = await api.sendMessage('Hello World!')\n  console.log(res.text)\n}\n```\n\nSee [demos/demo-reverse-proxy](./demos/demo-reverse-proxy.ts) for a full example:\n\n```bash\nnpx tsx demos/demo-reverse-proxy.ts\n```\n\n`ChatGPTUnofficialProxyAPI` messages also contain a `conversationid` in addition to `parentMessageId`, since the ChatGPT webapp can't reference messages across different accounts & conversations.\n\n#### Reverse Proxy\n\nYou can override the reverse proxy by passing `apiReverseProxyUrl`:\n\n```ts\nconst api = new ChatGPTUnofficialProxyAPI({\n  accessToken: process.env.OPENAI_ACCESS_TOKEN,\n  apiReverseProxyUrl: 'https://your-example-server.com/api/conversation'\n})\n```\n\nKnown reverse proxies run by community members include:\n\n| Reverse Proxy URL                                | Author                                       | Rate Limits       | Last Checked |\n| ------------------------------------------------ | -------------------------------------------- | ----------------- | ------------ |\n| `https://bypass.duti.tech/api/conversation`        | [@acheong08](https://github.com/acheong08)   | 5 req / 10 seconds by IP | 3/11/2023    |\n| `https://gpt.pawan.krd/backend-api/conversation` | [@PawanOsman](https://github.com/PawanOsman) | ?                 | 2/19/2023    |\n\nNote: info on how the reverse proxies work is not being published at this time in order to prevent OpenAI from disabling access.\n\n#### Access Token\n\nTo use `ChatGPTUnofficialProxyAPI`, you'll need an OpenAI access token from the ChatGPT webapp. To do this, you can use any of the following methods which take an `email` and `password` and return an access token:\n\n- Node.js libs\n  - [ericlewis/openai-authenticator](https://github.com/ericlewis/openai-authenticator)\n  - [michael-dm/openai-token](https://github.com/michael-dm/openai-token)\n  - [allanoricil/chat-gpt-authenticator](https://github.com/AllanOricil/chat-gpt-authenticator)\n- Python libs\n  - [acheong08/OpenAIAuth](https://github.com/acheong08/OpenAIAuth)\n\nThese libraries work with email + password accounts (e.g., they do not support accounts where you auth via Microsoft / Google).\n\nAlternatively, you can manually get an `accessToken` by logging in to the ChatGPT webapp and then opening `https://chat.openai.com/api/auth/session`, which will return a JSON object containing your `accessToken` string.\n\nAccess tokens last for days.\n\n**Note**: using a reverse proxy will expose your access token to a third-party. There shouldn't be any adverse effects possible from this, but please consider the risks before using this method.\n\n## Docs\n\nSee the [auto-generated docs](./docs/classes/ChatGPTAPI.md) for more info on methods and parameters.\n\n## Demos\n\nMost of the demos use `ChatGPTAPI`. It should be pretty easy to convert them to use `ChatGPTUnofficialProxyAPI` if you'd rather use that approach. The only thing that needs to change is how you initialize the api with an `accessToken` instead of an `apiKey`.\n\nTo run the included demos:\n\n1. clone repo\n2. install node deps\n3. set `OPENAI_API_KEY` in .env\n\nA [basic demo](./demos/demo.ts) is included for testing purposes:\n\n```bash\nnpx tsx demos/demo.ts\n```\n\nA [demo showing on progress handler](./demos/demo-on-progress.ts):\n\n```bash\nnpx tsx demos/demo-on-progress.ts\n```\n\nThe on progress demo uses the optional `onProgress` parameter to `sendMessage` to receive intermediary results as ChatGPT is \"typing\".\n\nA [conversation demo](./demos/demo-conversation.ts):\n\n```bash\nnpx tsx demos/demo-conversation.ts\n```\n\nA [persistence demo](./demos/demo-persistence.ts) shows how to store messages in Redis for persistence:\n\n```bash\nnpx tsx demos/demo-persistence.ts\n```\n\nAny [keyv adaptor](https://github.com/jaredwray/keyv) is supported for persistence, and there are overrides if you'd like to use a different way of storing / retrieving messages.\n\nNote that persisting message is required for remembering the context of previous conversations beyond the scope of the current Node.js process, since by default, we only store messages in memory. Here's an [external demo](https://github.com/transitive-bullshit/chatgpt-twitter-bot/blob/main/src/index.ts#L86-L95) of using a completely custom database solution to persist messages.\n\n**Note**: Persistence is handled automatically when using `ChatGPTUnofficialProxyAPI` because it is connecting indirectly to ChatGPT.\n\n## Projects\n\nAll of these awesome projects are built using the `chatgpt` package. 🤯\n\n- [Twitter Bot](https://github.com/transitive-bullshit/chatgpt-twitter-bot) powered by ChatGPT ✨\n  - Mention [@ChatGPTBot](https://twitter.com/ChatGPTBot) on Twitter with your prompt to try it out\n- [ChatGPT API Server](https://github.com/waylaidwanderer/node-chatgpt-api) - API server for this package with support for multiple OpenAI accounts, proxies, and load-balancing requests between accounts.\n- [ChatGPT Prompts](https://github.com/pacholoamit/chatgpt-prompts) - A collection of 140+ of the best ChatGPT prompts from the community.\n- [Lovelines.xyz](https://lovelines.xyz?ref=chatgpt-api)\n- [Chrome Extension](https://github.com/gragland/chatgpt-everywhere) ([demo](https://twitter.com/gabe_ragland/status/1599466486422470656))\n- [VSCode Extension #1](https://github.com/mpociot/chatgpt-vscode) ([demo](https://twitter.com/marcelpociot/status/1599180144551526400), [updated version](https://github.com/timkmecl/chatgpt-vscode), [marketplace](https://marketplace.visualstudio.com/items?itemName=timkmecl.chatgpt))\n- [VSCode Extension #2](https://github.com/barnesoir/chatgpt-vscode-plugin) ([marketplace](https://marketplace.visualstudio.com/items?itemName=JayBarnes.chatgpt-vscode-plugin))\n- [VSCode Extension #3](https://github.com/gencay/vscode-chatgpt) ([marketplace](https://marketplace.visualstudio.com/items?itemName=gencay.vscode-chatgpt))\n- [VSCode Extension #4](https://github.com/dogukanakkaya/chatgpt-code-vscode-extension) ([marketplace](https://marketplace.visualstudio.com/items?itemName=dogukanakkaya.chatgpt-code))\n- [Raycast Extension #1](https://github.com/abielzulio/chatgpt-raycast) ([demo](https://twitter.com/abielzulio/status/1600176002042191875))\n- [Raycast Extension #2](https://github.com/domnantas/raycast-chatgpt)\n- [Telegram Bot #1](https://github.com/realies/chatgpt-telegram-bot)\n- [Telegram Bot #2](https://github.com/dawangraoming/chatgpt-telegram-bot)\n- [Telegram Bot #3](https://github.com/RainEggplant/chatgpt-telegram-bot) (group privacy mode, ID-based auth)\n- [Telegram Bot #4](https://github.com/ArdaGnsrn/chatgpt-telegram) (queue system, ID-based chat thread)\n- [Deno Telegram Bot](https://github.com/Ciyou/chatbot-telegram)\n- [Go Telegram Bot](https://github.com/m1guelpf/chatgpt-telegram)\n- [Telegram Bot for YouTube Summaries](https://github.com/codextde/youtube-summary)\n- [GitHub ProBot](https://github.com/oceanlvr/ChatGPTBot)\n- [Discord Bot #1](https://github.com/onury5506/Discord-ChatGPT-Bot)\n- [Discord Bot #2](https://github.com/Nageld/ChatGPT-Bot)\n- [Discord Bot #3](https://github.com/leinstay/gptbot)\n- [Discord Bot #4 (selfbot)](https://github.com/0x7030676e31/cumsocket)\n- [Discord Bot #5](https://github.com/itskdhere/ChatGPT-Discord-BOT)\n- [Discord Bot #6 (Shakespeare bot)](https://gist.github.com/TheBrokenRail/4b37e7c44e8f721d8bd845050d034c16)\n- [WeChat Bot #1](https://github.com/AutumnWhj/ChatGPT-wechat-bot)\n- [WeChat Bot #2](https://github.com/fuergaosi233/wechat-chatgpt)\n- [WeChat Bot #3](https://github.com/wangrongding/wechat-bot) (\n- [WeChat Bot #4](https://github.com/darknightlab/wechat-bot)\n- [WeChat Bot #5](https://github.com/sunshanpeng/wechaty-chatgpt)\n- [QQ Bot (plugin for Yunzai-bot)](https://github.com/ikechan8370/chatgpt-plugin)\n- [QQ Bot (plugin for KiviBot)](https://github.com/KiviBotLab/kivibot-plugin-chatgpt)\n- [QQ Bot (oicq)](https://github.com/easydu2002/chat_gpt_oicq)\n- [QQ Bot (oicq + RabbitMQ)](https://github.com/linsyking/ChatGPT-QQBot)\n- [QQ Bot (go-cqhttp)](https://github.com/PairZhu/ChatGPT-QQRobot)\n- [EXM smart contracts](https://github.com/decentldotland/molecule)\n- [Flutter ChatGPT API](https://github.com/coskuncay/flutter_chatgpt_api)\n- [Carik Bot](https://github.com/luridarmawan/Carik)\n- [Github Action for reviewing PRs](https://github.com/kxxt/chatgpt-action/)\n- [WhatsApp Bot #1](https://github.com/askrella/whatsapp-chatgpt) (DALL-E + Whisper support 💪)\n- [WhatsApp Bot #2](https://github.com/amosayomide05/chatgpt-whatsapp-bot)\n- [WhatsApp Bot #3](https://github.com/pascalroget/whatsgpt) (multi-user support)\n- [WhatsApp Bot #4](https://github.com/noelzappy/chatgpt-whatsapp) (schedule periodic messages)\n- [WhatsApp Bot #5](https://github.com/hujanais/bs-chat-gpt3-api) (RaspberryPi + ngrok + Twilio)\n- [WhatsApp Bot #6](https://github.com/dannysantino/whatsgpt) (Session and chat history storage with MongoStore)\n- [Matrix Bot](https://github.com/matrixgpt/matrix-chatgpt-bot)\n- [Rental Cover Letter Generator](https://sharehouse.app/ai)\n- [Assistant CLI](https://github.com/diciaup/assistant-cli)\n- [Teams Bot](https://github.com/formulahendry/chatgpt-teams-bot)\n- [Askai](https://github.com/yudax42/askai)\n- [TalkGPT](https://github.com/ShadovvBeast/TalkGPT)\n- [ChatGPT With Voice](https://github.com/thanhsonng/chatgpt-voice)\n- [iOS Shortcut](https://github.com/leecobaby/shortcuts/blob/master/other/ChatGPT_EN.md)\n- [Slack Bot #1](https://github.com/trietphm/chatgpt-slackbot/)\n- [Slack Bot #2](https://github.com/lokwkin/chatgpt-slackbot-node/) (with queueing mechanism)\n- [Slack Bot #3](https://github.com/NessunKim/slack-chatgpt/)\n- [Slack Bot #4](https://github.com/MarkusGalant/chatgpt-slackbot-serverless/) ( Serverless AWS Lambda )\n- [Electron Bot](https://github.com/ShiranAbir/chaty)\n- [Kodyfire CLI](https://github.com/nooqta/chatgpt-kodyfire)\n- [Twitch Bot](https://github.com/BennyDeeDev/chatgpt-twitch-bot)\n- [Continuous Conversation](https://github.com/DanielTerletzkiy/chat-gtp-assistant)\n- [Figma plugin](https://github.com/frederickk/chatgpt-figma-plugin)\n- [NestJS server](https://github.com/RusDyn/chatgpt_nestjs_server)\n- [NestJS ChatGPT Starter Boilerplate](https://github.com/mitkodkn/nestjs-chatgpt-starter)\n- [Wordsmith: Add-in for Microsoft Word](https://github.com/xtremehpx/Wordsmith)\n- [QuizGPT: Create Kahoot quizzes with ChatGPT](https://github.com/Kladdy/quizgpt)\n- [openai-chatgpt: Talk to ChatGPT from the terminal](https://github.com/gmpetrov/openai-chatgpt)\n- [Clippy the Saleforce chatbot](https://github.com/sebas00/chatgptclippy) ClippyJS joke bot\n- [ai-assistant](https://github.com/youking-lib/ai-assistant) Chat assistant\n- [Feishu Bot](https://github.com/linjungz/feishu-chatgpt-bot)\n- [DomainGPT: Discover available domain names](https://github.com/billylo1/DomainGPT)\n- [AI Poem Generator](https://aipoemgenerator.com/)\n- [Next.js ChatGPT With Firebase](https://github.com/youngle316/chatgpt)\n- [ai-commit – GPT-3 Commit Message Generator](https://github.com/insulineru/ai-commit)\n- [AItinerary – ChatGPT itinerary Generator](https://aitinerary.ai)\n\nIf you create a cool integration, feel free to open a PR and add it to the list.\n\n## Compatibility\n\n- This package is ESM-only.\n- This package supports `node >= 14`.\n- This module assumes that `fetch` is installed.\n  - In `node >= 18`, it's installed by default.\n  - In `node < 18`, you need to install a polyfill like `unfetch/polyfill` ([guide](https://github.com/developit/unfetch#usage-as-a-polyfill)) or `isomorphic-fetch` ([guide](https://github.com/matthew-andrews/isomorphic-fetch#readme)).\n- If you want to build a website using `chatgpt`, we recommend using it only from your backend API\n\n## Credits\n\n- Huge thanks to [@waylaidwanderer](https://github.com/waylaidwanderer), [@abacaj](https://github.com/abacaj), [@wong2](https://github.com/wong2), [@simon300000](https://github.com/simon300000), [@RomanHotsiy](https://github.com/RomanHotsiy), [@ElijahPepe](https://github.com/ElijahPepe), and all the other contributors 💪\n- The original browser version was inspired by this [Go module](https://github.com/danielgross/whatsapp-gpt) by [Daniel Gross](https://github.com/danielgross)\n- [OpenAI](https://openai.com) for creating [ChatGPT](https://openai.com/blog/chatgpt/) 🔥\n\n## License\n\nMIT © [Travis Fischer](https://transitivebullsh.it)\n\nIf you found this project interesting, please consider [sponsoring me](https://github.com/sponsors/transitive-bullshit) or <a href=\"https://twitter.com/transitive_bs\">following me on twitter <img src=\"https://storage.googleapis.com/saasify-assets/twitter-logo.svg\" alt=\"twitter\" height=\"24px\" align=\"center\"></a>\n","readmeFilename":"readme.md","gitHead":"f9068c5b691a4f8bb793771f17a2d902641eeddf","bugs":{"url":"https://github.com/transitive-bullshit/chatgpt-api/issues"},"homepage":"https://github.com/transitive-bullshit/chatgpt-api#readme","_id":"@catalystclan/chatgpt@5.0.10-beta.2","_nodeVersion":"19.8.1","_npmVersion":"9.5.1","dist":{"integrity":"sha512-DA6lJMvPR6XYVIzjwItsNI5EtvIefATWIRVG71tSBPaESulHbOgzAlm0eGEqWVBySAtwxfcX2KtitKxbZivUWg==","shasum":"a0ee9a9555ddfc382af4c19cbe4788edd19642ee","tarball":"https://registry.npmjs.org/@catalystclan/chatgpt/-/chatgpt-5.0.10-beta.2.tgz","fileCount":9,"unpackedSize":190245,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDzrT4qQ2WT26TTpRdO95JNMS0UOcIqgUPMgt7AG7ZbFAiEAm3ufxpBTnD9j75Tm98zryLLicDi4TwCXHo4y78XM1nw="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkHBLtACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmrzuw//YcD2thDHkIAVBhPQ5eUKQ6Erk9xz0wgDLUyqYvBGz898nJAX\r\ncADbrw4/WMmp31X0PuVvS2gvKS2DNetBBTGSIDaknEdsF+0o3FiOGCcO11za\r\nCXxnMRZNJpu9BbUTvYBCIWBT1r+PosEnjAQUvQDKISKECubulSUBPBcfFgID\r\n18XZ8L9l9xWDrZcVdhqJR7OKx8Tmbt/VVhtONZjp6JPJCnMAGZ+PMtxgEMSm\r\nzMualVh8BZCRy9BeoUQInTDTN7uI9YuOeuxAEHZP+0njsZ6gHQjoERENUoqb\r\ng4puXp6n9siC4TZ3QDSslIMQKrVFfiK1/xPqAhIthehFQdsJDG14zhzW1xa2\r\nmDoMPeFgXfDs7VamqDVK9mfQAUCanSDrKY8KqeuIpf8PP3ZTEQBKxL3yghbo\r\nn6PmzfQQiHo52LrWbBXLF4UuIsxIQQO5yf5sr9NWE0po2v3HGzVm5NhUkThm\r\n/kBoZYSg6juJVwFiS1mgaSCLfV3u2zfWgKNZVVmEjvWmmW5+zjznNLDwu566\r\nuFPdKLnsFwAJFkKvcM3HJh/KepJyv66rVe8MccNXbkuPJn8b2QdhxKKG0JAp\r\nCy9FFAzMl5AxT2KoDEV08IowQolXxdSvFCWIu7R56rfWGzNK/gHmg7YA0qhB\r\nV9XWG/JhuSFWpcbEwe6N3tJ3WJEp3k4jbx8=\r\n=baDq\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"jakelaoyu","email":"jake.laoyu@gmail.com"},"directories":{},"maintainers":[{"name":"jakelaoyu","email":"jake.laoyu@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chatgpt_5.0.10-beta.2_1679561453317_0.9851723473162846"},"_hasShrinkwrap":false},"5.2.4-beta.0":{"name":"@catalystclan/chatgpt","version":"5.2.4-beta.0","description":"Node.js client for the official ChatGPT API.","author":{"name":"Travis Fischer","email":"travis@transitivebullsh.it"},"repository":{"type":"git","url":"git+https://github.com/transitive-bullshit/chatgpt-api.git"},"license":"MIT","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"source":"./src/index.ts","types":"./build/index.d.ts","exports":{".":{"import":"./build/index.mjs","types":"./build/index.d.ts","require":"./build/index.js","default":"./build/index.mjs"}},"bin":{"chatgpt":"bin/cli.js"},"engines":{"node":">=14"},"scripts":{"build":"tsup","dev":"tsup --watch","clean":"del build","prebuild":"run-s clean","predev":"run-s clean","pretest":"run-s build","docs":"typedoc","prepare":"husky install","pre-commit":"lint-staged","test":"run-p test:*","test:prettier":"prettier '**/*.{js,jsx,ts,tsx}' --check"},"dependencies":{"@dqbd/tiktoken":"^1.0.7","cac":"^6.7.14","conf":"^11.0.1","eventsource-parser":"^1.0.0","keyv":"^4.5.2","p-timeout":"npm:@esm2cjs/p-timeout@^6.0.0","quick-lru":"^5.1.1","read-pkg-up":"^7.0.1","uuid":"^9.0.0"},"devDependencies":{"@keyv/redis":"^2.5.7","@trivago/prettier-plugin-sort-imports":"^4.1.1","@types/node":"^18.16.3","@types/uuid":"^9.0.1","del-cli":"^5.0.0","dotenv-safe":"^8.2.0","husky":"^8.0.3","lint-staged":"^13.2.2","npm-run-all":"^4.1.5","ora":"^6.3.0","prettier":"^2.8.8","tsup":"^6.7.0","tsx":"^3.12.7","typedoc":"^0.24.6","typedoc-plugin-markdown":"^3.15.3","typescript":"^5.0.4"},"lint-staged":{"*.{ts,tsx}":["prettier --write"]},"keywords":["openai","chatgpt","chat","gpt","gpt-3","gpt3","gpt4","chatbot","machine learning","conversation","conversational ai","ai","ml","bot"],"gitHead":"fc41794ad4edc9b7454528472ea8cd73f99dcf2d","bugs":{"url":"https://github.com/transitive-bullshit/chatgpt-api/issues"},"homepage":"https://github.com/transitive-bullshit/chatgpt-api#readme","_id":"@catalystclan/chatgpt@5.2.4-beta.0","_nodeVersion":"18.15.0","_npmVersion":"9.5.1","dist":{"integrity":"sha512-lzEbcTb+pJ5dUGjr8XsrtuEXQjAa68hMuJe9oAW5Rc54QktpHDHgopk1KLkgXhIyZj91T7syyFug+lsayH0g4Q==","shasum":"f0c5f040261a2007d4fa0bd51b7351a65cae36e7","tarball":"https://registry.npmjs.org/@catalystclan/chatgpt/-/chatgpt-5.2.4-beta.0.tgz","fileCount":9,"unpackedSize":208855,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICjStJ1jhheAJ5may/OGApgtGhSU/6oohcvHicoMijTjAiBgGolsGR/44RT4VpCDYnSnCfZ7vSjM1Ve01w6Gg9f4Aw=="}]},"_npmUser":{"name":"jakelaoyu","email":"jake.laoyu@gmail.com"},"directories":{},"maintainers":[{"name":"jakelaoyu","email":"jake.laoyu@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chatgpt_5.2.4-beta.0_1683469332433_0.17299054880459308"},"_hasShrinkwrap":false}},"time":{"created":"2023-03-23T04:38:03.298Z","5.0.10-beta.0":"2023-03-23T04:38:03.646Z","modified":"2023-05-07T14:22:12.784Z","5.0.10-beta.1":"2023-03-23T05:40:34.499Z","5.0.10-beta.2":"2023-03-23T08:50:53.440Z","5.2.4-beta.0":"2023-05-07T14:22:12.673Z"},"maintainers":[{"name":"jakelaoyu","email":"jake.laoyu@gmail.com"}],"description":"Node.js client for the official ChatGPT API.","homepage":"https://github.com/transitive-bullshit/chatgpt-api#readme","keywords":["openai","chatgpt","chat","gpt","gpt-3","gpt3","gpt4","chatbot","machine learning","conversation","conversational ai","ai","ml","bot"],"repository":{"type":"git","url":"git+https://github.com/transitive-bullshit/chatgpt-api.git"},"author":{"name":"Travis Fischer","email":"travis@transitivebullsh.it"},"bugs":{"url":"https://github.com/transitive-bullshit/chatgpt-api/issues"},"license":"MIT","readme":"# ChatGPT API <!-- omit in toc -->\n\n> Node.js client for the official [ChatGPT](https://openai.com/blog/chatgpt/) API.\n\n[![NPM](https://img.shields.io/npm/v/chatgpt.svg)](https://www.npmjs.com/package/chatgpt) [![Build Status](https://github.com/transitive-bullshit/chatgpt-api/actions/workflows/test.yml/badge.svg)](https://github.com/transitive-bullshit/chatgpt-api/actions/workflows/test.yml) [![MIT License](https://img.shields.io/badge/license-MIT-blue)](https://github.com/transitive-bullshit/chatgpt-api/blob/main/license) [![Prettier Code Formatting](https://img.shields.io/badge/code_style-prettier-brightgreen.svg)](https://prettier.io)\n\n- [Intro](#intro)\n- [Updates](#updates)\n- [CLI](#cli)\n- [Install](#install)\n- [Usage](#usage)\n  - [Usage - ChatGPTAPI](#usage---chatgptapi)\n  - [Usage - ChatGPTUnofficialProxyAPI](#usage---chatgptunofficialproxyapi)\n    - [Reverse Proxy](#reverse-proxy)\n    - [Access Token](#access-token)\n- [Docs](#docs)\n- [Demos](#demos)\n- [Projects](#projects)\n- [Compatibility](#compatibility)\n- [Credits](#credits)\n- [License](#license)\n\n## Intro\n\nThis package is a Node.js wrapper around [ChatGPT](https://openai.com/blog/chatgpt) by [OpenAI](https://openai.com). TS batteries included. ✨\n\n<p align=\"center\">\n  <img alt=\"Example usage\" src=\"/media/demo.gif\">\n</p>\n\n## Updates\n\n<details open>\n<summary><strong>April 10, 2023</strong></summary>\n\n<br/>\n\nThis package now **fully supports GPT-4**! 🔥\n\nWe also just released a [TypeScript chatgpt-plugin package](https://github.com/transitive-bullshit/chatgpt-plugin-ts) which contains helpers and examples to make it as easy as possible to start building your own ChatGPT Plugins in JS/TS. Even if you don't have developer access to ChatGPT Plugins yet, you can still use the [chatgpt-plugin](https://github.com/transitive-bullshit/chatgpt-plugin-ts) repo to get a head start on building your own plugins locally.\n\nIf you have access to the `gpt-4` model, you can run the following to test out the CLI with GPT-4:\n\n```bash\nnpx chatgpt@latest --model gpt-4 \"Hello world\"\n```\n\n<p align=\"center\">\n  <img src=\"https://user-images.githubusercontent.com/552829/229368245-d22fbac7-4b56-4a5e-810b-5ac5793b6ac3.png\" width=\"600px\" alt=\"Using the chatgpt CLI with gpt-4\">\n</p>\n\nWe still support both the official ChatGPT API and the unofficial proxy API, but we now recommend using the official API since it's significantly more robust and supports **GPT-4**.\n\n| Method                      | Free?  | Robust? | Quality?                        |\n| --------------------------- | ------ | ------- | ------------------------------- |\n| `ChatGPTAPI`                | ❌ No  | ✅ Yes  | ✅️ Real ChatGPT models + GPT-4 |\n| `ChatGPTUnofficialProxyAPI` | ✅ Yes | ❌ No️  | ✅ ChatGPT webapp               |\n\n**Note**: We strongly recommend using `ChatGPTAPI` since it uses the officially supported API from OpenAI. We will likely remove support for `ChatGPTUnofficialProxyAPI` in a future release.\n\n1. `ChatGPTAPI` - Uses the `gpt-3.5-turbo` model with the official OpenAI chat completions API (official, robust approach, but it's not free)\n2. `ChatGPTUnofficialProxyAPI` - Uses an unofficial proxy server to access ChatGPT's backend API in a way that circumvents Cloudflare (uses the real ChatGPT and is pretty lightweight, but relies on a third-party server and is rate-limited)\n\n</details>\n\n<details>\n<summary><strong>Previous Updates</strong></summary>\n\n<br/>\n\n<details>\n<summary><strong>March 1, 2023</strong></summary>\n\n<br/>\n\nThe [official OpenAI chat completions API](https://platform.openai.com/docs/guides/chat) has been released, and it is now the default for this package! 🔥\n\n| Method                      | Free?  | Robust?  | Quality?                |\n| --------------------------- | ------ | -------- | ----------------------- |\n| `ChatGPTAPI`                | ❌ No  | ✅ Yes   | ✅️ Real ChatGPT models |\n| `ChatGPTUnofficialProxyAPI` | ✅ Yes | ☑️ Maybe | ✅ Real ChatGPT         |\n\n**Note**: We strongly recommend using `ChatGPTAPI` since it uses the officially supported API from OpenAI. We may remove support for `ChatGPTUnofficialProxyAPI` in a future release.\n\n1. `ChatGPTAPI` - Uses the `gpt-3.5-turbo` model with the official OpenAI chat completions API (official, robust approach, but it's not free)\n2. `ChatGPTUnofficialProxyAPI` - Uses an unofficial proxy server to access ChatGPT's backend API in a way that circumvents Cloudflare (uses the real ChatGPT and is pretty lightweight, but relies on a third-party server and is rate-limited)\n\n</details>\n\n<details>\n<summary><strong>Feb 19, 2023</strong></summary>\n\n<br/>\n\nWe now provide three ways of accessing the unofficial ChatGPT API, all of which have tradeoffs:\n\n| Method                      | Free?  | Robust?  | Quality?          |\n| --------------------------- | ------ | -------- | ----------------- |\n| `ChatGPTAPI`                | ❌ No  | ✅ Yes   | ☑️ Mimics ChatGPT |\n| `ChatGPTUnofficialProxyAPI` | ✅ Yes | ☑️ Maybe | ✅ Real ChatGPT   |\n| `ChatGPTAPIBrowser` (v3)    | ✅ Yes | ❌ No    | ✅ Real ChatGPT   |\n\n**Note**: I recommend that you use either `ChatGPTAPI` or `ChatGPTUnofficialProxyAPI`.\n\n1. `ChatGPTAPI` - (Used to use) `text-davinci-003` to mimic ChatGPT via the official OpenAI completions API (most robust approach, but it's not free and doesn't use a model fine-tuned for chat)\n2. `ChatGPTUnofficialProxyAPI` - Uses an unofficial proxy server to access ChatGPT's backend API in a way that circumvents Cloudflare (uses the real ChatGPT and is pretty lightweight, but relies on a third-party server and is rate-limited)\n3. `ChatGPTAPIBrowser` - (_deprecated_; v3.5.1 of this package) Uses Puppeteer to access the official ChatGPT webapp (uses the real ChatGPT, but very flaky, heavyweight, and error prone)\n\n</details>\n\n<details>\n<summary><strong>Feb 5, 2023</strong></summary>\n\n<br/>\n\nOpenAI has disabled the leaked chat model we were previously using, so we're now defaulting to `text-davinci-003`, which is not free.\n\nWe've found several other hidden, fine-tuned chat models, but OpenAI keeps disabling them, so we're searching for alternative workarounds.\n\n</details>\n\n<details>\n<summary><strong>Feb 1, 2023</strong></summary>\n\n<br/>\n\nThis package no longer requires any browser hacks – **it is now using the official OpenAI completions API** with a leaked model that ChatGPT uses under the hood. 🔥\n\n```ts\nimport { ChatGPTAPI } from 'chatgpt'\n\nconst api = new ChatGPTAPI({\n  apiKey: process.env.OPENAI_API_KEY\n})\n\nconst res = await api.sendMessage('Hello World!')\nconsole.log(res.text)\n```\n\nPlease upgrade to `chatgpt@latest` (at least [v4.0.0](https://github.com/transitive-bullshit/chatgpt-api/releases/tag/v4.0.0)). The updated version is **significantly more lightweight and robust** compared with previous versions. You also don't have to worry about IP issues or rate limiting.\n\nHuge shoutout to [@waylaidwanderer](https://github.com/waylaidwanderer) for discovering the leaked chat model!\n\n</details>\n</details>\n\nIf you run into any issues, we do have a pretty active [ChatGPT Hackers Discord](https://www.chatgpthackers.dev/) with over 8k developers from the Node.js & Python communities.\n\nLastly, please consider starring this repo and <a href=\"https://twitter.com/transitive_bs\">following me on twitter <img src=\"https://storage.googleapis.com/saasify-assets/twitter-logo.svg\" alt=\"twitter\" height=\"24px\" align=\"center\"></a> to help support the project.\n\nThanks && cheers,\n[Travis](https://twitter.com/transitive_bs)\n\n## CLI\n\nTo run the CLI, you'll need an [OpenAI API key](https://platform.openai.com/overview):\n\n```bash\nexport OPENAI_API_KEY=\"sk-TODO\"\nnpx chatgpt \"your prompt here\"\n```\n\nBy default, the response is streamed to stdout, the results are stored in a local config file, and every invocation starts a new conversation. You can use `-c` to continue the previous conversation and `--no-stream` to disable streaming.\n\n```\nUsage:\n  $ chatgpt <prompt>\n\nCommands:\n  <prompt>  Ask ChatGPT a question\n  rm-cache  Clears the local message cache\n  ls-cache  Prints the local message cache path\n\nFor more info, run any command with the `--help` flag:\n  $ chatgpt --help\n  $ chatgpt rm-cache --help\n  $ chatgpt ls-cache --help\n\nOptions:\n  -c, --continue          Continue last conversation (default: false)\n  -d, --debug             Enables debug logging (default: false)\n  -s, --stream            Streams the response (default: true)\n  -s, --store             Enables the local message cache (default: true)\n  -t, --timeout           Timeout in milliseconds\n  -k, --apiKey            OpenAI API key\n  -o, --apiOrg            OpenAI API organization\n  -n, --conversationName  Unique name for the conversation\n  -h, --help              Display this message\n  -v, --version           Display version number\n```\n\nIf you have access to the `gpt-4` model, you can run the following to test out the CLI with GPT-4:\n\n<p align=\"center\">\n  <img src=\"https://user-images.githubusercontent.com/552829/229368245-d22fbac7-4b56-4a5e-810b-5ac5793b6ac3.png\" width=\"600px\" alt=\"Using the chatgpt CLI with gpt-4\">\n</p>\n\n## Install\n\n```bash\nnpm install chatgpt\n```\n\nMake sure you're using `node >= 18` so `fetch` is available (or `node >= 14` if you install a [fetch polyfill](https://github.com/developit/unfetch#usage-as-a-polyfill)).\n\n## Usage\n\nTo use this module from Node.js, you need to pick between two methods:\n\n| Method                      | Free?  | Robust? | Quality?                        |\n| --------------------------- | ------ | ------- | ------------------------------- |\n| `ChatGPTAPI`                | ❌ No  | ✅ Yes  | ✅️ Real ChatGPT models + GPT-4 |\n| `ChatGPTUnofficialProxyAPI` | ✅ Yes | ❌ No️  | ✅ Real ChatGPT webapp          |\n\n1. `ChatGPTAPI` - Uses the `gpt-3.5-turbo` model with the official OpenAI chat completions API (official, robust approach, but it's not free). You can override the model, completion params, and system message to fully customize your assistant.\n\n2. `ChatGPTUnofficialProxyAPI` - Uses an unofficial proxy server to access ChatGPT's backend API in a way that circumvents Cloudflare (uses the real ChatGPT and is pretty lightweight, but relies on a third-party server and is rate-limited)\n\nBoth approaches have very similar APIs, so it should be simple to swap between them.\n\n**Note**: We strongly recommend using `ChatGPTAPI` since it uses the officially supported API from OpenAI and it also supports `gpt-4`. We will likely remove support for `ChatGPTUnofficialProxyAPI` in a future release.\n\n### Usage - ChatGPTAPI\n\nSign up for an [OpenAI API key](https://platform.openai.com/overview) and store it in your environment.\n\n```ts\nimport { ChatGPTAPI } from 'chatgpt'\n\nasync function example() {\n  const api = new ChatGPTAPI({\n    apiKey: process.env.OPENAI_API_KEY\n  })\n\n  const res = await api.sendMessage('Hello World!')\n  console.log(res.text)\n}\n```\n\nYou can override the default `model` (`gpt-3.5-turbo`) and any [OpenAI chat completion params](https://platform.openai.com/docs/api-reference/chat/create) using `completionParams`:\n\n```ts\nconst api = new ChatGPTAPI({\n  apiKey: process.env.OPENAI_API_KEY,\n  completionParams: {\n    model: 'gpt-4',\n    temperature: 0.5,\n    top_p: 0.8\n  }\n})\n```\n\nIf you want to track the conversation, you'll need to pass the `parentMessageId` like this:\n\n```ts\nconst api = new ChatGPTAPI({ apiKey: process.env.OPENAI_API_KEY })\n\n// send a message and wait for the response\nlet res = await api.sendMessage('What is OpenAI?')\nconsole.log(res.text)\n\n// send a follow-up\nres = await api.sendMessage('Can you expand on that?', {\n  parentMessageId: res.id\n})\nconsole.log(res.text)\n\n// send another follow-up\nres = await api.sendMessage('What were we talking about?', {\n  parentMessageId: res.id\n})\nconsole.log(res.text)\n```\n\nYou can add streaming via the `onProgress` handler:\n\n```ts\nconst res = await api.sendMessage('Write a 500 word essay on frogs.', {\n  // print the partial response as the AI is \"typing\"\n  onProgress: (partialResponse) => console.log(partialResponse.text)\n})\n\n// print the full text at the end\nconsole.log(res.text)\n```\n\nYou can add a timeout using the `timeoutMs` option:\n\n```ts\n// timeout after 2 minutes (which will also abort the underlying HTTP request)\nconst response = await api.sendMessage(\n  'write me a really really long essay on frogs',\n  {\n    timeoutMs: 2 * 60 * 1000\n  }\n)\n```\n\nIf you want to see more info about what's actually being sent to [OpenAI's chat completions API](https://platform.openai.com/docs/api-reference/chat/create), set the `debug: true` option in the `ChatGPTAPI` constructor:\n\n```ts\nconst api = new ChatGPTAPI({\n  apiKey: process.env.OPENAI_API_KEY,\n  debug: true\n})\n```\n\nWe default to a basic `systemMessage`. You can override this in either the `ChatGPTAPI` constructor or `sendMessage`:\n\n```ts\nconst res = await api.sendMessage('what is the answer to the universe?', {\n  systemMessage: `You are ChatGPT, a large language model trained by OpenAI. You answer as concisely as possible for each responseIf you are generating a list, do not have too many items.\nCurrent date: ${new Date().toISOString()}\\n\\n`\n})\n```\n\nNote that we automatically handle appending the previous messages to the prompt and attempt to optimize for the available tokens (which defaults to `4096`).\n\n<details>\n<summary>Usage in CommonJS (Dynamic import)</summary>\n\n```js\nasync function example() {\n  // To use ESM in CommonJS, you can use a dynamic import like this:\n  const { ChatGPTAPI } = await import('chatgpt')\n  // You can also try dynamic importing like this:\n  // const importDynamic = new Function('modulePath', 'return import(modulePath)')\n  // const { ChatGPTAPI } = await importDynamic('chatgpt')\n\n  const api = new ChatGPTAPI({ apiKey: process.env.OPENAI_API_KEY })\n\n  const res = await api.sendMessage('Hello World!')\n  console.log(res.text)\n}\n```\n\n</details>\n\n### Usage - ChatGPTUnofficialProxyAPI\n\nThe API for `ChatGPTUnofficialProxyAPI` is almost exactly the same. You just need to provide a ChatGPT `accessToken` instead of an OpenAI API key.\n\n```ts\nimport { ChatGPTUnofficialProxyAPI } from 'chatgpt'\n\nasync function example() {\n  const api = new ChatGPTUnofficialProxyAPI({\n    accessToken: process.env.OPENAI_ACCESS_TOKEN\n  })\n\n  const res = await api.sendMessage('Hello World!')\n  console.log(res.text)\n}\n```\n\nSee [demos/demo-reverse-proxy](./demos/demo-reverse-proxy.ts) for a full example:\n\n```bash\nnpx tsx demos/demo-reverse-proxy.ts\n```\n\n`ChatGPTUnofficialProxyAPI` messages also contain a `conversationid` in addition to `parentMessageId`, since the ChatGPT webapp can't reference messages across different accounts & conversations.\n\n#### Reverse Proxy\n\nYou can override the reverse proxy by passing `apiReverseProxyUrl`:\n\n```ts\nconst api = new ChatGPTUnofficialProxyAPI({\n  accessToken: process.env.OPENAI_ACCESS_TOKEN,\n  apiReverseProxyUrl: 'https://your-example-server.com/api/conversation'\n})\n```\n\nKnown reverse proxies run by community members include:\n\n| Reverse Proxy URL                                 | Author                                       | Rate Limits                  | Last Checked |\n| ------------------------------------------------- | -------------------------------------------- | ---------------------------- | ------------ |\n| `https://ai.fakeopen.com/api/conversation` | [@pengzhile](https://github.com/pengzhile)   | 5 req / 10 seconds by IP     | 4/18/2023    |\n| `https://api.pawan.krd/backend-api/conversation`  | [@PawanOsman](https://github.com/PawanOsman) | 50 req / 15 seconds (~3 r/s) | 3/23/2023    |\n\nNote: info on how the reverse proxies work is not being published at this time in order to prevent OpenAI from disabling access.\n\n#### Access Token\n\nTo use `ChatGPTUnofficialProxyAPI`, you'll need an OpenAI access token from the ChatGPT webapp. To do this, you can use any of the following methods which take an `email` and `password` and return an access token:\n\n- Node.js libs\n  - [ericlewis/openai-authenticator](https://github.com/ericlewis/openai-authenticator)\n  - [michael-dm/openai-token](https://github.com/michael-dm/openai-token)\n  - [allanoricil/chat-gpt-authenticator](https://github.com/AllanOricil/chat-gpt-authenticator)\n- Python libs\n  - [acheong08/OpenAIAuth](https://github.com/acheong08/OpenAIAuth)\n\nThese libraries work with email + password accounts (e.g., they do not support accounts where you auth via Microsoft / Google).\n\nAlternatively, you can manually get an `accessToken` by logging in to the ChatGPT webapp and then opening `https://chat.openai.com/api/auth/session`, which will return a JSON object containing your `accessToken` string.\n\nAccess tokens last for days.\n\n**Note**: using a reverse proxy will expose your access token to a third-party. There shouldn't be any adverse effects possible from this, but please consider the risks before using this method.\n\n## Docs\n\nSee the [auto-generated docs](./docs/classes/ChatGPTAPI.md) for more info on methods and parameters.\n\n## Demos\n\nMost of the demos use `ChatGPTAPI`. It should be pretty easy to convert them to use `ChatGPTUnofficialProxyAPI` if you'd rather use that approach. The only thing that needs to change is how you initialize the api with an `accessToken` instead of an `apiKey`.\n\nTo run the included demos:\n\n1. clone repo\n2. install node deps\n3. set `OPENAI_API_KEY` in .env\n\nA [basic demo](./demos/demo.ts) is included for testing purposes:\n\n```bash\nnpx tsx demos/demo.ts\n```\n\nA [demo showing on progress handler](./demos/demo-on-progress.ts):\n\n```bash\nnpx tsx demos/demo-on-progress.ts\n```\n\nThe on progress demo uses the optional `onProgress` parameter to `sendMessage` to receive intermediary results as ChatGPT is \"typing\".\n\nA [conversation demo](./demos/demo-conversation.ts):\n\n```bash\nnpx tsx demos/demo-conversation.ts\n```\n\nA [persistence demo](./demos/demo-persistence.ts) shows how to store messages in Redis for persistence:\n\n```bash\nnpx tsx demos/demo-persistence.ts\n```\n\nAny [keyv adaptor](https://github.com/jaredwray/keyv) is supported for persistence, and there are overrides if you'd like to use a different way of storing / retrieving messages.\n\nNote that persisting message is required for remembering the context of previous conversations beyond the scope of the current Node.js process, since by default, we only store messages in memory. Here's an [external demo](https://github.com/transitive-bullshit/chatgpt-twitter-bot/blob/main/src/index.ts#L86-L95) of using a completely custom database solution to persist messages.\n\n**Note**: Persistence is handled automatically when using `ChatGPTUnofficialProxyAPI` because it is connecting indirectly to ChatGPT.\n\n## Projects\n\nAll of these awesome projects are built using the `chatgpt` package. 🤯\n\n- [Twitter Bot](https://github.com/transitive-bullshit/chatgpt-twitter-bot) powered by ChatGPT ✨\n  - Mention [@ChatGPTBot](https://twitter.com/ChatGPTBot) on Twitter with your prompt to try it out\n- [ChatGPT API Server](https://github.com/waylaidwanderer/node-chatgpt-api) - API server for this package with support for multiple OpenAI accounts, proxies, and load-balancing requests between accounts.\n- [ChatGPT Prompts](https://github.com/pacholoamit/chatgpt-prompts) - A collection of 140+ of the best ChatGPT prompts from the community.\n- [Lovelines.xyz](https://lovelines.xyz?ref=chatgpt-api)\n- [Chrome Extension](https://github.com/gragland/chatgpt-everywhere) ([demo](https://twitter.com/gabe_ragland/status/1599466486422470656))\n- [VSCode Extension #1](https://github.com/mpociot/chatgpt-vscode) ([demo](https://twitter.com/marcelpociot/status/1599180144551526400), [updated version](https://github.com/timkmecl/chatgpt-vscode), [marketplace](https://marketplace.visualstudio.com/items?itemName=timkmecl.chatgpt))\n- [VSCode Extension #2](https://github.com/barnesoir/chatgpt-vscode-plugin) ([marketplace](https://marketplace.visualstudio.com/items?itemName=JayBarnes.chatgpt-vscode-plugin))\n- [VSCode Extension #3](https://github.com/gencay/vscode-chatgpt) ([marketplace](https://marketplace.visualstudio.com/items?itemName=gencay.vscode-chatgpt))\n- [VSCode Extension #4](https://github.com/dogukanakkaya/chatgpt-code-vscode-extension) ([marketplace](https://marketplace.visualstudio.com/items?itemName=dogukanakkaya.chatgpt-code))\n- [Raycast Extension #1](https://github.com/abielzulio/chatgpt-raycast) ([demo](https://twitter.com/abielzulio/status/1600176002042191875))\n- [Raycast Extension #2](https://github.com/domnantas/raycast-chatgpt)\n- [Telegram Bot #1](https://github.com/realies/chatgpt-telegram-bot)\n- [Telegram Bot #2](https://github.com/dawangraoming/chatgpt-telegram-bot)\n- [Telegram Bot #3](https://github.com/RainEggplant/chatgpt-telegram-bot) (group privacy mode, ID-based auth)\n- [Telegram Bot #4](https://github.com/ArdaGnsrn/chatgpt-telegram) (queue system, ID-based chat thread)\n- [Telegram Bot #5](https://github.com/azoway/chatgpt-telegram-bot) (group privacy mode, ID-based chat thread)\n- [Deno Telegram Bot](https://github.com/Ciyou/chatbot-telegram)\n- [Go Telegram Bot](https://github.com/m1guelpf/chatgpt-telegram)\n- [Telegram Bot for YouTube Summaries](https://github.com/codextde/youtube-summary)\n- [GitHub ProBot](https://github.com/oceanlvr/ChatGPTBot)\n- [Discord Bot #1](https://github.com/onury5506/Discord-ChatGPT-Bot)\n- [Discord Bot #2](https://github.com/Nageld/ChatGPT-Bot)\n- [Discord Bot #3](https://github.com/leinstay/gptbot)\n- [Discord Bot #4 (selfbot)](https://github.com/0x7030676e31/cumsocket)\n- [Discord Bot #5](https://github.com/itskdhere/ChatGPT-Discord-BOT)\n- [Discord Bot #6 (Shakespeare bot)](https://gist.github.com/TheBrokenRail/4b37e7c44e8f721d8bd845050d034c16)\n- [Discord Bot #7](https://github.com/Elitezen/discordjs-chatgpt)\n- [Zoom Chat](https://github.com/shixin-guo/my-bot)\n- [WeChat Bot #1](https://github.com/AutumnWhj/ChatGPT-wechat-bot)\n- [WeChat Bot #2](https://github.com/fuergaosi233/wechat-chatgpt)\n- [WeChat Bot #3](https://github.com/wangrongding/wechat-bot) (\n- [WeChat Bot #4](https://github.com/darknightlab/wechat-bot)\n- [WeChat Bot #5](https://github.com/sunshanpeng/wechaty-chatgpt)\n- [WeChat Bot #6](https://github.com/formulahendry/chatgpt-wechat-bot)\n- [WeChat Bot #7](https://github.com/gfl94/Chatbot004)\n- [QQ Bot (plugin for Yunzai-bot)](https://github.com/ikechan8370/chatgpt-plugin)\n- [QQ Bot (plugin for KiviBot)](https://github.com/KiviBotLab/kivibot-plugin-chatgpt)\n- [QQ Bot (oicq)](https://github.com/easydu2002/chat_gpt_oicq)\n- [QQ Bot (oicq + RabbitMQ)](https://github.com/linsyking/ChatGPT-QQBot)\n- [QQ Bot (go-cqhttp)](https://github.com/PairZhu/ChatGPT-QQRobot)\n- [QQ Bot (plugin for Yunzai-Bot + Bull)](https://github.com/Micuks/chatGPT-yunzai) (Lightweight, Google Bard support 💪)\n- [EXM smart contracts](https://github.com/decentldotland/molecule)\n- [Flutter ChatGPT API](https://github.com/coskuncay/flutter_chatgpt_api)\n- [Carik Bot](https://github.com/luridarmawan/Carik)\n- [Github Action for reviewing PRs](https://github.com/kxxt/chatgpt-action/)\n- [WhatsApp Bot #1](https://github.com/askrella/whatsapp-chatgpt) (DALL-E + Whisper support 💪)\n- [WhatsApp Bot #2](https://github.com/amosayomide05/chatgpt-whatsapp-bot)\n- [WhatsApp Bot #3](https://github.com/pascalroget/whatsgpt) (multi-user support)\n- [WhatsApp Bot #4](https://github.com/noelzappy/chatgpt-whatsapp) (schedule periodic messages)\n- [WhatsApp Bot #5](https://github.com/hujanais/bs-chat-gpt3-api) (RaspberryPi + ngrok + Twilio)\n- [WhatsApp Bot #6](https://github.com/dannysantino/whatsgpt) (Session and chat history storage with MongoStore)\n- [Matrix Bot](https://github.com/matrixgpt/matrix-chatgpt-bot)\n- [Rental Cover Letter Generator](https://sharehouse.app/ai)\n- [Assistant CLI](https://github.com/diciaup/assistant-cli)\n- [Teams Bot](https://github.com/formulahendry/chatgpt-teams-bot)\n- [Askai](https://github.com/yudax42/askai)\n- [TalkGPT](https://github.com/ShadovvBeast/TalkGPT)\n- [ChatGPT With Voice](https://github.com/thanhsonng/chatgpt-voice)\n- [iOS Shortcut](https://github.com/leecobaby/shortcuts/blob/master/other/ChatGPT_EN.md)\n- [Slack Bot #1](https://github.com/trietphm/chatgpt-slackbot/)\n- [Slack Bot #2](https://github.com/lokwkin/chatgpt-slackbot-node/) (with queueing mechanism)\n- [Slack Bot #3](https://github.com/NessunKim/slack-chatgpt/)\n- [Slack Bot #4](https://github.com/MarkusGalant/chatgpt-slackbot-serverless/) ( Serverless AWS Lambda )\n- [Slack Bot #5](https://github.com/benjiJanssens/SlackGPT) (Hosted)\n  - [Add to Slack](https://slackgpt.benji.sh/slack/install)\n- [Electron Bot](https://github.com/ShiranAbir/chaty)\n- [Kodyfire CLI](https://github.com/nooqta/chatgpt-kodyfire)\n- [Twitch Bot](https://github.com/BennyDeeDev/chatgpt-twitch-bot)\n- [Continuous Conversation](https://github.com/DanielTerletzkiy/chat-gtp-assistant)\n- [Figma plugin](https://github.com/frederickk/chatgpt-figma-plugin)\n- [NestJS server](https://github.com/RusDyn/chatgpt_nestjs_server)\n- [NestJS ChatGPT Starter Boilerplate](https://github.com/mitkodkn/nestjs-chatgpt-starter)\n- [Wordsmith: Add-in for Microsoft Word](https://github.com/xtremehpx/Wordsmith)\n- [QuizGPT: Create Kahoot quizzes with ChatGPT](https://github.com/Kladdy/quizgpt)\n- [openai-chatgpt: Talk to ChatGPT from the terminal](https://github.com/gmpetrov/openai-chatgpt)\n- [Clippy the Saleforce chatbot](https://github.com/sebas00/chatgptclippy) ClippyJS joke bot\n- [ai-assistant](https://github.com/youking-lib/ai-assistant) Chat assistant\n- [Feishu Bot](https://github.com/linjungz/feishu-chatgpt-bot)\n- [DomainGPT: Discover available domain names](https://github.com/billylo1/DomainGPT)\n- [AI Poem Generator](https://aipoemgenerator.com/)\n- [Next.js ChatGPT With Firebase](https://github.com/youngle316/chatgpt)\n- [ai-commit – GPT-3 Commit Message Generator](https://github.com/insulineru/ai-commit)\n- [AItinerary – ChatGPT itinerary Generator](https://aitinerary.ai)\n- [wechaty-chatgpt - A chatbot based on Wechaty & ChatGPT](https://github.com/zhengxs2018/wechaty-chatgpt)\n- [Julius GPT](https://github.com/christophebe/julius-gpt) - Generate and publish your content from the CLI\n- [OpenAI-API-Service](https://github.com/Jarvan-via/api-service) - Provides OpenAI related APIs for businesses\n- [Discord Daily News Bot](https://github.com/ZirionNeft/chatgpt-discord-daily-news-bot) - Discord bot that generate funny daily news\n- [ai-assistant](https://github.com/chenweiyi/ai-assistant) - Create a chat website similar to ChatGPT\n\nIf you create a cool integration, feel free to open a PR and add it to the list.\n\n## Compatibility\n\n- This package is ESM-only.\n- This package supports `node >= 14`.\n- This module assumes that `fetch` is installed.\n  - In `node >= 18`, it's installed by default.\n  - In `node < 18`, you need to install a polyfill like `unfetch/polyfill` ([guide](https://github.com/developit/unfetch#usage-as-a-polyfill)) or `isomorphic-fetch` ([guide](https://github.com/matthew-andrews/isomorphic-fetch#readme)).\n- If you want to build a website using `chatgpt`, we recommend using it only from your backend API\n\n## Credits\n\n- Huge thanks to [@waylaidwanderer](https://github.com/waylaidwanderer), [@abacaj](https://github.com/abacaj), [@wong2](https://github.com/wong2), [@simon300000](https://github.com/simon300000), [@RomanHotsiy](https://github.com/RomanHotsiy), [@ElijahPepe](https://github.com/ElijahPepe), and all the other contributors 💪\n- [OpenAI](https://openai.com) for creating [ChatGPT](https://openai.com/blog/chatgpt/) 🔥\n- I run the [ChatGPT Hackers Discord](https://www.chatgpthackers.dev/) with over 8k developers – come join us!\n\n## License\n\nMIT © [Travis Fischer](https://transitivebullsh.it)\n\nIf you found this project interesting, please consider [sponsoring me](https://github.com/sponsors/transitive-bullshit) or <a href=\"https://twitter.com/transitive_bs\">following me on twitter <img src=\"https://storage.googleapis.com/saasify-assets/twitter-logo.svg\" alt=\"twitter\" height=\"24px\" align=\"center\"></a>\n","readmeFilename":"readme.md"}