OpenAIToolkit 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package OpenAIToolkit --version 1.0.0
                    
NuGet\Install-Package OpenAIToolkit -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="OpenAIToolkit" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OpenAIToolkit" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="OpenAIToolkit" />
                    
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 OpenAIToolkit --version 1.0.0
                    
#r "nuget: OpenAIToolkit, 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 OpenAIToolkit@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=OpenAIToolkit&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=OpenAIToolkit&version=1.0.0
                    
Install as a Cake Tool

OpenAI Toolkit

OpenAI Toolkit is a .NET library designed to offer a simple and intuitive way to interact with the OpenAI API, making it easier to incorporate OpenAI's advanced language models into your .NET applications.

Features

This library comes with a range of features designed to streamline the process of integrating OpenAI's capabilities into your projects, including:

  • Support for OpenAI's Chat Completion API: Directly access one of the most powerful features of the OpenAI API.
  • Easy-to-use Client: A straightforward client interface for making API requests without hassle.
  • Strongly-typed Request and Response DTOs: Ensures type safety and easier handling of data.
  • Comprehensive Error Handling and Logging: Provides detailed insights into the workings and issues for easier debugging.
  • Asynchronous Methods: Support for non-blocking API calls to enhance application performance.
  • Extensible Design: Built with flexibility in mind, allowing for future additions of other OpenAI APIs.

Installation

The OpenAI Toolkit can be seamlessly integrated into your project using either NuGet Package Manager or the .NET CLI.

Via NuGet Package Manager

For those using Visual Studio, the library can be installed directly through the NuGet Package Manager by executing the following command:

Using .NET CLI

Alternatively, the package can be added using the .NET CLI with the command below:

Usage

To begin utilizing the OpenAI Toolkit within your application, you'll need to instantiate the OpenAIClient class with your OpenAI API key and an ILogger instance as demonstrated in the following snippet:

var apiKey = Configuration["OpenAIApiKey"];
var loggerFactory = LoggerFactory.Create(builder => {
    builder.AddConsole(); // Additional logging providers can be configured as needed.
});

var logger = loggerFactory.CreateLogger<OpenAIClient>();
var client = new OpenAIClient(apiKey, logger);

var request = new ChatCompletionRequest {
    Model = "gpt-3.5-turbo",
    Messages = new List<ChatMessage> {
        new ChatMessage { Role = "system", Content = "You are a helpful assistant." },
        new ChatMessage { Role = "user", Content = "Hello! How are you?" }
    }
};
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.