chatgpt-api-pool
v0.6.1
Published
Build your own ChatGPT with a request pool.
Downloads
13
Readme
ChatGPT API Pool
Build your own ChatGPT with a request pool.
NOTICE: due to
chatgpt
dependency does not supportCJS
, so this library does not work properly inCJS
environment, use it on your own risk, recommend to useESM
.Use
gpt-3.5-turbo
Usage
const API_KEYS = ['...', '...']
const EMAIL_CONFIG = {
// Here is a documentation about QQ email:https://www.ujcms.com/documentation/351.html
serverConfig: {
host: 'smtp.xx.com',
port: 465,
secure: true,
auth: {
user: 'xxx',
pass: 'xxx'
}
},
targetEmail: '[email protected]'
}
// EMAIL_CONFIG is optional, to provide email notification when key is exhausted
const requestPool = new RequestPool(API_KEYS, EMAIL_CONFIG)
const response: {
success: boolean
message: ChatMessage /* from chatgpt library */
error: ErrorType
} = await requestPool.sendMessage(q, options) // options, see https://github.com/transitive-bullshit/chatgpt-api/blob/main/src/types.ts#L5-L15
ErrorType
enum ErrorType {
NO_VALID_KEYS = 'no_valid_keys',
}