Yesterday, OpenAI added additional Cloudflare protections that make it more difficult to access the unofficial API.
Yesterday, OpenAI added additional Cloudflare protections that make it more difficult to access the unofficial API.
...
@@ -10,7 +10,7 @@ To use the updated version, **make sure you're using the latest version of this
...
@@ -10,7 +10,7 @@ To use the updated version, **make sure you're using the latest version of this
We're working hard to improve this process (especially CAPTCHA automation). Keep in mind that this package will be updated to use the official API as soon as it's released, so things should get much easier over time. 💪
We're working hard to improve this process (especially CAPTCHA automation). Keep in mind that this package will be updated to use the official API as soon as it's released, so things should get much easier over time. 💪
Lastly, please star this repo and <ahref="https://twitter.com/transitive_bs">follow me on twitter <imgsrc="https://storage.googleapis.com/saasify-assets/twitter-logo.svg"alt="twitter"height="24px"align="center"></a> to help support the project.
Lastly, please consider starring this repo and <ahref="https://twitter.com/transitive_bs">following me on twitter <imgsrc="https://storage.googleapis.com/saasify-assets/twitter-logo.svg"alt="twitter"height="24px"align="center"></a> to help support the project.
3. set `OPENAI_EMAIL` and `OPENAI_PASSWORD` in .env
A [basic demo](./demos/demo.ts) is included for testing purposes:
A [basic demo](./demos/demo.ts) is included for testing purposes:
```bash
```bash
npx tsx src/demo.ts
npx tsx demos/demo.ts
```
```
A [conversation demo](./demos/demo-conversation.ts) is also included:
A [conversation demo](./demos/demo-conversation.ts) is also included:
```bash
```bash
npx tsx src/demo-conversation.ts
npx tsx demos/demo-conversation.ts
```
```
### Authentication
### Authentication
...
@@ -176,7 +174,7 @@ You can also get these tokens manually, but keep in mind that the `clearanceToke
...
@@ -176,7 +174,7 @@ You can also get these tokens manually, but keep in mind that the `clearanceToke
<details>
<details>
<summary>Getting tokens manually</summary>
<summary>Getting tokens manually</summary>
To get a session token manually:
To get session token manually:
1. Go to https://chat.openai.com/chat and log in or sign up.
1. Go to https://chat.openai.com/chat and log in or sign up.
2. Open dev tools.
2. Open dev tools.
...
@@ -184,11 +182,14 @@ To get a session token manually:
...
@@ -184,11 +182,14 @@ To get a session token manually:


4. Copy the value for `__Secure-next-auth.session-token` and save it to your environment. This will be your `sessionToken`.
4. Copy the value for `__Secure-next-auth.session-token` and save it to your environment. This will be your `sessionToken`.
5. Copy the value for `cf_clearance` and save it to your environment. This will be your `clearanceToken`.
5. Copy the value for `cf_clearance` and save it to your environment. This will be your `clearanceToken`.
6. Copy the value of the `user-agent` header from any request in your `Network` tab. This will be your `userAgent`.
Pass `sessionToken`, `clearanceToken`, and `userAgent` to the `ChatGPTAPI` constructor.
</details>
</details>
> **Note**
> **Note**
> This package will switch to using the official API once it's released.
> This package will switch to using the official API once it's released, which will make this process much simpler.
#### Restrictions
#### Restrictions
...
@@ -256,15 +257,14 @@ If you create a cool integration, feel free to open a PR and add it to the list.
...
@@ -256,15 +257,14 @@ If you create a cool integration, feel free to open a PR and add it to the list.
This package is ESM-only. It supports:
This package is ESM-only. It supports:
- Node.js >= 18
- Node.js >= 18
- Node.js 17, 16, and 14 were supported in earlier versions, but OpenAI's Cloudflare update caused a bug with `undici` on v17 and v16 that we need to debug. So for now, use `node >= 18`
- Node.js 17, 16, and 14 were supported in earlier versions, but OpenAI's Cloudflare update caused a bug with `undici` on v17 and v16 that needs investigation. So for now, use `node >= 18`
- We recommend against using `chatgpt` from client-side browser code because it would expose your private session token
- We recommend against using `chatgpt` from client-side browser code because it would expose your private session token
- If you want to build a website using `chatgpt`, we recommend using it only from your backend API
- If you want to build a website using `chatgpt`, we recommend using it only from your backend API
## Credits
## Credits
- Huge thanks to [@simon300000](https://github.com/simon300000), [@RomanHotsiy](https://github.com/RomanHotsiy), [@ElijahPepe](https://github.com/ElijahPepe), and all the other contributors 💪
- Huge thanks to [@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 💪
- The original browser version was inspired by this [Go module](https://github.com/danielgross/whatsapp-gpt) by [Daniel Gross](https://github.com/danielgross)
- The original browser version was inspired by this [Go module](https://github.com/danielgross/whatsapp-gpt) by [Daniel Gross](https://github.com/danielgross)
- The original REST version was inspired by [chat-gpt-google-extension](https://github.com/wong2/chat-gpt-google-extension) by [@wong2](https://github.com/wong2)
-[OpenAI](https://openai.com) for creating [ChatGPT](https://openai.com/blog/chatgpt/) 🔥
-[OpenAI](https://openai.com) for creating [ChatGPT](https://openai.com/blog/chatgpt/) 🔥