At Microsoft Build 2024, we announced new investments that expand the AI ecosystem for .NET developers. We’re excited to share more detailed plans around Microsoft’s collaboration with OpenAI on their official .NET library.
Today, the OpenAI team released their first beta, version 2.0.0-beta.1, of the official OpenAI library for .NET. Features include:
- 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>
This official .NET library ensures a smooth and supported integration with OpenAI and Azure OpenAI. It also complements OpenAI’s official libraries for Python and TypeScript/JavaScript developers.
The .NET library is developed and supported on GitHub and will be kept up to date with the latest features from OpenAI. Work will continue over the next few months to gather feedback to improve the library and release a stable NuGet package.
Thank you to the .NET community
We’d like to thank and recognize the work of Roger Pincombe on his library that was published under the OpenAI v1.x NuGet package name. Roger initially published the library in June 2020, making it the first known OpenAI package for .NET. He volunteered countless hours of personal time ever since to maintain the project on GitHub. Roger has worked closely with OpenAI and Microsoft on our plans for the official .NET package for OpenAI. Roger is also helping with a migration guide from his package to the new official one.
Of course, developers may choose to continue using their favorite community libraries, like:
OpenAI and the .NET team also thank these project maintainers for their extraordinary efforts in filling a void within the community. Even with the release of the official package from OpenAI, there are opportunities for community libraries to add significant value on top. We look forward to collaborating with the community in this space.
Next steps
Here’s how you can get involved:
- Try the library: Install the OpenAI .NET library and start experimenting with its features.
- Join the community: Engage with us and other developers on GitHub. Share your experiences, report issues, and contribute to discussions.
- Attend the live stream: Join us live at 10:00 AM PDT on June 19 for the .NET AI Community Standup. Ask questions, learn more about the library, and see demos of its capabilities.
Quick question
does this library supports the new gpt 4o-mini?
Yes, it does. You should be able to do something like this:
Well, no, we can’t. What you copied is really on the github readme of the openai nuget, but if oyu try to add that package from gui or from console, you wil got a totally different one, which has zero relevance with the documentation.
For those following along, we discussed and demonstrated the official library on today’s .NET AI Community Standup. View the recording at https://www.youtube.com/watch?v=GUV2p_9QUo8. Special guest Roger Pincombe joined us!
Official .NET libraries requiring API keys for third-party services to use?
That’s a new one.
Maybe in 2030 we’ll require the user having a Microsoft account to run a program that has using System; :p
It is required in whatever programming platform or language you are using. Lol. You are consuming their pretrained models or services through their endpoints, so you need the OPENAI keys. When consuming AI services on Azure or AWS, you would need their keys also.
But if you want to consume a SLM or MLM locally or on edge (on device), you can use Semantic Kernel library to do that. SK library supports C#, Python and...
Its OpenAI’s official api, they require a key like a million other services do. Or do you expect them to provide everything unlimited completely free?
How does this affect those using the ML.NET package from Microsoft? Are the two packages related, or does is this package a “next version” of ML.NET?
Hi Jeff,
This has no effect on ML.NET set of packages. The OpenAI library announced in this post and ML.NET are unrelated. However, if there’s any integrations folks would like to see between ML.NET and OpenAI models, feedback is always welcome.
https://github.com/dotnet/machinelearning/issues
I appreciate the reply. Unfortunately, this is another example of MS having one hand not knowing what the other hand is doing. ML.NET has been around, and been updated, for years. MS should have provided a clear path of transition or map of interaction of the two. ML.NET does not require any subscriptions (and thus no revenue stream for MS), whereas "OpenAI library for .NET" does require a subscription and incurs...
Hi Jeff,
Thanks for the feedback.
MS should have provided a clear path of transition or map of interaction of the two. ML.NET does not require any subscriptions (and thus no revenue stream for MS), whereas “OpenAI library for .NET” does require a subscription and incurs cost for the developer and end user.
At a high-level, the intents of the libraries are different.
OpenAI services can be thought of like any other (Azure) AI Service, for which...
Interesting
Does this include support for the latest GPT-4o features? audio stream in & out as well as image & video recognition?
Hey Jose Luis!
Yes they do! the main repo have great samples (https://github.com/openai/openai-dotnet), and we talked about that also today in the .NET + AI LATAM streaming.
Best
What does this mean for the
Azure.AI.OpenAI
package?A quick update on this for anyone interested in making the switch. I migrated my code to the new prerelease of the package. Everything is running great. As already mentioned in this thread, you use when communicating with a model hosted on Azure and when communicating with a model on OpenAI. One thing you should be aware of is that the new clients now throw instead of . So, if you...
Hello, Thomas! That's a great question. We've worked closely with OpenAI for overall .NET convergence and that existing package is being converted into the Azure OpenAI Service "companion library" that will provide a dedicated for connecting to Azure OpenAI resources, together with extensions for Azure-specific concepts like Responsible AI content filter results and On Your Data integration. All of the common capabilities between OpenAI and Azure OpenAI will share the same scenario clients,...
Thank you for the detailed answer. So, to make sure I understand the split here. Previously, we would use an to communicate with both ChatGPT from OpenAI and Azure OpenAI Service. With different endpoints and settings, of course. But going forward, we will use from the package to communicate with Azure OpenAI Service and from the package to communicate with OpenAI?
is from the predecessor OpenAI library prior to the package name being graciously transferred; please be sure you're using for the official library!
The OpenAI library has ; the package adds , which derives from and specifically configures things for Azure OpenAI. With either, you then instantiate scenario clients from the factory-like top-level client, e.g. . From there, the (or other scenario client instance) is used the same way whether...
Makes sense. Thanks!
Here’s the updated Azure.AI.OpenAI package Travis mentioned: https://www.nuget.org/packages/Azure.AI.OpenAI/2.0.0-beta.1