ChatGPT.Net
1.0.1
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
<PackageReference Include="ChatGPT.Net" Version="1.0.1" />
paket add ChatGPT.Net --version 1.0.1
#r "nuget: ChatGPT.Net, 1.0.1"
// 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)
- install using this command
sudo apt-get install xvfb
- Create a virtual display:
Xvfb :99 -screen 0 1280x1024x24 &
- Run the project with this command:
export DISPLAY=:99; ./ChatGPT.Net'
Projects with this package
- ChatGPT Unofficial free API without Authentication Click Here
- Talk with ChatGPT with +130 Languages [Website] Click Here
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
- Microsoft.AspNetCore.Http.Extensions (>= 2.2.0)
- Microsoft.AspNetCore.WebUtilities (>= 2.2.0)
- Microsoft.Net.Http.Headers (>= 2.2.8)
- Microsoft.Playwright (>= 1.28.0)
- Newtonsoft.Json (>= 13.0.2)
-
net7.0
- Microsoft.AspNetCore.Http.Extensions (>= 2.2.0)
- Microsoft.AspNetCore.WebUtilities (>= 2.2.0)
- Microsoft.Net.Http.Headers (>= 2.2.8)
- Microsoft.Playwright (>= 1.28.0)
- Newtonsoft.Json (>= 13.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.