diff --git a/legacy/readme.md b/legacy/readme.md index 475f94b9..64630e9f 100644 --- a/legacy/readme.md +++ b/legacy/readme.md @@ -1,5 +1,40 @@ -> **Note** -> As of December 11, 2022 ~2pm CST, OpenAI has enabled additional Cloudflare restrictions that are currently preventing us from refreshing access tokens. This is affecting _all_ ChatGPT API wrappers at the moment, including the Python ones. See [this issue](https://github.com/transitive-bullshit/chatgpt-api/issues/96) for an ongoing discussion until I release a viable workaround. +# Update December 11, 2022 + +Today, OpenAI added additional Cloudflare protections that make it more difficult to access the unofficial API. _This is affecting all ChatGPT API wrappers at the moment_, including the Python ones. See [this issue](https://github.com/transitive-bullshit/chatgpt-api/issues/96). + +**As a temporary workaround**, make sure you're using the latest version of this package and Node.js >= 18: + +1. Log into https://chat.openai.com/chat and copy a fresh session token (same instructions as below). + +2. Copy the value of the `cf_clearance` cookie and store it in a `CLEARANCE_TOKEN` environment variable in addition to your `SESSION_TOKEN`. + +3. Copy your browser's `user-agent` header from any request in your browser's network tab. + +4. Use both tokens when creating the API wrapper: + +```ts +const api = new ChatGPTApI({ + sessionToken: process.env.SESSION_TOKEN, + clearanceToken: process.env.CLEARANCE_TOKEN, + userAgent: '' // replace to match your real browser's user agent +}) + +await api.ensureAuth() +``` + +Restrictions on this method: + +- Cloudflare `cf_clearance` **tokens expire after 2 hours**, so right now you manually have to log in and extract it by hand every so often +- Your `user-agent` and `IP address` **must match** from the real browser window you logged into to the one you're using for `ChatGPTAPI`. + - This means that you currently can't log in with your laptop and then run the bot on a server somewhere. +- You must use `node >= 18`. I'm using `v19.2.0` in my testing, but for some reason, all `fetch` requests using `v16` and `v17` fail at the moment (these use `undici` under the hood, whereas Node.js v18 and above use a built-in `fetch` based on `undici`). + +We're working hard in [this issue](https://github.com/transitive-bullshit/chatgpt-api/issues/96) to make this process easier and more automated. + +Cheers, +Travis + +---
@@ -11,16 +46,17 @@
[](https://www.npmjs.com/package/chatgpt) [](https://github.com/transitive-bullshit/chatgpt-api/actions/workflows/test.yml) [](https://github.com/transitive-bullshit/chatgpt-api/blob/main/license) [](https://prettier.io)
-- [Intro](#intro)
-- [Install](#install)
-- [Usage](#usage)
- - [Docs](#docs)
- - [Demos](#demos)
- - [Session Tokens](#session-tokens)
-- [Projects](#projects)
-- [Compatibility](#compatibility)
-- [Credits](#credits)
-- [License](#license)
+- [Update December 11, 2022](#update-december-11-2022)
+ - [Intro](#intro)
+ - [Install](#install)
+ - [Usage](#usage)
+ - [Docs](#docs)
+ - [Demos](#demos)
+ - [Session Tokens](#session-tokens)
+ - [Projects](#projects)
+ - [Compatibility](#compatibility)
+ - [Credits](#credits)
+ - [License](#license)
## Intro