kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
chore: update docs
rodzic
8c46f0b64f
commit
a64cd17af7
|
@ -36,7 +36,7 @@ Creates a new client wrapper around the unofficial ChatGPT REST API.
|
|||
|
||||
#### Defined in
|
||||
|
||||
[chatgpt-api.ts:29](https://github.com/transitive-bullshit/chatgpt-api/blob/549e9b4/src/chatgpt-api.ts#L29)
|
||||
[chatgpt-api.ts:31](https://github.com/transitive-bullshit/chatgpt-api/blob/c9cef79/src/chatgpt-api.ts#L31)
|
||||
|
||||
## Methods
|
||||
|
||||
|
@ -50,7 +50,7 @@ Creates a new client wrapper around the unofficial ChatGPT REST API.
|
|||
|
||||
#### Defined in
|
||||
|
||||
[chatgpt-api.ts:72](https://github.com/transitive-bullshit/chatgpt-api/blob/549e9b4/src/chatgpt-api.ts#L72)
|
||||
[chatgpt-api.ts:74](https://github.com/transitive-bullshit/chatgpt-api/blob/c9cef79/src/chatgpt-api.ts#L74)
|
||||
|
||||
___
|
||||
|
||||
|
@ -64,7 +64,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[chatgpt-api.ts:63](https://github.com/transitive-bullshit/chatgpt-api/blob/549e9b4/src/chatgpt-api.ts#L63)
|
||||
[chatgpt-api.ts:65](https://github.com/transitive-bullshit/chatgpt-api/blob/c9cef79/src/chatgpt-api.ts#L65)
|
||||
|
||||
___
|
||||
|
||||
|
@ -78,7 +78,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[chatgpt-api.ts:163](https://github.com/transitive-bullshit/chatgpt-api/blob/549e9b4/src/chatgpt-api.ts#L163)
|
||||
[chatgpt-api.ts:165](https://github.com/transitive-bullshit/chatgpt-api/blob/c9cef79/src/chatgpt-api.ts#L165)
|
||||
|
||||
___
|
||||
|
||||
|
@ -104,4 +104,4 @@ the response.
|
|||
|
||||
#### Defined in
|
||||
|
||||
[chatgpt-api.ts:84](https://github.com/transitive-bullshit/chatgpt-api/blob/549e9b4/src/chatgpt-api.ts#L84)
|
||||
[chatgpt-api.ts:86](https://github.com/transitive-bullshit/chatgpt-api/blob/c9cef79/src/chatgpt-api.ts#L86)
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
#### Defined in
|
||||
|
||||
[types.ts:104](https://github.com/transitive-bullshit/chatgpt-api/blob/549e9b4/src/types.ts#L104)
|
||||
[types.ts:104](https://github.com/transitive-bullshit/chatgpt-api/blob/c9cef79/src/types.ts#L104)
|
||||
|
||||
___
|
||||
|
||||
|
@ -53,7 +53,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[types.ts:1](https://github.com/transitive-bullshit/chatgpt-api/blob/549e9b4/src/types.ts#L1)
|
||||
[types.ts:1](https://github.com/transitive-bullshit/chatgpt-api/blob/c9cef79/src/types.ts#L1)
|
||||
|
||||
___
|
||||
|
||||
|
@ -75,7 +75,7 @@ https://chat.openapi.com/backend-api/conversation
|
|||
|
||||
#### Defined in
|
||||
|
||||
[types.ts:129](https://github.com/transitive-bullshit/chatgpt-api/blob/549e9b4/src/types.ts#L129)
|
||||
[types.ts:129](https://github.com/transitive-bullshit/chatgpt-api/blob/c9cef79/src/types.ts#L129)
|
||||
|
||||
___
|
||||
|
||||
|
@ -93,7 +93,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[types.ts:246](https://github.com/transitive-bullshit/chatgpt-api/blob/549e9b4/src/types.ts#L246)
|
||||
[types.ts:246](https://github.com/transitive-bullshit/chatgpt-api/blob/c9cef79/src/types.ts#L246)
|
||||
|
||||
___
|
||||
|
||||
|
@ -118,7 +118,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[types.ts:252](https://github.com/transitive-bullshit/chatgpt-api/blob/549e9b4/src/types.ts#L252)
|
||||
[types.ts:252](https://github.com/transitive-bullshit/chatgpt-api/blob/c9cef79/src/types.ts#L252)
|
||||
|
||||
___
|
||||
|
||||
|
@ -135,7 +135,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[types.ts:265](https://github.com/transitive-bullshit/chatgpt-api/blob/549e9b4/src/types.ts#L265)
|
||||
[types.ts:265](https://github.com/transitive-bullshit/chatgpt-api/blob/c9cef79/src/types.ts#L265)
|
||||
|
||||
___
|
||||
|
||||
|
@ -157,7 +157,7 @@ https://chat.openapi.com/backend-api/conversation/message_feedback
|
|||
|
||||
#### Defined in
|
||||
|
||||
[types.ts:188](https://github.com/transitive-bullshit/chatgpt-api/blob/549e9b4/src/types.ts#L188)
|
||||
[types.ts:188](https://github.com/transitive-bullshit/chatgpt-api/blob/c9cef79/src/types.ts#L188)
|
||||
|
||||
___
|
||||
|
||||
|
@ -167,7 +167,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[types.ts:244](https://github.com/transitive-bullshit/chatgpt-api/blob/549e9b4/src/types.ts#L244)
|
||||
[types.ts:244](https://github.com/transitive-bullshit/chatgpt-api/blob/c9cef79/src/types.ts#L244)
|
||||
|
||||
___
|
||||
|
||||
|
@ -187,7 +187,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[types.ts:217](https://github.com/transitive-bullshit/chatgpt-api/blob/549e9b4/src/types.ts#L217)
|
||||
[types.ts:217](https://github.com/transitive-bullshit/chatgpt-api/blob/c9cef79/src/types.ts#L217)
|
||||
|
||||
___
|
||||
|
||||
|
@ -197,7 +197,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[types.ts:215](https://github.com/transitive-bullshit/chatgpt-api/blob/549e9b4/src/types.ts#L215)
|
||||
[types.ts:215](https://github.com/transitive-bullshit/chatgpt-api/blob/c9cef79/src/types.ts#L215)
|
||||
|
||||
___
|
||||
|
||||
|
@ -207,7 +207,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[types.ts:270](https://github.com/transitive-bullshit/chatgpt-api/blob/549e9b4/src/types.ts#L270)
|
||||
[types.ts:270](https://github.com/transitive-bullshit/chatgpt-api/blob/c9cef79/src/types.ts#L270)
|
||||
|
||||
___
|
||||
|
||||
|
@ -225,7 +225,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[types.ts:72](https://github.com/transitive-bullshit/chatgpt-api/blob/549e9b4/src/types.ts#L72)
|
||||
[types.ts:72](https://github.com/transitive-bullshit/chatgpt-api/blob/c9cef79/src/types.ts#L72)
|
||||
|
||||
___
|
||||
|
||||
|
@ -243,7 +243,7 @@ https://chat.openapi.com/backend-api/models
|
|||
|
||||
#### Defined in
|
||||
|
||||
[types.ts:65](https://github.com/transitive-bullshit/chatgpt-api/blob/549e9b4/src/types.ts#L65)
|
||||
[types.ts:65](https://github.com/transitive-bullshit/chatgpt-api/blob/c9cef79/src/types.ts#L65)
|
||||
|
||||
___
|
||||
|
||||
|
@ -262,7 +262,7 @@ https://chat.openapi.com/backend-api/moderations
|
|||
|
||||
#### Defined in
|
||||
|
||||
[types.ts:92](https://github.com/transitive-bullshit/chatgpt-api/blob/549e9b4/src/types.ts#L92)
|
||||
[types.ts:92](https://github.com/transitive-bullshit/chatgpt-api/blob/c9cef79/src/types.ts#L92)
|
||||
|
||||
___
|
||||
|
||||
|
@ -282,7 +282,7 @@ https://chat.openapi.com/backend-api/moderations
|
|||
|
||||
#### Defined in
|
||||
|
||||
[types.ts:109](https://github.com/transitive-bullshit/chatgpt-api/blob/549e9b4/src/types.ts#L109)
|
||||
[types.ts:109](https://github.com/transitive-bullshit/chatgpt-api/blob/c9cef79/src/types.ts#L109)
|
||||
|
||||
___
|
||||
|
||||
|
@ -300,7 +300,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[types.ts:156](https://github.com/transitive-bullshit/chatgpt-api/blob/549e9b4/src/types.ts#L156)
|
||||
[types.ts:156](https://github.com/transitive-bullshit/chatgpt-api/blob/c9cef79/src/types.ts#L156)
|
||||
|
||||
___
|
||||
|
||||
|
@ -317,7 +317,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[types.ts:173](https://github.com/transitive-bullshit/chatgpt-api/blob/549e9b4/src/types.ts#L173)
|
||||
[types.ts:173](https://github.com/transitive-bullshit/chatgpt-api/blob/c9cef79/src/types.ts#L173)
|
||||
|
||||
___
|
||||
|
||||
|
@ -327,7 +327,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[types.ts:3](https://github.com/transitive-bullshit/chatgpt-api/blob/549e9b4/src/types.ts#L3)
|
||||
[types.ts:3](https://github.com/transitive-bullshit/chatgpt-api/blob/c9cef79/src/types.ts#L3)
|
||||
|
||||
___
|
||||
|
||||
|
@ -347,7 +347,7 @@ https://chat.openapi.com/api/auth/session
|
|||
|
||||
#### Defined in
|
||||
|
||||
[types.ts:8](https://github.com/transitive-bullshit/chatgpt-api/blob/549e9b4/src/types.ts#L8)
|
||||
[types.ts:8](https://github.com/transitive-bullshit/chatgpt-api/blob/c9cef79/src/types.ts#L8)
|
||||
|
||||
___
|
||||
|
||||
|
@ -369,7 +369,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[types.ts:25](https://github.com/transitive-bullshit/chatgpt-api/blob/549e9b4/src/types.ts#L25)
|
||||
[types.ts:25](https://github.com/transitive-bullshit/chatgpt-api/blob/c9cef79/src/types.ts#L25)
|
||||
|
||||
## Functions
|
||||
|
||||
|
@ -389,4 +389,4 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[utils.ts:4](https://github.com/transitive-bullshit/chatgpt-api/blob/549e9b4/src/utils.ts#L4)
|
||||
[utils.ts:4](https://github.com/transitive-bullshit/chatgpt-api/blob/c9cef79/src/utils.ts#L4)
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
chatgpt / [Exports](modules.md)
|
||||
|
||||
<p align="center">
|
||||
<img alt="Example usage" src="/media/demo.gif">
|
||||
</p>
|
||||
|
||||
# ChatGPT API <!-- omit in toc -->
|
||||
|
||||
> Node.js client for the unofficial [ChatGPT](https://openai.com/blog/chatgpt/) API.
|
||||
|
@ -23,21 +27,23 @@ You can use it to start building projects powered by ChatGPT like chatbots, webs
|
|||
|
||||
## How it works
|
||||
|
||||
This package requires a valid session token from OpenAI's ChatGPT webapp to access it's unofficial REST API.
|
||||
This package requires a valid session token from ChatGPT to access it's unofficial REST API.
|
||||
|
||||
1. Go to https://chat.openai.com/chat and log in or sign up
|
||||
2. Open the dev tools console
|
||||
3. Open `Application` > `Cookies`
|
||||

|
||||
To get a session token:
|
||||
|
||||
1. Go to https://chat.openai.com/chat and log in or sign up.
|
||||
2. Open dev tools.
|
||||
3. Open `Application` > `Cookies`.
|
||||

|
||||
4. Copy the value for `__Secure-next-auth.session-token` and save it to your environment.
|
||||
|
||||
If you want to run the built-in demo,
|
||||
If you want to run the built-in demo, store this value as `SESSION_TOKEN` in a local `.env` file.
|
||||
|
||||
> **Note**
|
||||
> This package will switch to using the official API once it's released.
|
||||
|
||||
> **Note**
|
||||
> Prior to v1.0.0, this package used headless Chromium via [Playwright](https://playwright.dev/) to automate the web UI. Here are the [docs for the initial browser version](https://github.com/transitive-bullshit/chatgpt-api/tree/v0.4.2).
|
||||
> Prior to v1.0.0, this package used a headless browser via [Playwright](https://playwright.dev/) to automate the web UI. Here are the [docs for the initial browser version](https://github.com/transitive-bullshit/chatgpt-api/tree/v0.4.2).
|
||||
|
||||
## Install
|
||||
|
||||
|
@ -55,7 +61,7 @@ pnpm add chatgpt
|
|||
import { ChatGPTAPI } from 'chatgpt'
|
||||
|
||||
async function example() {
|
||||
const api = new ChatGPTAPI()
|
||||
const api = new ChatGPTAPI({ sessionToken: process.env.SESSION_TOKEN })
|
||||
|
||||
// ensure the API is properly authenticated (optional)
|
||||
await api.ensureAuth()
|
||||
|
@ -70,6 +76,15 @@ async function example() {
|
|||
}
|
||||
```
|
||||
|
||||
By default, the response will be formatted as markdown. If you want to work with plaintext only, you can use:
|
||||
|
||||
```ts
|
||||
const api = new ChatGPTAPI({
|
||||
sessionToken: process.env.SESSION_TOKEN,
|
||||
markdown: false
|
||||
})
|
||||
```
|
||||
|
||||
A full [example](./src/example.ts) is included for testing purposes:
|
||||
|
||||
```bash
|
||||
|
@ -93,13 +108,15 @@ All of these awesome projects use the `chatgpt` package. 🤯
|
|||
- [Chrome Extension](https://github.com/gragland/chatgpt-everywhere) ([demo](https://twitter.com/gabe_ragland/status/1599466486422470656))
|
||||
- [VSCode Extension](https://github.com/mpociot/chatgpt-vscode) ([demo](https://twitter.com/marcelpociot/status/1599180144551526400))
|
||||
- [Go Telegram Bot](https://github.com/m1guelpf/chatgpt-telegram)
|
||||
- [Github ProBot](https://github.com/oceanlvr/ChatGPTBot)
|
||||
- [Lovelines.xyz](https://lovelines.xyz)
|
||||
|
||||
If you create a cool integration, feel free to open a PR and add it to the list.
|
||||
|
||||
## Credit
|
||||
|
||||
- Inspired by this [Go module](https://github.com/danielgross/whatsapp-gpt) by [Daniel Gross](https://github.com/danielgross)
|
||||
- Huge thanks to [@RomanHotsiy](https://github.com/RomanHotsiy), [@ElijahPepe](https://github.com/ElijahPepe), [@wong2](https://github.com/wong2), 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)
|
||||
|
||||
## License
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue