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: articles/ai-services/openai/includes/chatgpt-javascript.md
+4-136Lines changed: 4 additions & 136 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,7 +68,7 @@ Your app's _package.json_ file will be updated with the dependencies.
68
68
69
69
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.
> 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).
350
-
351
-
## [**TypeScript**](#tab/typescript)
352
-
353
-
```typescript
354
-
import {
355
-
DefaultAzureCredential,
356
-
getBearerTokenProvider,
357
-
} from"@azure/identity";
358
-
import"dotenv/config";
359
-
import { AzureOpenAI } from"openai";
360
-
importtype {
361
-
ChatCompletion,
362
-
ChatCompletionCreateParamsNonStreaming,
363
-
} from"openai/resources/index";
364
-
365
-
// You will need to set these environment variables or edit the following values
Copy file name to clipboardExpand all lines: articles/ai-services/openai/includes/javascript.md
+4-139Lines changed: 4 additions & 139 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,7 +66,7 @@ Your app's _package.json_ file will be updated with the dependencies.
66
66
67
67
Open a command prompt where you created the new project, and create a new file named Completion.js. Copy the following code into the Completion.js file.
constdeployment="gpt-35-turbo-instruct"; //The deployment name for your completions API model. The instruct model is the only new model that supports the legacy API.
> 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).
> If your receive the error: *Error occurred: OpenAIError: The `apiKey` and `azureADTokenProvider` arguments are mutually exclusive; only one can be passed at a time.* You may need to remove a pre-existing environment variable for the API key from your system. Even though the Microsoft Entra ID code sample is not explicitly referencing the API key environment variable, if one is present on the system executing this sample, this error will still be generated.
0 commit comments