chatgpt / Exports / ChatGPTAPIBrowser
-
↳
ChatGPTAPIBrowser
- _onRequest
- _onResponse
- closeSession
- getIsAuthenticated
- initSession
- refreshSession
- resetSession
- resetThread
- sendMessage
• new ChatGPTAPIBrowser(opts
)
Creates a new client for automating the ChatGPT webapp.
Name | Type | Description |
---|---|---|
opts |
Object |
- |
opts.captchaToken? |
string |
Default Value undefined * |
opts.debug? |
boolean |
Default Value false * |
opts.email |
string |
- |
opts.executablePath? |
string |
Default Value undefined * |
opts.isGoogleLogin? |
boolean |
Default Value false * |
opts.isMicrosoftLogin? |
boolean |
Default Value false * |
opts.isProAccount? |
boolean |
Default Value false * |
opts.markdown? |
boolean |
Default Value true * |
opts.minimize? |
boolean |
Default Value true * |
opts.nopechaKey? |
string |
Default Value undefined * |
opts.password |
string |
- |
opts.proxyServer? |
string |
Default Value undefined * |
opts.userDataDir? |
string |
Default Value random directory with email as prefix * |
• get
isChatPage(): boolean
boolean
src/chatgpt-api-browser.ts:640
▸ _onRequest(request
): void
Name | Type |
---|---|
request |
HTTPRequest |
void
src/chatgpt-api-browser.ts:255
▸ _onResponse(response
): Promise
<void
>
Name | Type |
---|---|
response |
HTTPResponse |
Promise
<void
>
src/chatgpt-api-browser.ts:292
▸ closeSession(): Promise
<void
>
Closes the active session.
Throws
An error if it fails.
Promise
<void
>
src/chatgpt-api-browser.ts:586
▸ getIsAuthenticated(): Promise
<boolean
>
Promise
<boolean
>
true
if the client is authenticated with a valid session or false
otherwise.
AChatGPTAPI.getIsAuthenticated
src/chatgpt-api-browser.ts:425
▸ initSession(): Promise
<void
>
Performs any async initialization work required to ensure that this API is properly authenticated.
Throws
An error if the session failed to initialize properly.
Promise
<void
>
src/chatgpt-api-browser.ts:133
▸ refreshSession(): Promise
<void
>
Attempts to handle 403 errors by refreshing the page.
Promise
<void
>
src/chatgpt-api-browser.ts:367
▸ resetSession(): Promise
<void
>
Attempts to handle 401 errors by re-authenticating.
Promise
<void
>
src/chatgpt-api-browser.ts:348
▸ resetThread(): Promise
<void
>
Promise
<void
>
src/chatgpt-api-browser.ts:578
▸ sendMessage(message
, opts?
): Promise
<ChatResponse
>
Sends a message to ChatGPT, waits for the response to resolve, and returns the response.
If you want to receive a stream of partial responses, use opts.onProgress
.
Name | Type | Description |
---|---|---|
message |
string |
The prompt message to send |
opts |
SendMessageOptions |
- |
Promise
<ChatResponse
>
The response from ChatGPT, including conversationId
, messageId
, and
the response
text.