You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this quickstart, learn how to create a .NET console chat app to connect to and prompt an OpenAI or Azure OpenAI model. The app uses the [`Microsoft.Extensions.AI`](https://www.nuget.org/packages/Microsoft.Extensions.AI) library so you can write code using AI abstractions rather than a specific SDK. AI abstractions enable you to change the underlying AI model with minimal code changes.
15
+
In this quickstart, you learn how to create a .NET console chat app to connect to and prompt an OpenAI or Azure OpenAI model. The app uses the [`Microsoft.Extensions.AI`](https://www.nuget.org/packages/Microsoft.Extensions.AI) library so you can write code using AI abstractions rather than a specific SDK. AI abstractions enable you to change the underlying AI model with minimal code changes.
16
+
17
+
> [!NOTE]
18
+
> The [`Microsoft.Extensions.AI`](https://www.nuget.org/packages/Microsoft.Extensions.AI/) library is currently in Preview.
16
19
17
20
:::zone target="docs" pivot="openai"
18
21
@@ -26,11 +29,13 @@ In this quickstart, learn how to create a .NET console chat app to connect to an
Complete the following steps to create a .NET console app to connect to an AI service.
38
+
Complete the following steps to create a .NET console app to connect to an AI model.
34
39
35
40
1. In an empty directory on your computer, use the `dotnet new` command to create a new console app:
36
41
@@ -90,19 +95,14 @@ Complete the following steps to create a .NET console app to connect to an AI se
90
95
```bash
91
96
dotnet user-secrets init
92
97
dotnet user-secrets set OpenAIKey <your-openai-key>
93
-
```
94
-
95
-
1. Use the `dotnet run` command to run the app:
96
-
97
-
```dotnetcli
98
-
dotnet run
98
+
dotnet user-secrets set ModelName <your-openai-model-name>
99
99
```
100
100
101
101
:::zone-end
102
102
103
103
## Add the app code
104
104
105
-
The app uses the [`Microsoft.SemanticKernel`](https://www.nuget.org/packages/Microsoft.SemanticKernel) package to send and receive requests to the OpenAI service.
105
+
The app uses the [`Microsoft.Extensions.AI`](https://www.nuget.org/packages/Microsoft.Extensions.AI/) package to send and receive requests to the AI model.
106
106
107
107
1. In the **Program.cs** file, add the following code to connect and authenticate to the AI model.
108
108
@@ -129,7 +129,15 @@ The app uses the [`Microsoft.SemanticKernel`](https://www.nuget.org/packages/Mic
Customize the text content of the `benefits.md` file or the length of the summary to see the differences in the responses.
132
+
1. Use the `dotnet run` command to run the app:
133
+
134
+
```dotnetcli
135
+
dotnet run
136
+
```
137
+
138
+
The app prints out the completion response from the AI model. Customize the text content of the `benefits.md` file or the length of the summary to see the differences in the responses.
139
+
140
+
:::zone target="docs" pivot="azure-openai"
133
141
134
142
## Clean up resources
135
143
@@ -139,6 +147,8 @@ When you no longer need the sample application or resources, remove the correspo
139
147
azd down
140
148
```
141
149
150
+
:::zone-end
151
+
142
152
## Next steps
143
153
144
154
-[Quickstart - Build an AI chat app with .NET](get-started-openai.md)
> You can also use [Semantic Kernel](/semantic-kernel) to accomplish the tasks in this article. Semantic Kernel is a lightweight, open-source development kit that lets you easily build AI agents and integrate the latest AI models into your C#, Python, or Java codebase.
0 commit comments