Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
chatgpt-io
Advanced tools
Readme
A simple NPM package for interacting with the ChatGPT without a browser.
import chatGPT from "chatgpt-io";
let bot = new chatGPT("<SESSION_TOKEN>");
let response = await bot.ask("Hello?");
console.log(response);
The new method operates without a browser by utilizing a server that has implemented bypass methods to function as a proxy. The library sends requests to the server, which then redirects the request to ChatGPT while bypassing Cloudflare and other bot detection measures. The server then returns the ChatGPT response, ensuring that the method remains effective even if ChatGPT implements changes to prevent bot usage. Our servers are continuously updated to maintain their bypass capabilities.
To install the package, run the following command:
npm install chatgpt-io
To use the package, require it in your code and create a new instance of the ChatGPT
class, passing in your ChatGPT API session token as an argument.
import ChatGPT from "chatgpt-io";
let bot = new ChatGPT("<SESSION_TOKEN>");
// set the model manually, for plus accounts
let bot = new ChatGPT("<SESSION_TOKEN>", {
model: "text-davinci-002-render-sha",
});
Then you can send a message to the API using the ask
method. This method takes a message string as its first argument and an optional conversation ID as its second argument. If a conversation ID is not provided, the default conversation will be used.
let response = await bot.ask("Hello?");
console.log(response);
let response2 = await bot.ask("Hello?", "any-unique-string");
console.log(response2);
The ask
method returns a promise that resolves with the API's response to the message.
ChatGPT
classconstructor(sessionToken: string, options: object)
Creates a new instance of the ChatGPT
class.
sessionToken
(string): Your ChatGPT API session token.options
(object):options = {
name?: string; // name of the instance (default: "chatgpt-io")
logLevel?: LogLevel; // log level (default: LogLevel.Info)
bypassNode?: string; // bypass node url (default: https://api.pawan.krd)
model?: string; // model to use (default: text-davinci-002-render-sha)
configsDir?: string; // directory to save configs (default: ./configs)
saveInterval?: number; // interval to save configs (default: 1000 * 60 * 5)
}
LogLevel = { // log levels
Trace = 0,
Debug = 1,
Info = 2, // default
Warning = 3,
Error = 4
}
ask(prompt: string, id: string = "default", parentId?: string): Promise<string>
Sends a message to the API and returns a promise that resolves with the API's response.
message
(string): The message to send to the API.conversationId
(string, optional): The ID of the conversation to send the message to. If not provided, the default conversation will be used.parentId
(string, optional): The ID of the parent message. If not provided, the message will not have a parent.askStream(callback: (arg0: string) => void, prompt: string, id: string = "default", parentId?: string): Promise<string>
Sends a message to the API and returns a promise that resolves with the API's response. This method is similar to ask
, but it will call the callback function with the API's response as it is received instead of waiting for the entire response to be received.
callback
(function): The callback function to call with the API's response as it is received.message
(string): The message to send to the API.conversationId
(string, optional): The ID of the conversation to send the message to. If not provided, the default conversation will be used.parentId
(string, optional): The ID of the parent message. If not provided, the message will not have a parent.Here is an example of how to use the chatgpt-io
module to send a message to the API and log the response:
import ChatGPT from "chatgpt-io";
let bot = new ChatGPT("<SESSION_TOKEN>");
// default conversation
let response = await bot.ask("Hello?");
console.log(response);
// specific conversation
let response2 = await bot.ask("Hello?", "any-unique-string");
console.log(response2);
// stream response
await bot.askStream((response) => {
console.log(response);
}, "Hello?");
// stream response with conversation
await bot.askStream(
(response) => {
console.log(response);
},
"Hello?",
"any-unique-string",
);
This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
ChatGPT Client API, Blazing Fast, without using browser
The npm package chatgpt-io receives a total of 16 weekly downloads. As such, chatgpt-io popularity was classified as not popular.
We found that chatgpt-io demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.