// uses puppeteer to bypass cloudflare (headful because you may have to solve
// use puppeteer to bypass cloudflare (headful because of captchas)
// a captcha)
constopenAIAuth=awaitgetOpenAIAuth({
constopenAIAuth=awaitgetOpenAIAuth({
email:process.env.EMAIL,
email:process.env.EMAIL,
password:process.env.EMAIL
password:process.env.EMAIL
...
@@ -174,7 +173,7 @@ You can also get these tokens manually, but keep in mind that the `clearanceToke
...
@@ -174,7 +173,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.
...
@@ -182,11 +181,14 @@ To get a session token manually:
...
@@ -182,11 +181,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
...
@@ -254,15 +256,14 @@ If you create a cool integration, feel free to open a PR and add it to the list.
...
@@ -254,15 +256,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/) 🔥