A few months ago the OpenAI .NET library was released as a beta. It has now reached version 2.0.0 and the time has come to leave beta and, with a few amendments enter production readiness.
As a refresher, the library provides convenient access to the OpenAI REST API from .NET applications so that developers can build AI driven applications. That access breaks down to :
Support for the entire OpenAI API, including Assistants v2 and Chat Completions
Support for GPT-4o, OpenAI’s latest flagship model
Extensibility to enable the community to build libraries on top
Sync and async APIs for ease of use and efficiency
Access to streaming completions via IAsyncEnumerable<T>
.NET Standard 2.0 compatibility: written in C#, supports all .NET variants that implement .NET Standard 2.0, ensuring compatibility with the latest .NET platforms.
You can very easily add it to your project through NuGet:
dotnet add package OpenAI
With that in place and after obtaining an API key, you can enrich you application with the following functionalities:
chat completions with streaming
chat completions with tools and function calling
chat completions with structured outputs
generate text embeddings
generate images
transcribe audio
use assistants with retrieval augmented generation (RAG)
use assistants with streaming and vision
To put it into practice, here's a sample that summons various clients; embedding, image and audio.
The new version 2.0.0 implements a few breaking changes:
Renamed `OpenAIClientOptions`'s `ApplicationId` to `UserAgentApplicationId` (commit_hash)
Replaced the deprecated `ChatFunctionChoice(ChatFunction)` constructor with `CreateNamedChoice(string functionName)`
Renamed `FileClient` to `OpenAIFileClient` and the corresponding `GetFileClient()` method in `OpenAIClient` to `GetOpenAIFileClient()`
Renamed `ModelClient` to `OpenAIModelClient` and the corresponding `GetModelClient()` method in `OpenAIClient` to `GetOpenAIModelClient()`
So if you've been using the beta and want to upgrade, take those into consideration.
There's also another Microsoft AI SDK, that of Semantic Kernel which serves a similar purpose in accessing LLMs from your code. The main difference is that with Semantic you get access to multiple models, and not just OpenAI’s, plus you can choose between the C#, Java, Python and Javascript versions. Explore both options to see which fits your needs.
Four teams of humanoid robots faced off in fully autonomous 3-on-3 soccer matches in the latest event organized to showcase China’s advances in humanoid robot technology. It was the first such compe [ ... ]
In the era of AI, the Raspberry Pi Foundation takes the view that learning how to create with technology has never been more important. Last year it revamped its Code Club network of free co [ ... ]