ChatGPT.Net 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package ChatGPT.Net --version 1.0.0
                    
NuGet\Install-Package ChatGPT.Net -Version 1.0.0
                    
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.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ChatGPT.Net" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="ChatGPT.Net" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ChatGPT.Net --version 1.0.0
                    
#r "nuget: ChatGPT.Net, 1.0.0"
                    
#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.
#:package ChatGPT.Net@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ChatGPT.Net&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=ChatGPT.Net&version=1.0.0
                    
Install as a Cake Tool

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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on ChatGPT.Net:

Package Downloads
OpenRP.Framework

OpenRP.Framework is the open source library of Open Roleplay, an ambitious SA-MP roleplay gamemode developed for open.mp (Open Multiplayer, a multiplayer mod for GTA San Andreas) using the SampSharp framework.

PiscesMetadata.Roleplay

Roleplay Framework to develop San Andreas Gamemodes.

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 118,555 4/1/2023
1.1.5 4,919 1/28/2023
1.1.4 1,623 1/21/2023
1.1.3 1,523 1/16/2023
1.1.2 1,947 1/7/2023
1.1.1 1,276 1/6/2023
1.1.0 1,408 12/30/2022
1.0.3 1,299 12/21/2022
1.0.2 1,226 12/21/2022
1.0.1 1,258 12/21/2022
1.0.0 1,511 12/19/2022