|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: Azure Open AI in ##Platform_Name## Chat UI Control | Syncfusion |
| 4 | +description: Checkout and learn about Integration of Azure Open AI in Syncfusion ##Platform_Name## Chat UI control of Syncfusion Essential JS 2 and more. |
| 5 | +platform: ej2-asp-core-mvc |
| 6 | +control: Azure Open AI |
| 7 | +publishingplatform: ##Platform_Name## |
| 8 | +documentation: ug |
| 9 | +--- |
| 10 | + |
| 11 | +# Integration of Azure Open AI With Chat UI component |
| 12 | + |
| 13 | +The Syncfusion AI AssistView supports integration with [Azure Open AI](https://microsoft.github.io/PartnerResources/skilling/ai-ml-academy/resources/openai), enabling advanced conversational AI features in your MVC applications. |
| 14 | + |
| 15 | +## Getting Started With the Chat UI Component |
| 16 | + |
| 17 | +Before integrating Azure Open AI, ensure that the Syncfusion Chat UI control is correctly rendered in your MVC application: |
| 18 | +[ MVC Getting Started Guide](../getting-started) |
| 19 | + |
| 20 | +## Prerequisites |
| 21 | + |
| 22 | +* An Azure account with access to `Azure Open AI` services and a generated API key. |
| 23 | + |
| 24 | +* Syncfusion Chat UI for MVC `Syncfusion.EJ2.MVC5` Install ASP.NET MVC package in the application. |
| 25 | + |
| 26 | +## Install Dependencies |
| 27 | + |
| 28 | +Install the Syncfusion ASP.NET MVC package in the application using the Package Manager Console. |
| 29 | + |
| 30 | +```bash |
| 31 | + |
| 32 | +NuGet\Install-Package Syncfusion.EJ2.MVC5 |
| 33 | + |
| 34 | +``` |
| 35 | + |
| 36 | +Install the Open AI and Azure Open AI package in the application using Package Manager Console. |
| 37 | + |
| 38 | +```bash |
| 39 | + |
| 40 | +NuGet\Install-Package OpenAI |
| 41 | +NuGet\Install-Package Azure.AI.OpenAI |
| 42 | +NuGet\Install-Package Azure.Core |
| 43 | + |
| 44 | +``` |
| 45 | + |
| 46 | + |
| 47 | +## Generate API Key |
| 48 | + |
| 49 | +1. Log in to the [Azure Portal](https://portal.azure.com/#home) and navigate to your Azure Open AI resource. |
| 50 | + |
| 51 | +2. Under Resource Management, select Keys and Endpoint to retrieve your API key and endpoint URL. |
| 52 | + |
| 53 | +3. Copy the API key, endpoint, and deployment name (e.g., gpt-4o-mini). Ensure the API version (e.g., 2024-07-01-preview) matches your resource configuration. |
| 54 | + |
| 55 | +4. Store these values securely, as they will be used in your application. |
| 56 | + |
| 57 | +> `Security Note`: Never expose your API key in client-side code for production applications. Use a server-side proxy or environment variables to manage sensitive information securely |
| 58 | +
|
| 59 | +## Integration Azure Open AI with Chat UI |
| 60 | + |
| 61 | +You can add the below respective files in your application: |
| 62 | + |
| 63 | +* Update the following configuration values with your Azure Open AI details: |
| 64 | + |
| 65 | +```bash |
| 66 | + |
| 67 | +string endpoint = "Your_Azure_OpenAI_Endpoint"; |
| 68 | +string apiKey = "Your_Azure_OpenAI_API_Key"; |
| 69 | +string deploymentName = "Your_Deployment_Name"; |
| 70 | + |
| 71 | +``` |
| 72 | + |
| 73 | +{% tabs %} |
| 74 | +{% highlight razor tabtitle="CSHTML" %} |
| 75 | +{% include code-snippet/chat-ui/ai-integrations/Asp.net-MVC/openai/razor %} |
| 76 | +{% endhighlight %} |
| 77 | +{% highlight c# tabtitle="openai.cs" %} |
| 78 | +{% include code-snippet/chat-ui/ai-integrations/Asp.net-MVC/openai/openai.cs %} |
| 79 | +{% endhighlight %} |
| 80 | +{% endtabs %} |
| 81 | + |
| 82 | + |
| 83 | + |
| 84 | +## Run and Test |
| 85 | + |
| 86 | +Run the application in the browser using the following command. |
| 87 | + |
| 88 | +Build and run the app (Ctrl + F5). |
| 89 | + |
| 90 | +Open `https://localhost:44321` to interact with your Azure Open AI for dynamic response. |
0 commit comments