{"id":3103,"date":"2024-07-30T01:34:41","date_gmt":"2024-07-30T08:34:41","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/semantic-kernel\/?p=3103"},"modified":"2024-08-14T01:28:15","modified_gmt":"2024-08-14T08:28:15","slug":"support-for-azure-ai-openai-and-openai-v2-is-coming","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/agent-framework\/support-for-azure-ai-openai-and-openai-v2-is-coming\/","title":{"rendered":"Support for Azure.AI.OpenAI and OpenAI v2 is coming"},"content":{"rendered":"<p>Microsoft <a href=\"https:\/\/www.youtube.com\/watch?v=GUV2p_9QUo8\">announced the official OpenAI library for .NET<\/a> at the Build 2024 conference. This new SDK ensures that .NET developers have parity with other programming language libraries when accessing Azure OpenAI models. This means the new SDK will be able to support the latest OpenAI features and models as soon as they come out, such as GPT4o and Assistants v2, by providing a unified experience across OpenAI and Azure OpenAI.<\/p>\n<p>Since the release of the official OpenAI library for .NET, the Semantic Kernel team has been working on updating our existing OpenAI connectors to use the new V2 <a href=\"https:\/\/www.nuget.org\/packages\/OpenAI\">OpenAI library<\/a> and <a href=\"https:\/\/www.nuget.org\/packages\/Azure.AI.OpenAI\">Azure.AI.OpenAI library<\/a>. This is a <span style=\"text-decoration: underline;\">significant<\/span> update to Semantic Kernel. Once complete, it will enable developers to upgrade their projects to the v2 libraries from OpenAI and Azure OpenAI.<\/p>\n<h2>Update<\/h2>\n<p style=\"text-align: left;\">We have published the <a href=\"https:\/\/www.nuget.org\/packages\/Microsoft.SemanticKernel\/1.18.0-rc\">Semantic Kernel v1.18.0-rc<\/a> release candidate including these changes and it is available to down and use now.\u00a0Read the full announcement <a href=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/support-for-azure-ai-openai-and-openai-v2-is-here\/\">Support for Azure.AI.OpenAI and OpenAI v2 is here | Semantic Kernel (microsoft.com)<\/a>. We have also published a <span class=\"ui-provider a b c d e f g h i j k l m n o p q r s t u v w x y z ab ac ae af ag ah ai aj ak\" dir=\"ltr\"> <a id=\"menur194\" class=\"fui-Link ___1rxvrpe f2hkw1w f3rmtva f1ewtqcl fyind8e f1k6fduh f1w7gpdv fk6fouc fjoy568 figsok6 f1hu3pq6 f11qmguv f19f4twv f1tyq0we f1g0x7ka fhxju0i f1qch9an f1cnd47f fqv5qza f1vmzxwi f1o700av f13mvf36 f1cmlufx f9n3di6 f1ids18y f1tx3yz7 f1deo86v f1eh06m1 f1iescvh fhgqx19 f1olyrje f1p93eir f1nev41a f1h8hb77 f1lqvz6u f10aw75t fsle3fq f17ae5zn\" title=\"https:\/\/learn.microsoft.com\/en-us\/semantic-kernel\/support\/v2-openai-migration-guide\" href=\"https:\/\/learn.microsoft.com\/en-us\/semantic-kernel\/support\/v2-openai-migration-guide\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"Link OpenAI Connector Migration Guide | Microsoft Learn\">OpenAI Connector Migration Guide | Microsoft Learn<\/a><\/span> to guide you through the upgrade process.<\/p>\n<h2>What to expect when you upgrade<\/h2>\n<p>Since the new .NET Azure.AI.OpenAI SDK has done a major version upgrade from v1 to v2, there have been significant updates to the underlying APIs. For developers that use this SDK directly, there are several breaking changes that must be accounted for. The good news for Semantic Kernel developers though is that our abstractions isolate your code from the vast majority of these changes. There are, however, a few unavoidable breaking changes to be aware of that are a result of the upgrade, but these changes primarily impact more advanced use cases.<\/p>\n<h3>The one required change&#8230;<\/h3>\n<p>The one change that most Semantic Kernel customers will need to make is updating the name of the library you import. Because there are now <em>two<\/em> libraries that connect to OpenAI models (Azure.AI.OpenAI and the official OpenAI library), we chose to update the name of Semantic Kernel&#8217;s connectors to better reflect those differences. There are now two different connector libraries: <code>Microsoft.SemanticKernel.Connectors.OpenAI<\/code> and <code>Microsoft.SemanticKernel.Connectors.AzureOpenAI<\/code>. If you used the\u00a0 <a href=\"https:\/\/www.nuget.org\/packages\/Microsoft.SemanticKernel.Connectors.OpenAI\">Microsoft.SemanticKernel.Connectors.OpenAI<\/a> library to connect to Azure OpenAI, you&#8217;ll want to update it to the Microsoft.SemanticKernel.Connectors.AzureOpenAI library. Additional details about the decisions related to naming and structure are documented <a href=\"https:\/\/github.com\/microsoft\/semantic-kernel\/blob\/main\/docs\/decisions\/0047-azure-open-ai-connectors.md\">here<\/a>.<\/p>\n<h3>Changes that impact advanced scenarios<\/h3>\n<p>If you are using more advanced scenarios that require direct usage of the APIs in the Azure.AI.OpenAI SDK, you&#8217;ll need to be aware of the following changes that Azure introduced when they moved to v2:<\/p>\n<ul>\n<li>The\u00a0<code>OpenAIClient<\/code>\u00a0type previously was a Azure specific namespace type but now it is an\u00a0<code>OpenAI<\/code>\u00a0SDK namespace type, you will need to update your code to use the new\u00a0<code>OpenAIClient<\/code> type.<\/li>\n<li>When using Azure, you will need to update your code to use the new\u00a0<code>AzureOpenAIClient<\/code>\u00a0type.<\/li>\n<li>\n<p dir=\"auto\">With the new\u00a0<code>AzureOpenAIClient<\/code>, you can now specify your datasource thru the options and that requires a small change in your code to the new type.<\/p>\n<\/li>\n<\/ul>\n<p>Also note that the following features have been deprecated in the new v2 Azure.AI.OpenAI SDK:<\/p>\n<ul>\n<li>The\u00a0<code>TextGeneration<\/code>\u00a0modality was deprecated in the latest version of the OpenAI Connector. You will need to update your code to use\u00a0<code>ChatCompletion<\/code>\u00a0modality instead. Keep in mind that the\u00a0<code>ChatCompletion<\/code>\u00a0services also implement the\u00a0<code>TextGeneration<\/code>\u00a0interface and that may not require any changes to your code if you were targetting the\u00a0<code>ITextGenerationService<\/code>\u00a0interface.<\/li>\n<li>The lastest\u00a0<code>OpenAI<\/code>\u00a0SDK does not support multiple choices anymore. The option for multiple results was removed also from the\u00a0<code>OpenAIPromptExecutionSettings<\/code>. So any implementation that was relying on multiple choices will need to be updated.<\/li>\n<li>The\u00a0<code>OpenAIFileService<\/code>\u00a0was deprecated in the latest version of the OpenAI Connector. We strongly recommend to update your code to use the new\u00a0<code>OpenAIClient.GetFileClient()<\/code>\u00a0for file management operations.<\/li>\n<\/ul>\n<h2>We&#8217;ll be there every step of the way!<\/h2>\n<p>Uptalking a major update can be challenging, but we in the Semantic Kernel team want to make it as painless as possible. As we get closer to adopting the new v2 libraries, we will provide a detailed migration guide to help you with the process of upgrading your code. In the feature branch where we&#8217;re updating the connectors, we&#8217;ve already made the required changes to our samples (see <a href=\"https:\/\/github.com\/microsoft\/semantic-kernel\/tree\/feature-connectors-openai\">microsoft\/semantic-kernel at feature-connectors-openai<\/a>).<\/p>\n<p>In most cases, the updates just required adding a new using statement for the Microsoft.SemanticKernel.Connectors.AzureOpenAI library, which shows the value of having an abstraction layer like Semantic Kernel between you and the underlying SDKs.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Microsoft announced the official OpenAI library for .NET at the Build 2024 conference. This new SDK ensures that .NET developers have parity with other programming language libraries when accessing Azure OpenAI models. This means the new SDK will be able to support the latest OpenAI features and models as soon as they come out, such [&hellip;]<\/p>\n","protected":false},"author":131388,"featured_media":2808,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3103","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-semantic-kernel"],"acf":[],"blog_post_summary":"<p>Microsoft announced the official OpenAI library for .NET at the Build 2024 conference. This new SDK ensures that .NET developers have parity with other programming language libraries when accessing Azure OpenAI models. This means the new SDK will be able to support the latest OpenAI features and models as soon as they come out, such [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts\/3103","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/users\/131388"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/comments?post=3103"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts\/3103\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/media\/2808"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/media?parent=3103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/categories?post=3103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/tags?post=3103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}