{"id":53895,"date":"2024-10-01T12:00:00","date_gmt":"2024-10-01T19:00:00","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/dotnet\/?p=53895"},"modified":"2024-10-01T12:22:36","modified_gmt":"2024-10-01T19:22:36","slug":"announcing-the-stable-release-of-the-official-open-ai-library-for-dotnet","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/announcing-the-stable-release-of-the-official-open-ai-library-for-dotnet\/","title":{"rendered":"Announcing the stable release of the official OpenAI library for .NET"},"content":{"rendered":"<p>Back in June, <a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/openai-dotnet-library\/\">we launched<\/a> the first beta of the OpenAI library for .NET, empowering developers to integrate advanced AI models into their applications. Today, we are excited to share that the <strong>stable release<\/strong> of the <strong><a href=\"https:\/\/www.nuget.org\/packages\/OpenAI\/2.0.0\">official OpenAI library for .NET<\/a><\/strong> is now live. This release ensures a smooth and reliable integration experience for developers working with OpenAI and Azure OpenAI services in their .NET applications.<\/p>\n<p><a href=\"https:\/\/www.nuget.org\/packages\/OpenAI\/\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2024\/10\/OpenAINuget.png\" alt=\"OpenAI NuGet Package\" \/><\/a><\/p>\n<h2>Key features<\/h2>\n<p>The official OpenAI library for .NET provides powerful tools that simplify integrating OpenAI&#8217;s cutting-edge models into your .NET applications, offering developers a streamlined experience:<\/p>\n<ul>\n<li><strong>Full OpenAI REST API support<\/strong>: Includes Assistants v2 and Chat Completions, enabling flexible and advanced interactions.<\/li>\n<li><strong>Support for latest models<\/strong>: OpenAI\u2019s latest flagship models, including GPT-4o, GPT-4o mini, o1-preview, and o1-mini, are fully supported, ensuring developers have access to cutting-edge AI capabilities.<\/li>\n<li><strong>Extensibility<\/strong>: The library is designed with extensibility in mind, allowing the community to build additional libraries on top of it.<\/li>\n<li><strong>Sync and async APIs<\/strong>: These ensure developers have the flexibility to use synchronous or asynchronous patterns depending on their application&#8217;s needs.<\/li>\n<li><strong>Streaming completions<\/strong>: Access to streaming completions via <code>IAsyncEnumerable&lt;T&gt;<\/code>, offering more dynamic interaction models.<\/li>\n<li><strong>Quality-of-life improvements<\/strong>: Numerous improvements have been made throughout the beta cycle based on community feedback.<\/li>\n<li><strong>.NET Standard 2.0 compatibility<\/strong>: This library, written in C#, supports all .NET variants that implement <a href=\"https:\/\/learn.microsoft.com\/dotnet\/standard\/net-standard?tabs=net-standard-2-0#select-net-standard-version\">.NET Standard 2.0<\/a>, ensuring compatibility with the latest .NET platforms.<\/li>\n<\/ul>\n<p>This official .NET library ensures a smooth and supported <a href=\"https:\/\/github.com\/openai\/openai-dotnet?tab=readme-ov-file#how-to-work-with-azure-openai\">integration with OpenAI and Azure OpenAI<\/a>. It also complements OpenAI\u2019s official libraries for Python and TypeScript\/JavaScript developers.<\/p>\n<p>The library is open-source, developed, and supported on <a href=\"https:\/\/github.com\/openai\/openai-dotnet\">GitHub<\/a>. It will be kept up to date with the latest features from OpenAI.<\/p>\n<h2>Sample code<\/h2>\n<p>Here\u2019s a quick look at how easy it is to use the OpenAI library in a .NET application. The following code snippet demonstrates how to create an OpenAI client and use it to complete a chat interaction:<\/p>\n<pre><code class=\"language-csharp\">using OpenAI.Chat;\r\n\r\nChatClient client = new(\r\n    model: \"gpt-4o\",\r\n    apiKey: Environment.GetEnvironmentVariable(\"OPENAI_API_KEY\"));\r\nChatCompletion completion = client.CompleteChat(\"Say 'this is a test.'\");\r\n\r\nConsole.WriteLine($\"[ASSISTANT]: {completion.Content[0].Text}\");<\/code><\/pre>\n<h2>Thank you to the .NET community<\/h2>\n<p>This stable release wouldn\u2019t have been possible without the continued support and feedback from the .NET community. Over the course of the beta, we\u2019ve seen significant engagement and contributions that helped shape this release. We&#8217;re committed to continuing this collaboration as the library evolves.<\/p>\n<h2>Get started today<\/h2>\n<ul>\n<li><strong>Try the library<\/strong>: Install the NuGet package for the <a href=\"https:\/\/www.nuget.org\/packages\/OpenAI\/2.0.0\">official OpenAI library for .NET<\/a> and start experimenting with its features.<\/li>\n<li><strong>Join the community<\/strong>: Engage with us and other developers on <a href=\"https:\/\/github.com\/openai\/openai-dotnet\">GitHub<\/a>. Share your experiences, report issues, and contribute to discussions.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Discover the stable release of the official OpenAI library for .NET, empowering developers to integrate cutting-edge AI models, including GPT-4o &amp; o1, into their .NET applications.<\/p>\n","protected":false},"author":11288,"featured_media":53896,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[685,7781,7252],"tags":[568,30,7724],"class_list":["post-53895","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dotnet","category-ai","category-cloud","tag-ai","tag-announcement","tag-openai"],"acf":[],"blog_post_summary":"<p>Discover the stable release of the official OpenAI library for .NET, empowering developers to integrate cutting-edge AI models, including GPT-4o &amp; o1, into their .NET applications.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/53895","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/users\/11288"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/comments?post=53895"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/53895\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media\/53896"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media?parent=53895"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=53895"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=53895"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}