Skip to content

Commit 65397f2

Browse files
committed
edit
1 parent 288c29f commit 65397f2

File tree

5 files changed

+128
-45
lines changed

5 files changed

+128
-45
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
manager: nitinme
3+
author: mrbullwinkle
4+
ms.author: mbullwin
5+
ms.service: azure-ai-openai
6+
ms.topic: include
7+
ms.date: 10/0//2024
8+
ms.custom: devex-track-js, devex-track-typescript
9+
---
10+
11+
[!INCLUDE [environment-variables](environment-variables.md)]
12+
13+
Add additional environment variables for the deployment name and API version:
14+
* `AZURE_OPENAI_DEPLOYMENT_NAME`: Your deployment name as shown in the Azure portal.
15+
* `OPENAI_API_VERSION`: Learn more about [API Versions](/azure/ai-services/openai/concepts/model-versions).
16+
17+
# [Command Line](#tab/command-line)
18+
19+
```cmd
20+
setx AZURE_OPENAI_DEPLOYMENT_NAME "REPLACE_WITH_YOUR_DEPLOYMENT_NAME"
21+
setx OPENAI_API_VERSION "REPLACE_WITH_YOUR_API_VERSION"
22+
```
23+
24+
# [PowerShell](#tab/powershell)
25+
26+
```powershell
27+
[System.Environment]::SetEnvironmentVariable('AZURE_OPENAI_DEPLOYMENT_NAME', 'REPLACE_WITH_YOUR_DEPLOYMENT_NAME', 'User')
28+
[System.Environment]::SetEnvironmentVariable('OPENAI_API_VERSION', 'REPLACE_WITH_YOUR_API_VERSION', 'User')
29+
```
30+
31+
# [Bash](#tab/bash)
32+
33+
```bash
34+
export AZURE_OPENAI_DEPLOYMENT_NAME="REPLACE_WITH_YOUR_DEPLOYMENT_NAME"
35+
export OPENAI_API_VERSION="REPLACE_WITH_YOUR_API_VERSION"
36+
```
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
manager: nitinme
3+
author: mrbullwinkle
4+
ms.author: mbullwin
5+
ms.service: azure-ai-openai
6+
ms.topic: include
7+
ms.date: 10/0//2024
8+
ms.custom: devex-track-js, devex-track-typescript
9+
---
10+
|Variable name | Value |
11+
|--------------------------|-------------|
12+
| `ENDPOINT` | This value can be found in the **Keys and Endpoint** section when examining your resource from the Azure portal. Alternatively, you can find the value in **Azure OpenAI Studio** > **Playground** > **View code**. An example endpoint is: `https://docs-test-001.openai.azure.com/`.|
13+
| `API-KEY` | This value can be found in the **Keys and Endpoint** section when examining your resource from the Azure portal. You can use either `KEY1` or `KEY2`.|
14+
| `DEPLOYMENT-NAME` | This value will correspond to the custom name you chose for your deployment when you deployed a model. This value can be found under **Resource Management** > **Model Deployments** in the Azure portal or alternatively under **Management** > **Deployments** in Azure OpenAI Studio.|
15+
16+
Go to your resource in the Azure portal. The **Keys and Endpoint** can be found in the **Resource Management** section. Copy your endpoint and access key as you'll need both for authenticating your API calls. You can use either `KEY1` or `KEY2`. Always having two keys allows you to securely rotate and regenerate keys without causing a service disruption.
17+
18+
:::image type="content" source="../media/quickstarts/endpoint.png" alt-text="Screenshot of the overview blade for an OpenAI Resource in the Azure portal with the endpoint & access keys location circled in red." lightbox="../media/quickstarts/endpoint.png":::
19+
20+
[!INCLUDE [environment-variables](environment-variables.md)]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
manager: nitinme
3+
author: mrbullwinkle
4+
ms.author: mbullwin
5+
ms.service: azure-ai-openai
6+
ms.topic: include
7+
ms.date: 10/0//2024
8+
ms.custom: devex-track-js, devex-track-typescript
9+
---
10+
|Variable name | Value |
11+
|--------------------------|-------------|
12+
| `RESOURCE_NAME` | This value can be found in the Azure portal for the Azure OpenAI resource.
13+
| `ENDPOINT` | This value can be found in the **Keys and Endpoint** section when examining your resource from the Azure portal. Alternatively, you can find the value in **Azure OpenAI Studio** > **Playground** > **View code**. An example endpoint is: `https://docs-test-001.openai.azure.com/`.|
14+
| `DEPLOYMENT-NAME` | This value will correspond to the custom name you chose for your deployment when you deployed a model. This value can be found under **Resource Management** > **Model Deployments** in the Azure portal or alternatively under **Management** > **Deployments** in Azure OpenAI Studio.|
15+
16+
[!INCLUDE [environment-variables](environment-variables-without-keys.md)]
17+

articles/ai-services/openai/includes/assistants-javascript.md

Lines changed: 15 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -68,44 +68,26 @@ For passwordless authentication, you need to
6868

6969
To successfully make a call against the Azure OpenAI service, you'll need the following:
7070
71-
|Variable name | Value |
72-
|--------------------------|-------------|
73-
| `ENDPOINT` | This value can be found in the **Keys and Endpoint** section when examining your resource from the Azure portal. Alternatively, you can find the value in **Azure OpenAI Studio** > **Playground** > **View code**. An example endpoint is: `https://docs-test-001.openai.azure.com/`.|
74-
| `API-KEY` | This value can be found in the **Keys and Endpoint** section when examining your resource from the Azure portal. You can use either `KEY1` or `KEY2`.|
75-
| `DEPLOYMENT-NAME` | This value will correspond to the custom name you chose for your deployment when you deployed a model. This value can be found under **Resource Management** > **Model Deployments** in the Azure portal or alternatively under **Management** > **Deployments** in Azure OpenAI Studio.|
71+
#### [TypeScript without key (Recommended)](#tab/typescript)
7672
77-
Go to your resource in the Azure portal. The **Keys and Endpoint** can be found in the **Resource Management** section. Copy your endpoint and access key as you'll need both for authenticating your API calls. You can use either `KEY1` or `KEY2`. Always having two keys allows you to securely rotate and regenerate keys without causing a service disruption.
73+
[!INCLUDE [assistants-keyless-environment-variables](assistants-env-var-without-key.md)]
74+
[!INCLUDE [environment-variables-deployment](assistants-env-var-additional.md)]
7875
79-
:::image type="content" source="../media/quickstarts/endpoint.png" alt-text="Screenshot of the overview blade for an OpenAI Resource in the Azure portal with the endpoint & access keys location circled in red." lightbox="../media/quickstarts/endpoint.png":::
8076
81-
[!INCLUDE [environment-variables](environment-variables.md)]
82-
83-
Add additional environment variables for the deployment name and API version:
84-
* `AZURE_OPENAI_DEPLOYMENT_NAME`: Your deployment name as shown in the Azure portal.
85-
* `OPENAI_API_VERSION`: Learn more about [API Versions](/azure/ai-services/openai/concepts/model-versions).
86-
87-
# [Command Line](#tab/command-line)
88-
89-
```cmd
90-
setx AZURE_OPENAI_DEPLOYMENT_NAME "REPLACE_WITH_YOUR_DEPLOYMENT_NAME"
91-
setx OPENAI_API_VERSION "REPLACE_WITH_YOUR_API_VERSION"
92-
```
77+
#### [TypeScript with key](#tab/typescript-key)
9378
94-
# [PowerShell](#tab/powershell)
79+
[!INCLUDE [assistants-key-environment-variables](assistants-env-var.md)]
80+
[!INCLUDE [environment-variables-deployment](assistants-env-var-additional.md)]
9581
96-
```powershell
97-
[System.Environment]::SetEnvironmentVariable('AZURE_OPENAI_DEPLOYMENT_NAME', 'REPLACE_WITH_YOUR_DEPLOYMENT_NAME', 'User')
98-
[System.Environment]::SetEnvironmentVariable('OPENAI_API_VERSION', 'REPLACE_WITH_YOUR_API_VERSION', 'User')
99-
```
82+
#### [JavaScript without key](#tab/javascript)
10083
101-
# [Bash](#tab/bash)
84+
[!INCLUDE [assistants-keyless-environment-variables](assistants-env-var-without-key.md)]
85+
[!INCLUDE [environment-variables-deployment](assistants-env-var-additional.md)]
10286
103-
```bash
104-
export AZURE_OPENAI_DEPLOYMENT_NAME="REPLACE_WITH_YOUR_DEPLOYMENT_NAME"
105-
export OPENAI_API_VERSION="REPLACE_WITH_YOUR_API_VERSION"
106-
```
87+
#### [JavaScript with key](#tab/javascript-key)
10788
108-
---
89+
[!INCLUDE [assistants-key-environment-variables](assistants-env-var.md)]
90+
[!INCLUDE [environment-variables-deployment](assistants-env-var-additional.md)]
10991
11092
## Create an assistant
11193
@@ -122,7 +104,7 @@ In our code we are going to specify the following values:
122104
123105
An individual assistant can access up to 128 tools including `code interpreter`, as well as any custom tools you create via [functions](../how-to/assistant-functions.md).
124106
125-
#### [TypeScript (Recommended) without key](#tab/typescript)
107+
#### [TypeScript without key (Recommended)](#tab/typescript)
126108
127109
1. Create the `index.ts` file with the following **recommended** passwordless TypeScript module (index.ts):
128110
@@ -364,12 +346,6 @@ An individual assistant can access up to 128 tools including `code interpreter`,
364346
```shell
365347
tsc index.ts
366348
```
367-
368-
1. Sign in to Azure with the following command:
369-
370-
```shell
371-
az login
372-
```
373349
374350
1. Run the code with the following command:
375351
@@ -379,7 +355,7 @@ An individual assistant can access up to 128 tools including `code interpreter`,
379355
380356
#### [JavaScript without key](#tab/javascript)
381357
382-
1. Create the `index.js` file with the following **recommended** passwordless JavaScript module (index.mjs):
358+
1. Create the `index.js` file with the following **recommended** passwordless JavaScript module:
383359
384360
```nodejs
385361
import { AzureOpenAI } from "openai";
@@ -485,7 +461,7 @@ An individual assistant can access up to 128 tools including `code interpreter`,
485461
486462
#### [JavaScript with key](#tab/javascript-key)
487463
488-
1. To use the service key for authentication, you can create the `index.js` file with the following JavaScript module (index.mjs):
464+
1. To use the service key for authentication, you can create the `index.js` file with the following JavaScript module:
489465
490466
```nodejs
491467
import { AzureOpenAI } from "openai";
@@ -569,12 +545,6 @@ An individual assistant can access up to 128 tools including `code interpreter`,
569545
}
570546
```
571547
572-
1. Sign in to Azure with the following command:
573-
574-
```shell
575-
az login
576-
```
577-
578548
1. Run the JavaScript file.
579549
580550
```shell
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: 'Environment variables'
3+
titleSuffix: Azure OpenAI Service
4+
description: set up environment variables for your key and endpoint
5+
#services: cognitive-services
6+
manager: nitinme
7+
ms.service: azure-ai-openai
8+
ms.topic: include
9+
ms.date: 10/08/2024
10+
---
11+
12+
13+
### Environment variables without keys
14+
15+
Create and assign persistent environment variables for your key and endpoint.
16+
17+
[!INCLUDE [Azure key vault](~/reusable-content/ce-skilling/azure/includes/ai-services/security/azure-key-vault.md)]
18+
19+
# [Command Line](#tab/command-line)
20+
21+
```cmd
22+
setx AZURE_OPENAI_RESOURCE "REPLACE_WITH_YOUR_RESOURCE_NAME_HERE"
23+
setx AZURE_OPENAI_ENDPOINT "REPLACE_WITH_YOUR_ENDPOINT_HERE"
24+
```
25+
26+
# [PowerShell](#tab/powershell)
27+
28+
```powershell
29+
[System.Environment]::SetEnvironmentVariable('AZURE_OPENAI_RESOURCE', 'REPLACE_WITH_YOUR_RESOURCE_NAME_HERE', 'User')
30+
[System.Environment]::SetEnvironmentVariable('AZURE_OPENAI_ENDPOINT', 'REPLACE_WITH_YOUR_ENDPOINT_HERE', 'User')
31+
```
32+
33+
# [Bash](#tab/bash)
34+
35+
```bash
36+
export AZURE_OPENAI_RESOURCE="REPLACE_WITH_YOUR_RESOURCE_NAME_HERE"
37+
export AZURE_OPENAI_ENDPOINT="REPLACE_WITH_YOUR_ENDPOINT_HERE"
38+
```
39+
40+
---

0 commit comments

Comments
 (0)