tryAGI.OpenAI
1.1.1
Prefix Reserved
See the version list below for details.
dotnet add package tryAGI.OpenAI --version 1.1.1
NuGet\Install-Package tryAGI.OpenAI -Version 1.1.1
<PackageReference Include="tryAGI.OpenAI" Version="1.1.1" />
<PackageVersion Include="tryAGI.OpenAI" Version="1.1.1" />
<PackageReference Include="tryAGI.OpenAI" />
paket add tryAGI.OpenAI --version 1.1.1
#r "nuget: tryAGI.OpenAI, 1.1.1"
#:package tryAGI.OpenAI@1.1.1
#addin nuget:?package=tryAGI.OpenAI&version=1.1.1
#tool nuget:?package=tryAGI.OpenAI&version=1.1.1
OpenAI
Generated C# SDK based on official OpenAI OpenAPI specification using NSwag
This package includes C# Source Generator which allows you to define functions natively through a C# interface,
and also provides extensions that make it easier to call this interface later.
In addition to easy function implementation and readability,
it generates Args classes, extension methods to easily pass a functions to API,
and extension methods to simply call a function via json and return json.
Currently only System.Text.Json is supported.
Usage
using tryAGI.OpenAI;
public enum Unit
{
Celsius,
Fahrenheit,
}
public class Weather
{
public string Location { get; set; } = string.Empty;
public double Temperature { get; set; }
public Unit Unit { get; set; }
public string Description { get; set; } = string.Empty;
}
[OpenAiFunctions]
public interface IWeatherFunctions
{
[Description("Get the current weather in a given location")]
public Task<Weather> GetCurrentWeatherAsync(
[Description("The city and state, e.g. San Francisco, CA")] string location,
Unit unit = Unit.Celsius,
CancellationToken cancellationToken = default);
}
public class WeatherService : IWeatherFunctions
{
public Task<Weather> GetCurrentWeatherAsync(string location, Unit unit = Unit.Celsius, CancellationToken cancellationToken = default)
{
return Task.FromResult(new Weather
{
Location = location,
Temperature = 22.0,
Unit = unit,
Description = "Sunny",
});
}
}
var service = new WeatherService();
using var httpClient = new HttpClient();
var api = new OpenAiApi(apiKey, httpClient);
var result = await api.CreateChatCompletionAsync(new CreateChatCompletionRequest
{
Messages = new List<ChatCompletionRequestMessage>
{
"You are a helpful weather assistant.".AsSystemMessage(),
"What's the weather like today?".AsUserMessage(),
},
Functions = service.AsFunctions(),
Function_call = Function_call4.Auto,
Model = "gpt-3.5-turbo-0613",
});
// ...
var resultMessage = result.GetFirstChoiceMessage();
var functionArgumentsJson = resultMessage.Function_call?.Arguments ?? string.Empty;
var json = await service.CallGetCurrentWeatherAsync(functionArgumentsJson);
// or just get arguments
var args = service.AsGetCurrentWeatherAsyncArgs(functionArgumentsJson);
Support
Priority place for bugs: https://github.com/tryAGI/OpenAI/issues
Priority place for ideas and general questions: https://github.com/tryAGI/OpenAI/discussions
Discord: https://discord.gg/Ca2xhfBf3v
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. 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. |
| .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 is compatible. 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. |
-
.NETFramework 4.6.2
- System.Text.Json (>= 7.0.3)
- Tiktoken (>= 1.1.0)
-
.NETStandard 2.0
- System.ComponentModel.Annotations (>= 5.0.0)
- System.Text.Json (>= 7.0.3)
- Tiktoken (>= 1.1.0)
-
net6.0
- Tiktoken (>= 1.1.0)
-
net7.0
- Tiktoken (>= 1.1.0)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on tryAGI.OpenAI:
| Package | Downloads |
|---|---|
|
LangChain.Providers.OpenAI
OpenAI API LLM and Chat model provider. |
|
|
LangChain
LangChain meta-package with the most used things. |
|
|
Anyscale
SDK for Anyscale Endpoint that makes it easy and cheap to use LLama 2 |
|
|
LangChain.Serve.OpenAI
LangChain Serve as OpenAI sdk compatible API |
|
|
FreeLLM
Free-first chat routing over OpenAI-compatible providers and Google Gemini. Includes model aliases, rate-limit tracking, automatic fallbacks, an OpenAI-compatible chat-completions surface, and Microsoft.Extensions.AI support. |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on tryAGI.OpenAI:
| Repository | Stars |
|---|---|
|
tryAGI/LangChain
C# implementation of LangChain. We try to be as close to the original as possible in terms of abstractions, but are open to new entities.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 4.2.5 | 242 | 5/27/2026 |
| 4.2.5-dev.34 | 40 | 5/27/2026 |
| 4.2.5-dev.31 | 42 | 5/26/2026 |
| 4.2.5-dev.29 | 39 | 5/26/2026 |
| 4.2.5-dev.25 | 52 | 5/23/2026 |
| 4.2.5-dev.24 | 57 | 5/22/2026 |
| 4.2.5-dev.18 | 59 | 5/7/2026 |
| 4.2.5-dev.16 | 59 | 5/7/2026 |
| 4.2.5-dev.15 | 60 | 5/7/2026 |
| 4.2.5-dev.14 | 63 | 5/7/2026 |
| 4.2.5-dev.2 | 56 | 4/30/2026 |
| 4.2.4 | 1,206 | 4/30/2026 |
| 4.2.4-dev.1 | 55 | 4/30/2026 |
| 4.2.1-dev.249 | 97 | 4/19/2026 |
| 4.2.1-dev.248 | 77 | 4/18/2026 |
| 4.2.1-dev.222 | 111 | 4/1/2026 |
| 4.2.1-dev.221 | 68 | 4/1/2026 |
| 4.2.1-dev.216 | 85 | 3/30/2026 |
| 4.2.1-dev.215 | 72 | 3/29/2026 |
| 1.1.1 | 58,956 | 6/30/2023 |