Skip to content

Commit 6954e87

Browse files
committed
edits
1 parent 13c6d6a commit 6954e87

File tree

1 file changed

+29
-37
lines changed
  • articles/ai-services/openai/includes/language-overview

1 file changed

+29
-37
lines changed

articles/ai-services/openai/includes/language-overview/javascript.md

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,6 @@ Feature availability in Azure OpenAI is dependent on what version of the REST AP
2525
npm install openai
2626
```
2727

28-
## Configuration
29-
30-
The `AzureClientOptions` object is used to configure the API client for interfacing with the Azure OpenAI API. The configuration object extends the existing OpenAi `ClientOptions` object. Below are the Azure OpenAI specific properties, their default values, and descriptions:
31-
32-
| Property | Details |
33-
|--|--|
34-
| azureADTokenProvider: `(() => Promise<string>)` | A function that returns an access token for Microsoft Entra (formerly known as Azure Active Directory), invoked on every request.|
35-
| apiKey: `string` | Your API key for authenticating requests. Default environment variable is `AZURE_OPENAI_API_KEY`.|
36-
| apiVersion: `string` | Specifies the API version to use. Default environment variable is `OPENAI_API_VERSION` |
37-
| deployment: `string` | A model deployment. If provided, sets the base client URL to include `/deployments/{deployment}`. Non-deployment endpoints cannot be used (not supported with Assistants APIs).|
38-
| endpoint: `string` | Your Azure OpenAI endpoint.|
39-
4028
## Authentication
4129

4230
# [Microsoft Entra ID](#tab/secure)
@@ -60,14 +48,27 @@ const endpoint = "https://your-azure-openai-resource.com";
6048
const apiVersion = "2024-10-21"
6149
const scope = "https://cognitiveservices.azure.com/.default";
6250
const azureADTokenProvider = getBearerTokenProvider(credential, scope);
51+
const deployment = "gpt-35-turbo";
6352

6453
const client = new AzureOpenAI({
6554
endpoint,
6655
apiVersion,
56+
deployment,
6757
azureADTokenProvider
68-
});
58+
});
6959
```
7060

61+
### Configuration
62+
63+
The `AzureClientOptions` object extends the OpenAI `ClientOptions` object. This Azure-specific client object is used to configure the connection and behavior of the Azure OpenAI client. It includes properties for specifying the properties unique to Azure.
64+
65+
| Property | Details |
66+
|--|--|
67+
| apiVersion: `string` | Specifies the API version to use. |
68+
| azureADTokenProvider: `(() => Promise<string>)` | A function that returns an access token for Microsoft Entra (formerly known as Azure Active Directory), invoked on every request.|
69+
| deployment: `string` | A model deployment. If provided, sets the base client URL to include `/deployments/{deployment}`. Non-deployment endpoints cannot be used (not supported with Assistants APIs).|
70+
| endpoint: `string` | Your Azure OpenAI endpoint with the following format: `https://RESOURCE-NAME.azure.openai.com/`.|
71+
7172
# [API Key](#tab/api-key)
7273

7374
API keys are not recommended for production use because they are less secure than other authentication methods.
@@ -77,38 +78,29 @@ import { AzureKeyCredential } from "@azure/openai";
7778
const apiKey = new AzureKeyCredential("your API key");
7879
const endpoint = "https://your-azure-openai-resource.com";
7980
const apiVersion = "2024-10-21"
81+
const deployment = "gpt-35-turbo";
8082

81-
const client = new AzureOpenAI({ apiKey, endpoint, apiVersion });
83+
const client = new AzureOpenAI({
84+
apiKey,
85+
endpoint,
86+
apiVersion,
87+
deployment
88+
});
8289
```
8390

84-
`AzureOpenAI` can be authenticated with an API key by setting the `AZURE_OPENAI_API_KEY` environment variable or by setting the `apiKey` string property in the [`AzureClientOptions`](#configuration) object when creating the `AzureOpenAI` client.
91+
The `AzureClientOptions` object extends the OpenAI `ClientOptions` object. This Azure-specific client object is used to configure the connection and behavior of the Azure OpenAI client. It includes properties for specifying the properties unique to Azure.
92+
93+
| Property | Details |
94+
|--|--|
95+
| apiKey: `string` | Your API key for authenticating requests. |
96+
| apiVersion: `string` | Specifies the API version to use. |
97+
| deployment: `string` | A model deployment. If provided, sets the base client URL to include `/deployments/{deployment}`. Non-deployment endpoints cannot be used (not supported with Assistants APIs).|
98+
| endpoint: `string` | Your Azure OpenAI endpoint with the following format: `https://RESOURCE-NAME.azure.openai.com/`.|
8599

86100
[!INCLUDE [Azure key vault](~/reusable-content/ce-skilling/azure/includes/ai-services/security/azure-key-vault.md)]
87101

88102
---
89103

90-
## Description
91-
92-
The `AzureClientOptions` object is used to configure the connection and behavior of the Azure Cosmos DB client. It includes properties for specifying the endpoint, authentication credentials, database and container names, consistency level, connection policy, and request timeout.
93-
94-
### Example Usage
95-
96-
```typescript
97-
import { CosmosClient, AzureClientOptions } from "@azure/cosmos";
98-
99-
const options: AzureClientOptions = {
100-
endpoint: process.env.AZURE_COSMOS_DB_ENDPOINT,
101-
key: process.env.AZURE_COSMOS_DB_KEY,
102-
databaseName: process.env.AZURE_COSMOS_DB_DATABASE,
103-
containerName: process.env.AZURE_COSMOS_DB_CONTAINER,
104-
aadCredentials: new DefaultAzureCredential(),
105-
consistencyLevel: "Session",
106-
connectionPolicy: { retryOptions: { maxRetryAttempts: 3 } },
107-
timeout: 60000,
108-
};
109-
110-
const client = new CosmosClient(options);
111-
```
112104

113105
## Audio
114106

0 commit comments

Comments
 (0)