Giter Club home page Giter Club logo

chatgpt.net's Introduction

Update 01-FEB-2023

We released a package to use ChatGPT using official OpenAI API without rate limits for free [Click Here]

For support join [Discord]

ChatGPT.Net - Unofficial API client for ChatGPT [Discord]

Other versions [NodeJS Version][Python Version]

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) .

chatgpt.net's People

Contributors

pawanosman avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.