AurelsOpenAIClient 1.1.0
See the version list below for details.
dotnet add package AurelsOpenAIClient --version 1.1.0
NuGet\Install-Package AurelsOpenAIClient -Version 1.1.0
<PackageReference Include="AurelsOpenAIClient" Version="1.1.0" />
<PackageVersion Include="AurelsOpenAIClient" Version="1.1.0" />
<PackageReference Include="AurelsOpenAIClient" />
paket add AurelsOpenAIClient --version 1.1.0
#r "nuget: AurelsOpenAIClient, 1.1.0"
#:package AurelsOpenAIClient@1.1.0
#addin nuget:?package=AurelsOpenAIClient&version=1.1.0
#tool nuget:?package=AurelsOpenAIClient&version=1.1.0
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.
Links
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 | Versions 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. |
-
.NETStandard 2.0
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.