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
- An Azure OpenAI Service resource with a `gpt-35-turbo` or `gpt-4` series models deployed. For more information about model deployment, see the [resource deployment guide](../how-to/create-resource.md).
27
-
28
-
> [!div class="nextstepaction"]
29
-
> [I ran into an issue with the prerequisites.](https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=JAVASCRIPT&Pillar=AOAI&Product=Chatgpt&Page=quickstart&Section=Prerequisites)
30
-
31
-
## [**JavaScript**](#tab/javascript)
32
-
33
21
- An Azure subscription - [Create one for free](https://azure.microsoft.com/free/cognitive-services?azure-portal=true)
34
22
-[LTS versions of Node.js](https://github.com/nodejs/release#release-schedule)
23
+
-[Azure CLI](/cli/azure/install-azure-cli) used for passwordless authentication in a local development environment, create the necessary context by signing in with the Azure CLI.
35
24
- An Azure OpenAI Service resource with either a `gpt-35-turbo` or `gpt-4` series models deployed. For more information about model deployment, see the [resource deployment guide](../how-to/create-resource.md).
36
25
37
26
> [!div class="nextstepaction"]
38
27
> [I ran into an issue with the prerequisites.](https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=JAVASCRIPT&Pillar=AOAI&Product=Chatgpt&Page=quickstart&Section=Prerequisites)
39
28
40
-
---
41
29
42
30
## Set up
43
31
@@ -54,7 +42,7 @@ In a console window (such as cmd, PowerShell, or Bash), create a new directory f
54
42
Install the required packages for JavaScript with npm from within the context of your new directory:
55
43
56
44
```console
57
-
npm install openai dotenv @azure/identity
45
+
npm install openai @azure/identity
58
46
```
59
47
60
48
Your app's _package.json_ file will be updated with the dependencies.
@@ -66,94 +54,69 @@ Your app's _package.json_ file will be updated with the dependencies.
66
54
67
55
Open a command prompt where you want the new project, and create a new file named ChatCompletion.js. Copy the following code into the ChatCompletion.js file.
68
56
69
-
## [**TypeScript**](#tab/typescript)
70
57
71
-
```typescript
72
-
import"dotenv/config";
73
-
import { AzureOpenAI } from"openai";
74
-
importtype {
75
-
ChatCompletion,
76
-
ChatCompletionCreateParamsNonStreaming,
77
-
} from"openai/resources/index";
58
+
## [Microsoft Entra ID](#tab/javascript-keyless)
59
+
60
+
```javascript
61
+
const { AzureOpenAI } =require("openai");
62
+
const {
63
+
DefaultAzureCredential,
64
+
getBearerTokenProvider
65
+
} =require("@azure/identity");
78
66
79
67
// You will need to set these environment variables or edit the following values
constdeployment="gpt-4o"; //This must match your deployment name.
156
-
require("dotenv/config");
157
120
158
121
asyncfunctionmain() {
159
122
@@ -198,122 +161,6 @@ node.exe ChatCompletion.js
198
161
}
199
162
```
200
163
201
-
## Microsoft Entra ID
202
-
203
-
> [!IMPORTANT]
204
-
> In the previous example we are demonstrating key-based authentication. Once you have tested with key-based authentication successfully, we recommend using the more secure [Microsoft Entra ID](/entra/fundamentals/whatis) for authentication which is demonstrated in the next code sample. Getting started with [Microsoft Entra ID] will require some additional [prerequisites](https://www.npmjs.com/package/@azure/identity).
205
-
206
-
## [**TypeScript**](#tab/typescript)
207
-
208
-
```typescript
209
-
import {
210
-
DefaultAzureCredential,
211
-
getBearerTokenProvider,
212
-
} from"@azure/identity";
213
-
import"dotenv/config";
214
-
import { AzureOpenAI } from"openai";
215
-
importtype {
216
-
ChatCompletion,
217
-
ChatCompletionCreateParamsNonStreaming,
218
-
} from"openai/resources/index";
219
-
220
-
// You will need to set these environment variables or edit the following values
0 commit comments