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
Copy file name to clipboardExpand all lines: hub/apps/how-tos/chatgpt-openai-winui3.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,13 +41,13 @@ After creating your project, you should see the following default file structure
41
41
42
42
## Set your environment variable
43
43
44
-
In order to use the OpenAI SDK, you'll need to set an environment variable with your API key. In this example, we'll use the `MY_OPEN_AI_API_KEY` environment variable. Once you have your API key from the [OpenAI developer dashboard](https://platform.openai.com/api-keys), you can set the environment variable from the command line as follows:
44
+
In order to use the OpenAI SDK, you'll need to set an environment variable with your API key. In this example, we'll use the `OPENAI_API_KEY` environment variable. Once you have your API key from the [OpenAI developer dashboard](https://platform.openai.com/api-keys), you can set the environment variable from the command line as follows:
45
45
46
46
```powershell
47
-
setx MY_OPEN_AI_API_KEY <your-api-key>
47
+
setx OPENAI_API_KEY <your-api-key>
48
48
```
49
49
50
-
Note that this method works well for development, but you'll want to use a more secure method for production apps (for example: you could store your API key in a secure key vault that a remote service can access on behalf of your app).
50
+
Note that this method works well for development, but you'll want to use a more secure method for production apps (for example: you could store your API key in a secure key vault that a remote service can access on behalf of your app). See [Best practices for OpenAI key safety](https://help.openai.com/articles/5112595-best-practices-for-api-key-safety).
Copy file name to clipboardExpand all lines: hub/apps/how-tos/dall-e-winui3.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ In this how-to, we'll integrate DALL-E's image generation capabilities into your
20
20
21
21
-[Visual Studio 2022 and Tools for Windows App SDK](../windows-app-sdk/set-up-your-development-environment.md)
22
22
- A functional chat interface into which this capability will be integrated. See *[How to add OpenAI chat completions to your WinUI 3 / Windows App SDK desktop app](./chatgpt-openai-winui3.md)* - we'll demonstrate how to integrate DALL-E into the chat interface from this how-to.
23
-
- An OpenAI API key from your [OpenAI developer dashboard](https://platform.openai.com/api-keys) assigned to the `MY_OPEN_AI_API_KEY` environment variable.
23
+
- An OpenAI API key from your [OpenAI developer dashboard](https://platform.openai.com/api-keys) assigned to the `OPENAI_API_KEY` environment variable.
24
24
- An OpenAI SDK installed in your project. Refer to the [OpenAI documentation](https://platform.openai.com/docs/libraries) for a list of community libraries. In this how-to, we'll use [betalgo/openai](https://github.com/betalgo/openai).
Copy file name to clipboardExpand all lines: hub/apps/windows-dotnet-maui/dall-e-maui-windows.md
+13-4Lines changed: 13 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,13 +14,23 @@ In this quickstart, we'll demonstrate how to integrate DALL-E's image generation
14
14
15
15
- Visual Studio 2022 17.8 or greater, with the .NET Multi-platform App UI workload installed. For more information, see [Installation](/dotnet/maui/get-started/installation).
16
16
- A functional .NET MAUI project with OpenAI integration into which this capability will be integrated. See *[Create a recommendation app with .NET MAUI and ChatGPT](tutorial-maui-ai.md)* - we'll demonstrate how to integrate DALL-E into the user interface from this how-to.
17
-
- An OpenAI API key from your [OpenAI developer dashboard](https://platform.openai.com/api-keys) assigned to the `openAIKey` variable in your project.
17
+
- An OpenAI API key from your [OpenAI developer dashboard](https://platform.openai.com/api-keys).
18
18
- An [Azure.AI.OpenAI](https://www.nuget.org/packages/Azure.AI.OpenAI/) NuGet package installed in your project. If you've followed along with the .NET MAUI ChatGPT tutorial, you will have this dependency installed and configured.
19
19
20
20
## What problem will we solve?
21
21
22
22
You want to add DALL-E's image generation capabilities to your .NET MAUI Windows desktop app to provide users with a rich, interactive experience. They can already use the app to generate text-based recommendations, and you want to add the ability to generate images that visualize an activity in the location they have entered.
23
23
24
+
## Set your environment variable
25
+
26
+
In order to use the OpenAI SDK, you'll need to set an environment variable with your API key. In this example, we'll use the `OPENAI_API_KEY` environment variable. Once you have your API key from the [OpenAI developer dashboard](https://platform.openai.com/api-keys), you can set the environment variable from the command line as follows:
27
+
28
+
```powershell
29
+
setx OPENAI_API_KEY <your-api-key>
30
+
```
31
+
32
+
Note that this method works for development on Windows, but you'll want to use a more secure method for production apps and for mobile support. For example, you can store your API key in a secure key vault that a remote service can access on behalf of your app. See [Best practices for OpenAI key safety](https://help.openai.com/articles/5112595-best-practices-for-api-key-safety) for more information.
33
+
24
34
## Install and initialize the Azure OpenAI SDK
25
35
26
36
In this section, we'll install the SDK into the .NET MAUI project and initialize it with your OpenAI API key.
@@ -32,7 +42,6 @@ In this section, we'll install the SDK into the .NET MAUI project and initialize
32
42
```csharp
33
43
privateOpenAIClient_chatGptClient;
34
44
privateGuid_sessionGuid=Guid.Empty;
35
-
privatestringopenAIKey="MY_OPEN_AI_API_KEY";
36
45
privatestringopenAIEndpoint=null;
37
46
privatechar[] trimChars= { '\n', '?' };
38
47
@@ -44,6 +53,8 @@ In this section, we'll install the SDK into the .NET MAUI project and initialize
Copy file name to clipboardExpand all lines: hub/apps/windows-dotnet-maui/tutorial-maui-ai.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,6 +25,16 @@ In this tutorial, you learn how to:
25
25
* The .NET MAUI [installation requirements](/dotnet/maui/get-started/installation)
26
26
* If you are new to .NET MAUI on Windows, you should start with the [Build your first .NET MAUI app for Windows](/windows/apps/windows-dotnet-maui/walkthrough-first-app) tutorial.
27
27
28
+
## Set your environment variable
29
+
30
+
In order to use the OpenAI SDK, you'll need to set an environment variable with your API key. In this example, we'll use the `OPENAI_API_KEY` environment variable. Once you have your API key from the [OpenAI developer dashboard](https://platform.openai.com/api-keys), you can set the environment variable from the command line as follows:
31
+
32
+
```powershell
33
+
setx OPENAI_API_KEY <your-api-key>
34
+
```
35
+
36
+
Note that this method works for development on Windows, but you'll want to use a more secure method for production apps and for mobile support. For example, you can store your API key in a secure key vault that a remote service can access on behalf of your app. See [Best practices for OpenAI key safety](https://help.openai.com/articles/5112595-best-practices-for-api-key-safety) for more information.
37
+
28
38
## Create a new .NET MAUI project with the required UI elements
29
39
30
40
We're going to start by creating a new .NET MAUI project in Visual Studio. We'll use the **.NET MAUI App** template and add some UI elements to the **MainPage** to provide users with some recommendations based on a provided location. The UI will have buttons to get recommendations for restaurants, hotels, and attractions.
0 commit comments