ChatGPT.Net 1.1.4

There is a newer version of this package available.
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                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ChatGPT.Net" Version="1.1.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ChatGPT.Net --version 1.1.4                
#r "nuget: ChatGPT.Net, 1.1.4"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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]

Nuget Package Nuget Package GitHub issues GitHub forks GitHub stars GitHub license Discord server

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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)
Version Downloads Last updated
2.0.0 58,294 4/1/2023
1.1.5 4,679 1/28/2023
1.1.4 1,472 1/21/2023
1.1.3 1,402 1/16/2023
1.1.2 1,823 1/7/2023
1.1.1 1,135 1/6/2023
1.1.0 1,250 12/30/2022
1.0.3 1,178 12/21/2022
1.0.2 1,085 12/21/2022
1.0.1 1,124 12/21/2022
1.0.0 1,293 12/19/2022