We have implemented support for pro accounts. [NodeJS Version][Python Version]
For support join [Discord]
ChatGPT.Net - Unofficial API client for ChatGPT [Discord]
The ChatGPT.Net Unofficial .Net API for ChatGPT is a C# library that allows developers to access ChatGPT, a chat-based language model. With this API, developers can send queries to ChatGPT and receive responses in real-time, making it easy to integrate ChatGPT into their own applications.
using ChatGPT.Net;
var chatGpt = new ChatGpt();
await chatGpt.WaitForReady();
var chatGptClient = await chatGpt.CreateClient(new ChatGptClientConfig
{
SessionToken = "eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2......."
});
var response = await chatGptClient.Ask("What is the weather like today?");
Console.WriteLine(response);
- New method without using a browser.
- Automatic login to ChatGPT using SessionToken.
- Bypass of Cloudflare protection and fake rate limit protection.
- Functionality to reset conversations or create multiple conversations.
- Automatic refresh of ChatGPT access token.
- Cache system enabled by default, with cached data saved to cache.json to reduce requests to ChatGPT endpoint and reduce rate limiting.
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 ChatGPT.Net, run the following command in the Package Manager Console:
Install-Package ChatGPT.Net
Alternatively, you can install it using the .NET Core command-line interface:
dotnet add package ChatGPT.Net
Here is a sample code showing how to use ChatGPT.Net:
using ChatGPT.Net;
var chatGpt = new ChatGpt(new ChatGptConfig
{
UseCache = true
});
await chatGpt.WaitForReady();
var chatGptClient = await chatGpt.CreateClient(new ChatGptClientConfig
{
SessionToken = "eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2.......",
AccountType = AccountType.Free
});
var conversationId = "a-unique-string-id";
var response = await chatGptClient.Ask("What is the weather like today?", conversationId);
Console.WriteLine(response);
await chatGptClient.ResetConversation(conversationId);
var chatGptClient2 = await chatGpt.CreateClient(new ChatGptClientConfig
{
SessionToken = "eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2.......",
AccountType = AccountType.Pro
});
var response2 = await chatGptClient2 .Ask("What is the weather like today?");
Console.WriteLine(response2);
The code above demonstrates how to use the ChatGPT.Net library to create and interact with multiple ChatGPT clients and conversations simultaneously.
The ChatGpt
class is used to initialize the ChatGPT library and wait for it to be ready. The CreateClient
method is then called to create a new client using a specified configuration.
Once the client is created, the Ask
method can be called to send a message to ChatGPT and receive a response. The conversationId
parameter is optional and can be used to specify the conversation that the message should be sent to. If no conversation ID is provided, a default conversation ID will be used.
The ResetConversation
method can be used to reset a specific conversation associated with a particular client. This allows the client to be used to start a new conversation with ChatGPT as if it were the first time the client was used.
Multiple ChatGPT clients can be created and used to manage multiple accounts simultaneously. It is important to note that the SessionToken
in the configuration must be a valid token in order to successfully authenticate and use the ChatGPT service.
If true
, the client will check for a cache of responses before generating a new one. If false
, the client will always generate a new response.
If true
, the client will save responses to a cache file (cache.json
) in the working directory after generating them. If false
, the client will not save responses to the cache.
This property specifies the session token for the ChatGPT account.
This property specifies the ChatGPT account type (free or pro) .