{"id":3196,"date":"2024-10-01T13:20:33","date_gmt":"2024-10-01T20:20:33","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/azure-sdk\/?p=3196"},"modified":"2024-10-02T12:05:48","modified_gmt":"2024-10-02T19:05:48","slug":"announcing-the-stable-release-of-the-azure-openai-library-for-net","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/azure-sdk\/announcing-the-stable-release-of-the-azure-openai-library-for-net\/","title":{"rendered":"Announcing the stable release of the Azure OpenAI library for .NET"},"content":{"rendered":"<p>Today, the OpenAI team announced <a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/announcing-the-stable-release-of-the-official-open-ai-library-for-dotnet\/\">their first stable release<\/a> of the official OpenAI library for .NET. To go along with it, today we&#8217;re also releasing <a href=\"https:\/\/www.nuget.org\/packages\/Azure.AI.OpenAI\/2.0.0\">the stable release version<\/a> of its companion <a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-net\/blob\/main\/sdk\/openai\/Azure.AI.OpenAI\/README.md\">Azure OpenAI library for .NET<\/a>.<\/p>\n<p>Chat client code snippet:<\/p>\n<pre><code class=\"language-c#\">using OpenAI.Chat;\r\nusing Azure.AI.OpenAI;\r\nusing Azure.Identity;\r\n\r\nAzureOpenAIClient azureClient = new(\r\n    new Uri(\"https:\/\/your-azure-openai-resource.com\"),\r\n    new DefaultAzureCredential());\r\nChatClient chatClient = azureClient.GetChatClient(\"my-gpt-4o-deployment\");\r\n\r\nChatCompletion completion = chatClient.CompleteChat(\r\n    [\r\n        \/\/ System messages represent instructions or other guidance about how the assistant should behave\r\n        new SystemChatMessage(\"You are a helpful assistant that talks like a pirate.\"),\r\n        \/\/ User messages represent user input, whether historical or the most recent input\r\n        new UserChatMessage(\"Hi, can you help me?\"),\r\n        \/\/ Assistant messages in a request represent conversation history for responses\r\n        new AssistantChatMessage(\"Arrr! Of course, me hearty! What can I do for ye?\"),\r\n        new UserChatMessage(\"What's the best way to train a parrot?\"),\r\n    ]);\r\n\r\nConsole.WriteLine($\"{completion.Role}: {completion.Content[0].Text}\");<\/code><\/pre>\n<p><div class=\"alert alert-primary\"><p class=\"alert-divider\"><i class=\"fabric-icon fabric-icon--Info\"><\/i><strong>Additional authentication options<\/strong><\/p>For alternative authentication options, see <a href=\"https:\/\/learn.microsoft.com\/dotnet\/api\/overview\/azure\/ai.openai-readme#authenticate-the-client\">Authenticate the client<\/a>.<\/div><\/p>\n<h2>2.1.0-beta.1 with OpenAI Realtime API support also available<\/h2>\n<p>We have also shipped <a href=\"https:\/\/www.nuget.org\/packages\/Azure.AI.OpenAI\/2.1.0-beta.1\">2.1.0-beta.1<\/a>, which comes with <a href=\"https:\/\/github.com\/openai\/openai-dotnet\/blob\/OpenAI_2.1.0-beta.1\/CHANGELOG.md#210-beta1-2024-10-01\">support for the new OpenAI Realtime API<\/a> just announced.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><\/div>\n<ul dir=\"auto\">\n<li>Added a new\u00a0<code>RealtimeConversationClient<\/code> in a corresponding scenario namespace.\n<ul dir=\"auto\">\n<li>This maps to the new\u00a0<code>\/realtime<\/code>\u00a0beta endpoint and is thus marked with a new\u00a0<code>[Experimental(\"OPENAI002\")]<\/code>\u00a0diagnostic tag.<\/li>\n<li>This is a very early version of the convenience surface and thus subject to significant change<\/li>\n<li>Documentation and samples will arrive soon; in the interim, see\u00a0<a href=\"https:\/\/github.com\/openai\/openai-dotnet\/blob\/OpenAI_2.1.0-beta.1\/tests\/RealtimeConversation\">the scenario test files<\/a>\u00a0for basic usage<\/li>\n<li>You can also find an external sample employing this client, together with Azure OpenAI support, at\u00a0<a href=\"https:\/\/github.com\/Azure-Samples\/aoai-realtime-audio-sdk\/tree\/main\/dotnet\/samples\/console\">https:\/\/github.com\/Azure-Samples\/aoai-realtime-audio-sdk\/tree\/main\/dotnet\/samples\/console<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>Next steps<\/h2>\n<p>Here\u2019s how you can get involved:<\/p>\n<ul>\n<li><strong>Try the library:<\/strong> Install the <a href=\"https:\/\/www.nuget.org\/packages\/Azure.AI.OpenAI\/2.0.0\">Azure OpenAI library for .NET<\/a> and start experimenting with its features or work through <a href=\"https:\/\/learn.microsoft.com\/azure\/ai-services\/openai\/chatgpt-quickstart?pivots=programming-language-csharp\">one of the Azure samples<\/a>.<\/li>\n<li><strong>Join the community:<\/strong> Engage with us and other developers on <a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-net\/blob\/main\/sdk\/openai\/Azure.AI.OpenAI\/README.md\">GitHub<\/a>. Share your experiences, report issues, and contribute to discussions.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>The stable release of the Azure OpenAI library for .NET is now available and it includes support for the entire OpenAI API, GPT-4o, and o1-preview models.<\/p>\n","protected":false},"author":127,"featured_media":3197,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[701,786,931,732,705],"class_list":["post-3196","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure-sdk","tag-net","tag-ai","tag-openai","tag-release","tag-sdk"],"acf":[],"blog_post_summary":"<p>The stable release of the Azure OpenAI library for .NET is now available and it includes support for the entire OpenAI API, GPT-4o, and o1-preview models.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/posts\/3196","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/users\/127"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/comments?post=3196"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/posts\/3196\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/media\/3197"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/media?parent=3196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/categories?post=3196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/tags?post=3196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}