AurelsOpenAIClient 1.1.0

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

AurelsOpenAIClient

Version: 1.1.0

AurelsOpenAIClient is a simple .NET library for integrating OpenAI APIs into your applications. It supports various functionalities such as Chat Completion, Speech-to-Text, Text-to-Speech, and Translation. All you need is an OpenAI API key.



Features

  • Models: List all the available models by OpenAI
  • Chat Completion: Interact with OpenAI's chat models like gpt-5-chat-latest, gpt-4o, gpt-4o-mini,gpt-3.5-turbo, and more.
  • Speech-to-Text: Convert audio files into text using OpenAI's whisper-1 model.
  • Text-to-Speech: Generate speech from text with customizable voice and speed.
  • Translation: Translate audio files into English using OpenAI's whisper-1 model.

Check out my Audio library if you want to record and play audio

Nuget Package - AurelsAudioLibrary


Installation

Add the AurelsOpenAIClient library to your project using CLI or via NuGet Package Manager.

dotnet add package AurelsOpenAIClient --version 1.1.0

Ensure you have a valid OpenAI API key to use the services! You can top up your OpenAI credit with as little as 5 USD OpenAI Billing


Models

var models = new Models("YOUR-OPENAI-API-KEY");
string availableModels = await models.GetModels();

Chat Completion

The ChatCompletion class facilitates interaction with OpenAI's chat models, allowing for customization of parameters to suit your preferences. You have the ability to define the system role, which influences the model's behavior, specify keywords to exclude question and answer pairs that are not needed. The request includes previous question-and-answer pairs tailored to your requirements. Additionally, you can manually adjust previous messages or modify the parameters, even the model as needed.

var chatClient = new ChatCompletions("YOUR-OPENAI-API-KEY");
// SendChat method has 4 method overloads. Use the one that suits your needs.

string response = await chatClient.SendChat("What is the meaning of life?");

// In the example below with the second parameter, it will remember previous 5 Q&As
string response = await chatClient.SendChat(input, numberOfPreviousQA: 5);

// In this example the messages array will contain only the Q&A pairs that are related to the second parameter.
// Only those Q&A pairs will be in the messages array that contained "nvidia" or "tsm". It is case insensitive.
string response = await chatClient.SendChat(input, keywords: new List<string>{"Nvidia", "TSM" } );

// If you want to manually assamble all the parameters
string response = await chatClient.SendChatAdvanced(chatCompletetionParameters: allParameters);


// All the important parameters can be modified:

chatClient.SetEndpoint("https://api.openai.com/v1/chat/completions");
chatClient.SetModel("gpt-4o-mini");
chatClient.SetMaxTokens(5000);
chatClient.SetSystemRole("You are a professional accountant, and lawyer");
chatClient.SetTemperature(0.7);
chatClient.ClearPreviousQuestionAndAnswerPairs();

// You have the ability to get the whole response, not just the string response

ChatResponse chatResponse = chatClient.GetFullChatResponse();

// Use these functions if you would like to know more additional information of the request and response

int tokensTotal = chatClient.GetTotalTokens();
int tokensPromt = chatClient.GetPromtTokens();
int tokensCompletion = chatClient.GetCompletionTokens();

string jsonRequest = chatClient.GetJsonRequest();
string jsonResponse = chatClient.GetJsonResponse();
string responseTime = chatClient.GetResponseTimeMs();


Text-to-Speech

The TextToSpeech class generates speech from text. You can customize the voice, speed, and output file.

var textToSpeech = new TextToSpeech("YOUR-OPENAI-API-KEY",);
textToSpeech.SetFilePath("Speech.mp3"); // Optional

// returns the path to the generated audiofile.
string response = await textToSpeech.GetResponse(text: "You will hear this sentence!");


Speech-to-Text

The SpeechToText class converts audio files into text. It uses the gpt-4o-transcribe model by default.

var speechToText = new SpeechToText("YOUR-OPENAI-API-KEY");
// string speech variable contains the transcribed text
string speech = await speechToText.Transcribe("RecordedVoice.mp3");

Create translation

The Translate class translates audio files into English. It uses the whisper-1 model by default.

var translate = new Translate("YOUR-OPENAI-API-KEY");
// string englishText variable contains the translated text
string englishText = await Translate.GetResponse("RecordedForeignAudio.mp3");

Image generation

WIP. Coming soon!


License

This library is licensed under the MIT License. See the LICENSE file for details.


Contributing

Contributions are welcome! Feel free to submit issues or pull requests on the AurelsOpenAIClient GitHub repository

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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.

Version Downloads Last Updated
1.1.1 3 9/14/2025
1.1.0 56 9/12/2025
1.0.9 115 9/10/2025
1.0.8 175 9/4/2024
1.0.7 137 9/4/2024
1.0.6 151 8/23/2024
1.0.5 153 8/23/2024
1.0.4 146 8/23/2024
1.0.3 161 8/22/2024
1.0.2 144 8/22/2024
1.0.1 151 8/22/2024
1.0.0 154 8/22/2024