|
1 | 1 | ## Getting started
|
2 | 2 |
|
| 3 | +Add the following packages to your project to work with Azure OpenAI: |
| 4 | + |
| 5 | +**[Azure.AI.OpenAI](https://www.nuget.org/packages/Azure.AI.OpenAI/)**: Provides an Azure OpenAI client with Azure specific functionality that builds on top of the standard [OpenAI](https://www.nuget.org/packages/OpenAI/) library dependency. |
| 6 | +**[Azure.Identity](https://www.nuget.org/packages/Azure.Identity)**: Provides Microsoft Entra ID token authentication support across the Azure SDK libraries. |
| 7 | +**[Newtonsoft.Json.Schema](https://www.nuget.org/packages/Newtonsoft.Json.Schema)**: Provides helpful utilities for working with JSON schemas. |
| 8 | + |
| 9 | +```dotnetcli |
| 10 | +dotnet add package Azure.AI.OpenAI --prerelease |
| 11 | +dotnet add package Azure.Identity |
| 12 | +dotnet add package Newtonsoft.Json.Schema |
| 13 | +``` |
| 14 | + |
3 | 15 | # [Microsoft Entra ID](#tab/dotnet-entra-id)
|
4 | 16 |
|
| 17 | +If you are new to using Microsoft Entra ID for authentication see [How to configure Azure OpenAI Service with Microsoft Entra ID authentication](../how-to/managed-identity.md). |
| 18 | + |
5 | 19 | ```csharp
|
6 | 20 | using Azure.AI.OpenAI;
|
7 | 21 | using Azure.Identity;
|
@@ -184,8 +198,7 @@ var chat = new List<ChatMessage>()
|
184 | 198 |
|
185 | 199 | // Create a JSON schema for the CalendarEvent structured response
|
186 | 200 | JSchemaGenerator generator = new JSchemaGenerator();
|
187 |
| -var schema = generator.Generate(typeof(CalendarEvent)); |
188 |
| -string jsonSchema = schema.ToString(); |
| 201 | +var jsonSchema = generator.Generate(typeof(CalendarEvent)).ToString(); |
189 | 202 |
|
190 | 203 | // Get a chat completion from the AI model
|
191 | 204 | var completion = chatClient.CompleteChat(
|
@@ -273,8 +286,7 @@ var chat = new List<ChatMessage>()
|
273 | 286 |
|
274 | 287 | // Create a JSON schema for the CalendarEvent structured response
|
275 | 288 | JSchemaGenerator generator = new JSchemaGenerator();
|
276 |
| -var schema = generator.Generate(typeof(CalendarEvent)); |
277 |
| -string jsonSchema = schema.ToString(); |
| 289 | +var jsonSchema = generator.Generate(typeof(CalendarEvent)).ToString(); |
278 | 290 |
|
279 | 291 | // Get a chat completion from the AI model
|
280 | 292 | var completion = chatClient.CompleteChat(
|
|
0 commit comments