ChatGPT.Net 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package ChatGPT.Net --version 1.0.1
NuGet\Install-Package ChatGPT.Net -Version 1.0.1
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.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ChatGPT.Net --version 1.0.1
#r "nuget: ChatGPT.Net, 1.0.1"
#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.0.1

// Install ChatGPT.Net as a Cake Tool
#tool nuget:?package=ChatGPT.Net&version=1.0.1

ChatGPT.Net - Unoficial API client for ChatGPT

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

  • Automatic login to ChatGPT account (Microsoft accounts or SessionToken)
  • Bypasses Cloudflare protection
  • Bypasses fake ratelimit protection
  • Saves cookies to allow the application to restart without requiring a login
  • Provides a simple API for use in other applications
  • Can reset conversation or create multiple conversations in the same time.
  • Auto refresh ChatGPT access token.
  • Auto refresh Cloudflare cf_clearance cookie.

Todo

  • Implement login with Google and email
  • Allow the addition of proxies

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();
await chatGpt.WaitForReady();
var chatGptClient = await chatGpt.CreateClient(new ChatGptClientConfig
{
    SessionToken = "eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2......."
});
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......."
});
var response2 = await chatGptClient2 .Ask("What is the weather like today?");
Console.WriteLine(response2);

In the above code, we first create a new ChatGpt object and wait for it to be ready. Then, we create a new ChatGptClient using the CreateClient method, passing in a ChatGptClientConfig object containing the session token. Finally, we use the Ask method of the ChatGptClient to send a query to the ChatGPT service and print the response.

Note

you need Xvfb to run it in linux server "without display", use the commands below to insstall it and configure a virtual display (Ubuntu Server)

  1. install using this command
sudo apt-get install xvfb
  1. Create a virtual display:
Xvfb :99 -screen 0 1280x1024x24 &
  1. Run the project with this command:
export DISPLAY=:99; ./ChatGPT.Net'

Projects with this package

  1. ChatGPT Unofficial free API without Authentication Click Here
  2. Talk with ChatGPT with +130 Languages [Website] Click Here
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

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0 26,763 4/1/2023
1.1.5 4,560 1/28/2023
1.1.4 1,441 1/21/2023
1.1.3 1,376 1/16/2023
1.1.2 1,794 1/7/2023
1.1.1 1,088 1/6/2023
1.1.0 1,195 12/30/2022
1.0.3 1,148 12/21/2022
1.0.2 1,050 12/21/2022
1.0.1 1,095 12/21/2022
1.0.0 1,243 12/19/2022