Commit 80fda8c5 authored by MrlolDev's avatar MrlolDev Committed by GitHub

Merge pull request #1 from transitive-bullshit/main

Update code 2.3.0
parents 1dc12afe 6fb1ff92
...@@ -9,5 +9,5 @@ ...@@ -9,5 +9,5 @@
# ChatGPT # ChatGPT
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
EMAIL= OPENAI_EMAIL=
PASSWORD= OPENAI_PASSWORD=
...@@ -13,8 +13,8 @@ dotenv.config() ...@@ -13,8 +13,8 @@ dotenv.config()
* ``` * ```
*/ */
async function main() { async function main() {
const email = process.env.EMAIL const email = process.env.OPENAI_EMAIL
const password = process.env.PASSWORD const password = process.env.OPENAI_PASSWORD
const authInfo = await getOpenAIAuth({ const authInfo = await getOpenAIAuth({
email, email,
......
...@@ -13,8 +13,8 @@ dotenv.config() ...@@ -13,8 +13,8 @@ dotenv.config()
* ``` * ```
*/ */
async function main() { async function main() {
const email = process.env.EMAIL const email = process.env.OPENAI_EMAIL
const password = process.env.PASSWORD const password = process.env.OPENAI_PASSWORD
const authInfo = await getOpenAIAuth({ const authInfo = await getOpenAIAuth({
email, email,
......
...@@ -52,7 +52,7 @@ to obtain your `clearanceToken`. ...@@ -52,7 +52,7 @@ to obtain your `clearanceToken`.
#### Defined in #### Defined in
[src/chatgpt-api.ts:45](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/chatgpt-api.ts#L45) [src/chatgpt-api.ts:45](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/chatgpt-api.ts#L45)
## Accessors ## Accessors
...@@ -68,7 +68,7 @@ Gets the current Cloudflare clearance token (`cf_clearance` cookie value). ...@@ -68,7 +68,7 @@ Gets the current Cloudflare clearance token (`cf_clearance` cookie value).
#### Defined in #### Defined in
[src/chatgpt-api.ts:136](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/chatgpt-api.ts#L136) [src/chatgpt-api.ts:136](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/chatgpt-api.ts#L136)
___ ___
...@@ -84,7 +84,7 @@ Gets the current session token. ...@@ -84,7 +84,7 @@ Gets the current session token.
#### Defined in #### Defined in
[src/chatgpt-api.ts:131](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/chatgpt-api.ts#L131) [src/chatgpt-api.ts:131](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/chatgpt-api.ts#L131)
___ ___
...@@ -100,7 +100,7 @@ Gets the currently signed-in user, if authenticated, `null` otherwise. ...@@ -100,7 +100,7 @@ Gets the currently signed-in user, if authenticated, `null` otherwise.
#### Defined in #### Defined in
[src/chatgpt-api.ts:126](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/chatgpt-api.ts#L126) [src/chatgpt-api.ts:126](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/chatgpt-api.ts#L126)
___ ___
...@@ -116,7 +116,7 @@ Gets the current user agent. ...@@ -116,7 +116,7 @@ Gets the current user agent.
#### Defined in #### Defined in
[src/chatgpt-api.ts:141](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/chatgpt-api.ts#L141) [src/chatgpt-api.ts:141](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/chatgpt-api.ts#L141)
## Methods ## Methods
...@@ -133,7 +133,7 @@ is still valid. ...@@ -133,7 +133,7 @@ is still valid.
#### Defined in #### Defined in
[src/chatgpt-api.ts:319](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/chatgpt-api.ts#L319) [src/chatgpt-api.ts:319](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/chatgpt-api.ts#L319)
___ ___
...@@ -160,7 +160,7 @@ The new conversation instance ...@@ -160,7 +160,7 @@ The new conversation instance
#### Defined in #### Defined in
[src/chatgpt-api.ts:425](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/chatgpt-api.ts#L425) [src/chatgpt-api.ts:425](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/chatgpt-api.ts#L425)
___ ___
...@@ -177,7 +177,7 @@ the token fails. ...@@ -177,7 +177,7 @@ the token fails.
#### Defined in #### Defined in
[src/chatgpt-api.ts:306](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/chatgpt-api.ts#L306) [src/chatgpt-api.ts:306](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/chatgpt-api.ts#L306)
___ ___
...@@ -203,7 +203,7 @@ A valid access token ...@@ -203,7 +203,7 @@ A valid access token
#### Defined in #### Defined in
[src/chatgpt-api.ts:333](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/chatgpt-api.ts#L333) [src/chatgpt-api.ts:333](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/chatgpt-api.ts#L333)
___ ___
...@@ -234,4 +234,4 @@ The response from ChatGPT ...@@ -234,4 +234,4 @@ The response from ChatGPT
#### Defined in #### Defined in
[src/chatgpt-api.ts:166](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/chatgpt-api.ts#L166) [src/chatgpt-api.ts:166](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/chatgpt-api.ts#L166)
...@@ -41,7 +41,7 @@ Creates a new conversation wrapper around the ChatGPT API. ...@@ -41,7 +41,7 @@ Creates a new conversation wrapper around the ChatGPT API.
#### Defined in #### Defined in
[src/chatgpt-conversation.ts:21](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/chatgpt-conversation.ts#L21) [src/chatgpt-conversation.ts:21](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/chatgpt-conversation.ts#L21)
## Properties ## Properties
...@@ -51,7 +51,7 @@ Creates a new conversation wrapper around the ChatGPT API. ...@@ -51,7 +51,7 @@ Creates a new conversation wrapper around the ChatGPT API.
#### Defined in #### Defined in
[src/chatgpt-conversation.ts:10](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/chatgpt-conversation.ts#L10) [src/chatgpt-conversation.ts:10](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/chatgpt-conversation.ts#L10)
___ ___
...@@ -61,7 +61,7 @@ ___ ...@@ -61,7 +61,7 @@ ___
#### Defined in #### Defined in
[src/chatgpt-conversation.ts:11](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/chatgpt-conversation.ts#L11) [src/chatgpt-conversation.ts:11](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/chatgpt-conversation.ts#L11)
___ ___
...@@ -71,7 +71,7 @@ ___ ...@@ -71,7 +71,7 @@ ___
#### Defined in #### Defined in
[src/chatgpt-conversation.ts:12](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/chatgpt-conversation.ts#L12) [src/chatgpt-conversation.ts:12](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/chatgpt-conversation.ts#L12)
## Methods ## Methods
...@@ -104,4 +104,4 @@ The response from ChatGPT ...@@ -104,4 +104,4 @@ The response from ChatGPT
#### Defined in #### Defined in
[src/chatgpt-conversation.ts:48](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/chatgpt-conversation.ts#L48) [src/chatgpt-conversation.ts:48](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/chatgpt-conversation.ts#L48)
...@@ -66,7 +66,7 @@ node_modules/.pnpm/typescript@4.9.3/node_modules/typescript/lib/lib.es2022.error ...@@ -66,7 +66,7 @@ node_modules/.pnpm/typescript@4.9.3/node_modules/typescript/lib/lib.es2022.error
#### Defined in #### Defined in
[src/types.ts:298](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/types.ts#L298) [src/types.ts:298](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/types.ts#L298)
___ ___
...@@ -76,7 +76,7 @@ ___ ...@@ -76,7 +76,7 @@ ___
#### Defined in #### Defined in
[src/types.ts:297](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/types.ts#L297) [src/types.ts:297](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/types.ts#L297)
___ ___
...@@ -86,7 +86,7 @@ ___ ...@@ -86,7 +86,7 @@ ___
#### Defined in #### Defined in
[src/types.ts:295](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/types.ts#L295) [src/types.ts:295](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/types.ts#L295)
___ ___
...@@ -96,4 +96,4 @@ ___ ...@@ -96,4 +96,4 @@ ___
#### Defined in #### Defined in
[src/types.ts:296](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/types.ts#L296) [src/types.ts:296](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/types.ts#L296)
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
#### Defined in #### Defined in
[src/types.ts:109](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/types.ts#L109) [src/types.ts:109](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/types.ts#L109)
___ ___
...@@ -61,7 +61,7 @@ ___ ...@@ -61,7 +61,7 @@ ___
#### Defined in #### Defined in
[src/types.ts:1](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/types.ts#L1) [src/types.ts:1](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/types.ts#L1)
___ ___
...@@ -83,7 +83,7 @@ https://chat.openapi.com/backend-api/conversation ...@@ -83,7 +83,7 @@ https://chat.openapi.com/backend-api/conversation
#### Defined in #### Defined in
[src/types.ts:134](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/types.ts#L134) [src/types.ts:134](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/types.ts#L134)
___ ___
...@@ -101,7 +101,7 @@ ___ ...@@ -101,7 +101,7 @@ ___
#### Defined in #### Defined in
[src/types.ts:251](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/types.ts#L251) [src/types.ts:251](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/types.ts#L251)
___ ___
...@@ -126,7 +126,7 @@ ___ ...@@ -126,7 +126,7 @@ ___
#### Defined in #### Defined in
[src/types.ts:257](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/types.ts#L257) [src/types.ts:257](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/types.ts#L257)
___ ___
...@@ -136,7 +136,7 @@ ___ ...@@ -136,7 +136,7 @@ ___
#### Defined in #### Defined in
[src/types.ts:276](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/types.ts#L276) [src/types.ts:276](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/types.ts#L276)
___ ___
...@@ -153,7 +153,7 @@ ___ ...@@ -153,7 +153,7 @@ ___
#### Defined in #### Defined in
[src/types.ts:270](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/types.ts#L270) [src/types.ts:270](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/types.ts#L270)
___ ___
...@@ -175,7 +175,7 @@ https://chat.openapi.com/backend-api/conversation/message_feedback ...@@ -175,7 +175,7 @@ https://chat.openapi.com/backend-api/conversation/message_feedback
#### Defined in #### Defined in
[src/types.ts:193](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/types.ts#L193) [src/types.ts:193](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/types.ts#L193)
___ ___
...@@ -185,7 +185,7 @@ ___ ...@@ -185,7 +185,7 @@ ___
#### Defined in #### Defined in
[src/types.ts:249](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/types.ts#L249) [src/types.ts:249](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/types.ts#L249)
___ ___
...@@ -205,7 +205,7 @@ ___ ...@@ -205,7 +205,7 @@ ___
#### Defined in #### Defined in
[src/types.ts:222](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/types.ts#L222) [src/types.ts:222](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/types.ts#L222)
___ ___
...@@ -215,7 +215,7 @@ ___ ...@@ -215,7 +215,7 @@ ___
#### Defined in #### Defined in
[src/types.ts:220](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/types.ts#L220) [src/types.ts:220](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/types.ts#L220)
___ ___
...@@ -225,7 +225,7 @@ ___ ...@@ -225,7 +225,7 @@ ___
#### Defined in #### Defined in
[src/types.ts:275](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/types.ts#L275) [src/types.ts:275](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/types.ts#L275)
___ ___
...@@ -243,7 +243,7 @@ ___ ...@@ -243,7 +243,7 @@ ___
#### Defined in #### Defined in
[src/types.ts:77](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/types.ts#L77) [src/types.ts:77](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/types.ts#L77)
___ ___
...@@ -261,7 +261,7 @@ https://chat.openapi.com/backend-api/models ...@@ -261,7 +261,7 @@ https://chat.openapi.com/backend-api/models
#### Defined in #### Defined in
[src/types.ts:70](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/types.ts#L70) [src/types.ts:70](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/types.ts#L70)
___ ___
...@@ -280,7 +280,7 @@ https://chat.openapi.com/backend-api/moderations ...@@ -280,7 +280,7 @@ https://chat.openapi.com/backend-api/moderations
#### Defined in #### Defined in
[src/types.ts:97](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/types.ts#L97) [src/types.ts:97](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/types.ts#L97)
___ ___
...@@ -300,7 +300,7 @@ https://chat.openapi.com/backend-api/moderations ...@@ -300,7 +300,7 @@ https://chat.openapi.com/backend-api/moderations
#### Defined in #### Defined in
[src/types.ts:114](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/types.ts#L114) [src/types.ts:114](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/types.ts#L114)
___ ___
...@@ -322,7 +322,7 @@ to authenticate with the unofficial ChatGPT API. ...@@ -322,7 +322,7 @@ to authenticate with the unofficial ChatGPT API.
#### Defined in #### Defined in
[src/openai-auth.ts:17](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/openai-auth.ts#L17) [src/openai-auth.ts:17](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/openai-auth.ts#L17)
___ ___
...@@ -340,7 +340,7 @@ ___ ...@@ -340,7 +340,7 @@ ___
#### Defined in #### Defined in
[src/types.ts:161](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/types.ts#L161) [src/types.ts:161](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/types.ts#L161)
___ ___
...@@ -357,7 +357,7 @@ ___ ...@@ -357,7 +357,7 @@ ___
#### Defined in #### Defined in
[src/types.ts:178](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/types.ts#L178) [src/types.ts:178](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/types.ts#L178)
___ ___
...@@ -367,7 +367,7 @@ ___ ...@@ -367,7 +367,7 @@ ___
#### Defined in #### Defined in
[src/types.ts:3](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/types.ts#L3) [src/types.ts:3](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/types.ts#L3)
___ ___
...@@ -377,7 +377,7 @@ ___ ...@@ -377,7 +377,7 @@ ___
#### Defined in #### Defined in
[src/types.ts:289](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/types.ts#L289) [src/types.ts:289](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/types.ts#L289)
___ ___
...@@ -400,7 +400,7 @@ ___ ...@@ -400,7 +400,7 @@ ___
#### Defined in #### Defined in
[src/types.ts:278](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/types.ts#L278) [src/types.ts:278](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/types.ts#L278)
___ ___
...@@ -421,7 +421,7 @@ https://chat.openapi.com/api/auth/session ...@@ -421,7 +421,7 @@ https://chat.openapi.com/api/auth/session
#### Defined in #### Defined in
[src/types.ts:8](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/types.ts#L8) [src/types.ts:8](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/types.ts#L8)
___ ___
...@@ -443,7 +443,7 @@ ___ ...@@ -443,7 +443,7 @@ ___
#### Defined in #### Defined in
[src/types.ts:30](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/types.ts#L30) [src/types.ts:30](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/types.ts#L30)
## Functions ## Functions
...@@ -467,7 +467,7 @@ recognizes it and blocks access. ...@@ -467,7 +467,7 @@ recognizes it and blocks access.
#### Defined in #### Defined in
[src/openai-auth.ts:127](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/openai-auth.ts#L127) [src/openai-auth.ts:127](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/openai-auth.ts#L127)
___ ___
...@@ -505,7 +505,7 @@ with your updated credentials. ...@@ -505,7 +505,7 @@ with your updated credentials.
#### Defined in #### Defined in
[src/openai-auth.ts:39](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/openai-auth.ts#L39) [src/openai-auth.ts:39](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/openai-auth.ts#L39)
___ ___
...@@ -525,4 +525,4 @@ ___ ...@@ -525,4 +525,4 @@ ___
#### Defined in #### Defined in
[src/utils.ts:4](https://github.com/transitive-bullshit/chatgpt-api/blob/a48c177/src/utils.ts#L4) [src/utils.ts:4](https://github.com/transitive-bullshit/chatgpt-api/blob/c257286/src/utils.ts#L4)
chatgpt / [Exports](modules.md) chatgpt / [Exports](modules.md)
# Update December 12, 2022 # Update December 12, 2022 <!-- omit in toc -->
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 <a href="https://twitter.com/transitive_bs">follow 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. Lastly, 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.
Thanks && cheers, Thanks && cheers,
Travis Travis
...@@ -27,18 +27,17 @@ Travis ...@@ -27,18 +27,17 @@ Travis
[![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) [![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)
- [Update December 12, 2022](#update-december-12-2022) - [Intro](#intro)
- [Intro](#intro) - [Install](#install)
- [Install](#install) - [Usage](#usage)
- [Usage](#usage) - [Docs](#docs)
- [Docs](#docs) - [Demos](#demos)
- [Demos](#demos) - [Authentication](#authentication)
- [Authentication](#authentication) - [Restrictions](#restrictions)
- [Restrictions](#restrictions) - [Projects](#projects)
- [Projects](#projects) - [Compatibility](#compatibility)
- [Compatibility](#compatibility) - [Credits](#credits)
- [Credits](#credits) - [License](#license)
- [License](#license)
## Intro ## Intro
...@@ -60,11 +59,10 @@ npm install chatgpt puppeteer ...@@ -60,11 +59,10 @@ npm install chatgpt puppeteer
import { ChatGPTAPI, getOpenAIAuth } from 'chatgpt' import { ChatGPTAPI, getOpenAIAuth } from 'chatgpt'
async function example() { async function example() {
// uses puppeteer to bypass cloudflare (headful because you may have to solve // use puppeteer to bypass cloudflare (headful because of captchas)
// a captcha)
const openAIAuth = await getOpenAIAuth({ const openAIAuth = await getOpenAIAuth({
email: process.env.EMAIL, email: process.env.OPENAI_EMAIL,
password: process.env.EMAIL password: process.env.OPENAI_PASSWORD
}) })
const api = new ChatGPTAPI({ ...openAIAuth }) const api = new ChatGPTAPI({ ...openAIAuth })
...@@ -125,8 +123,8 @@ async function example() { ...@@ -125,8 +123,8 @@ async function example() {
const { ChatGPTAPI, getOpenAIAuth } = await import('chatgpt') const { ChatGPTAPI, getOpenAIAuth } = await import('chatgpt')
const openAIAuth = await getOpenAIAuth({ const openAIAuth = await getOpenAIAuth({
email: process.env.EMAIL, email: process.env.OPENAI_EMAIL,
password: process.env.EMAIL password: process.env.OPENAI_PASSWORD
}) })
const api = new ChatGPTAPI({ ...openAIAuth }) const api = new ChatGPTAPI({ ...openAIAuth })
...@@ -149,18 +147,18 @@ To run the included demos: ...@@ -149,18 +147,18 @@ To run the included demos:
1. clone repo 1. clone repo
2. install node deps 2. install node deps
3. set `EMAIL` and `PASSWORD` in .env 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:
![ChatGPT cookies](./media/session-token.png) ![ChatGPT cookies](./media/session-token.png)
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/) 🔥
## License ## License
......
...@@ -31,7 +31,7 @@ Travis ...@@ -31,7 +31,7 @@ Travis
- [Docs](#docs) - [Docs](#docs)
- [Demos](#demos) - [Demos](#demos)
- [Authentication](#authentication) - [Authentication](#authentication)
- [Restrictions](#restrictions) - [Restrictions](#restrictions)
- [Projects](#projects) - [Projects](#projects)
- [Compatibility](#compatibility) - [Compatibility](#compatibility)
- [Credits](#credits) - [Credits](#credits)
...@@ -59,8 +59,8 @@ import { ChatGPTAPI, getOpenAIAuth } from 'chatgpt' ...@@ -59,8 +59,8 @@ import { ChatGPTAPI, getOpenAIAuth } from 'chatgpt'
async function example() { async function example() {
// use puppeteer to bypass cloudflare (headful because of captchas) // use puppeteer to bypass cloudflare (headful because of captchas)
const openAIAuth = await getOpenAIAuth({ const openAIAuth = await getOpenAIAuth({
email: process.env.EMAIL, email: process.env.OPENAI_EMAIL,
password: process.env.EMAIL password: process.env.OPENAI_PASSWORD
}) })
const api = new ChatGPTAPI({ ...openAIAuth }) const api = new ChatGPTAPI({ ...openAIAuth })
...@@ -121,8 +121,8 @@ async function example() { ...@@ -121,8 +121,8 @@ async function example() {
const { ChatGPTAPI, getOpenAIAuth } = await import('chatgpt') const { ChatGPTAPI, getOpenAIAuth } = await import('chatgpt')
const openAIAuth = await getOpenAIAuth({ const openAIAuth = await getOpenAIAuth({
email: process.env.EMAIL, email: process.env.OPENAI_EMAIL,
password: process.env.EMAIL password: process.env.OPENAI_PASSWORD
}) })
const api = new ChatGPTAPI({ ...openAIAuth }) const api = new ChatGPTAPI({ ...openAIAuth })
...@@ -145,18 +145,18 @@ To run the included demos: ...@@ -145,18 +145,18 @@ To run the included demos:
1. clone repo 1. clone repo
2. install node deps 2. install node deps
3. set `EMAIL` and `PASSWORD` in .env 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
...@@ -189,9 +189,9 @@ Pass `sessionToken`, `clearanceToken`, and `userAgent` to the `ChatGPTAPI` const ...@@ -189,9 +189,9 @@ Pass `sessionToken`, `clearanceToken`, and `userAgent` to the `ChatGPTAPI` const
> **Note** > **Note**
> This package will switch to using the official API once it's released, which will make this process much simpler. > This package will switch to using the official API once it's released, which will make this process much simpler.
#### Restrictions ### Restrictions
**Please read these carefully** **Please read carefully**
- You must use `node >= 18` at the moment. I'm using `v19.2.0` in my testing. - You must use `node >= 18` at the moment. I'm using `v19.2.0` in my testing.
- Cloudflare `cf_clearance` **tokens expire after 2 hours**, so right now we recommend that you refresh your `cf_clearance` token every hour or so. - Cloudflare `cf_clearance` **tokens expire after 2 hours**, so right now we recommend that you refresh your `cf_clearance` token every hour or so.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment