ChatGPT.Net
1.0.0
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
<PackageReference Include="ChatGPT.Net" Version="1.0.0" />
<PackageVersion Include="ChatGPT.Net" Version="1.0.0" />
<PackageReference Include="ChatGPT.Net" />
paket add ChatGPT.Net --version 1.0.0
#r "nuget: ChatGPT.Net, 1.0.0"
#:package ChatGPT.Net@1.0.0
#addin nuget:?package=ChatGPT.Net&version=1.0.0
#tool nuget:?package=ChatGPT.Net&version=1.0.0
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. 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. |
-
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 (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)
|