1.6.0 • Published 1 year ago

unofficial-chatgpt-api v1.6.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

unofficial-chatgpt-api

version downloads MIT License

Getting Started

Installation

To use ChatGPT in your application, run:

npm i unofficial-chatgpt-api
# or `yarn add unofficial-chatgpt-api`
# or `pnpm i unofficial-chatgpt-api`

Configuration

// dual token
const { ChatGPTClient } = require('unofficial-chatgpt-api');
const gpt = new ChatGPTClient({
  clearanceToken: '<--BOT_CLEARANCE_TOKEN-->',
  sessionToken0: '<--SESSION_TOKEN_0-->',
  sessionToken1: '<--SESSION_TOKEN_1-->',
});
// single token
const { ChatGPTClient } = require('unofficial-chatgpt-api');
const gpt = new ChatGPTClient({
  clearanceToken: '<--BOT_CLEARANCE_TOKEN-->',
  sessionToken0: '<--SESSION_TOKEN-->',
});

Auto-refresh

Library manages auto-refreshing tokens.

Dual tokens

Some accounts require dual tokens:

  1. Visit: https://chat.openai.com/chat
  2. Open devtools in chrome: visit the application tab
  3. Click on cookies in the left under storage, click on the chat.openai.com domain
  4. Copy the value of the first cookie and paste it in the client (Name: __Secure-next-auth.session-token.0)
  5. Copy the value of the second cookie and paste it in the client (Name: __Secure-next-auth.session-token.1)

Single token

Some accounts require single token:

  1. Visit: https://chat.openai.com/chat
  2. Open devtools in chrome: visit the application tab
  3. Click on cookies in the left under storage, click on the chat.openai.com domain
  4. Copy the value of the first cookie and paste it in the client (Name: __Secure-next-auth.session-token)

Chatting

const convo = await gpt.startConversation();
const m1 = await convo.chat('show me some javascript code:');

const m2 = await convo.chat('who created you?');
console.log(m2.message.content.parts);

Multiple conversations

const convo1 = await gpt.startConversation();
const convo2 = await gpt.startConversation();

const m1 = await convo1.chat('show me some javascript code:');
const m2 = await convo2.chat('who created you?');
console.log(m2.message.content.parts);

Reset conversation (thread)

convo.reset();
1.6.0

1 year ago

1.5.2

1 year ago

1.5.1

1 year ago

1.5.0

1 year ago

1.4.4

1 year ago

1.4.3

1 year ago

1.4.2

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.5

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago