ChatGPT.Net
1.1.4
See the version list below for details.
dotnet add package ChatGPT.Net --version 1.1.4
NuGet\Install-Package ChatGPT.Net -Version 1.1.4
<PackageReference Include="ChatGPT.Net" Version="1.1.4" />
paket add ChatGPT.Net --version 1.1.4
#r "nuget: ChatGPT.Net, 1.1.4"
// Install ChatGPT.Net as a Cake Addin #addin nuget:?package=ChatGPT.Net&version=1.1.4 // Install ChatGPT.Net as a Cake Tool #tool nuget:?package=ChatGPT.Net&version=1.1.4
Update 21-JAN-2023
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);
Features
- 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.
How the new method working without a browser?
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.
Getting Started
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
Usage
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.
Documentation for the ChatGptConfig
class:
Properties
UseCache
(bool)
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.
SaveCache
(bool)
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.
Documentation for the ChatGptClientConfig
class:
Properties
SessionToken
(string)
This property specifies the session token for the ChatGPT account.
AccountType
(AccountType)
This property specifies the ChatGPT account type (free or pro) .
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Newtonsoft.Json (>= 13.0.2)
- SocketIOClient (>= 3.0.7)
-
net7.0
- Newtonsoft.Json (>= 13.0.2)
- SocketIOClient (>= 3.0.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on ChatGPT.Net:
Repository | Stars |
---|---|
VRCWizard/TTS-Voice-Wizard
Speech to Text to Speech. Song now playing. Sends text as OSC messages to VRChat to display on avatar. (STTTS) (Speech to TTS) (VRC STT System) (VTuber TTS)
|