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/api-management/api-management-authenticate-authorize-azure-openai.md
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ description: Options to authenticate and authorize to Azure OpenAI APIs using Az
5
5
author: dlepow
6
6
ms.service: azure-api-management
7
7
ms.topic: concept-article
8
-
ms.date: 01/23/2025
8
+
ms.date: 04/01/2025
9
9
ms.author: danlep
10
10
ms.collection: ce-skilling-ai-copilot
11
11
---
@@ -101,6 +101,9 @@ Following are steps to configure your API Management instance to use a managed i
101
101
</set-header>
102
102
```
103
103
104
+
> [!TIP]
105
+
> An alternative to using the `authentication-managed-identity` and `set-header` policies shown in this example is to configure a [backend](backends.md) resource that directs API requests to the Azure OpenAI Service endpoint. In the backend configuration, enable managed identity authentication to the Azure OpenAI Service. Azure API Management automates these steps when importing an API directly from Azure OpenAI Service. For more information, see [Import API from Azure OpenAI Service](azure-openai-api-from-specification.md#option-1-import-api-from-azure-openai-service).
106
+
104
107
## OAuth 2.0 authorization using identity provider
105
108
106
109
To enable more fine-grained access to OpenAPI APIs by particular users or clients, you can preauthorize access to the Azure OpenAI API using OAuth 2.0 authorization with Microsoft Entra ID or another identity provider. For background, see [Protect an API in Azure API Management using OAuth 2.0 authorization with Microsoft Entra ID](api-management-howto-protect-backend-with-aad.md).
Copy file name to clipboardExpand all lines: articles/api-management/azure-openai-api-from-specification.md
+24-15Lines changed: 24 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ ms.service: azure-api-management
5
5
author: dlepow
6
6
ms.author: danlep
7
7
ms.topic: how-to
8
-
ms.date: 01/23/2025
8
+
ms.date: 04/01/2025
9
9
ms.collection: ce-skilling-ai-copilot
10
10
ms.custom: template-how-to, build-2024
11
11
---
@@ -29,6 +29,10 @@ Learn more about managing AI APIs in API Management:
29
29
- An Azure OpenAI resource with a model deployed. For more information about model deployment, see the [resource deployment guide](/azure/ai-services/openai/how-to/create-resource).
30
30
31
31
Make a note of the ID (name) of the deployment. You'll need it when you test the imported API in API Management.
32
+
33
+
> [!NOTE]
34
+
> API Management policies such as [azure-openai-token-limit](azure-openai-token-limit-policy.md) and [azure-openai-emit-token-metric](azure-openai-emit-token-metric-policy.md) are supported for certain API endpoints exposed through specific Azure OpenAI Service models. For more information, see [Supported Azure OpenAI Service models](azure-openai-token-limit-policy.md#supported-azure-openai-service-models).
35
+
32
36
- Permissions to grant access to the Azure OpenAI resource from the API Management instance.
33
37
34
38
## Option 1. Import API from Azure OpenAI Service
@@ -39,11 +43,11 @@ You can import an Azure OpenAI API directly from Azure OpenAI Service to API Man
39
43
40
44
When you import the API, API Management automatically configures:
41
45
42
-
* Operations for each of the Azure OpenAI [REST API endpoints](/azure/ai-services/openai/reference).
46
+
* Operations for each of the Azure OpenAI [REST API endpoints](/azure/ai-services/openai/reference)
43
47
* A system-assigned identity with the necessary permissions to access the Azure OpenAI resource.
44
-
* A [backend](backends.md) resource and [set-backend-service](set-backend-service-policy.md) policy that direct API requests to the Azure OpenAI Service endpoint.
45
-
*An [authentication-managed-identity](authentication-managed-identity-policy.md) policy that can authenticate to the Azure OpenAI resource using the instance's system-assigned identity.
46
-
* (optionally) Policies to help you monitor and manage token consumption by the Azure OpenAI API.
48
+
* A [backend](backends.md) resource and a [set-backend-service](set-backend-service-policy.md) policy that direct API requests to the Azure OpenAI Service endpoint.
49
+
*Authentication to the Azure OpenAI backend using the instance's system-assigned managed identity.
50
+
* (optionally) Policies to help you monitor and manage the Azure OpenAI API.
47
51
48
52
To import an Azure OpenAI API to API Management:
49
53
@@ -55,14 +59,19 @@ To import an Azure OpenAI API to API Management:
55
59
56
60
1. On the **Basics** tab:
57
61
1. Select the Azure OpenAI resource that you want to import.
58
-
1. Optionally select an **Azure OpenAI API version**. If you don't select one, the latest production-ready REST API version is used by default.
62
+
1. Optionally select an **Azure OpenAI API version**. If you don't select one, the latest production-ready REST API version is used by default. Make a note of the version you selected. You'll need it to test the API.
59
63
1. Enter a **Display name** and optional **Description** for the API.
60
64
1. In **Base URL**, append a path that your API Management instance uses to access the Azure OpenAI API endpoints. If you enable **Ensure OpenAI SDK compatibility** (recommended), `/openai` is automatically appended to the base URL.
61
65
62
66
For example, if your API Management gateway endpoint is `https://contoso.azure-api.net`, set a **Base URL** similar to `https://contoso.azure-api.net/my-openai-api/openai`.
63
67
1. Optionally select one or more products to associate with the API. Select **Next**.
64
-
1. On the **Policies** tab, optionally enable policies to monitor and manage Azure OpenAI API token consumption.
65
-
If selected, enter settings or accept defaults that define the `azure-openai-token-limit` and `azure-openai-emit-token-metric` policies for your API. You can also set or update the policy configuration later. Select **Review + Create**.
68
+
1. On the **Policies** tab, optionally enable policies to monitor and manage Azure OpenAI API token consumption. You can also set or edit policies later.
69
+
70
+
If selected, enter settings or accept defaults that define the following policies (see linked articles for prerequisites and configuration details):
1. After settings are validated, select **Create**.
67
76
68
77
## Option 2. Add an OpenAPI specification to API Management
@@ -71,13 +80,13 @@ Alternatively, manually download the OpenAPI specification for the Azure OpenAI
71
80
72
81
### Download the OpenAPI specification
73
82
74
-
Download the OpenAPI specification for the Azure OpenAI REST API, such as the [2024-02-01 GA version](https://github.com/Azure/azure-rest-api-specs/blob/main/specification/cognitiveservices/data-plane/AzureOpenAI/inference/stable/2024-02-01/inference.json).
83
+
Download the OpenAPI specification for the Azure OpenAI REST API, such as the [2024-10-21 GA version](https://github.com/Azure/azure-rest-api-specs/blob/main/specification/cognitiveservices/data-plane/AzureOpenAI/inference/stable/2024-10-21/inference.json).
75
84
76
85
1. In a text editor, open the specification file that you downloaded.
77
86
1. In the `servers` element in the specification, substitute the name of your Azure OpenAI Service endpoint in the placeholder values of `url` and `default` endpoint in the specification. For example, if your Azure OpenAI Service endpoint is `contoso.openai.azure.com`, update the `servers` element with the following values:
@@ -93,7 +102,7 @@ Download the OpenAPI specification for the Azure OpenAI REST API, such as the [2
93
102
],
94
103
[...]
95
104
```
96
-
1. Make a note of the value of the API `version` in the specification. You'll need it to test the API. Example: `2024-02-01`.
105
+
1. Make a note of the value of the API `version` in the specification. You'll need it to test the API. Example: `2024-10-21`.
97
106
98
107
### Add OpenAPI specification to API Management
99
108
@@ -113,7 +122,7 @@ If you added the Azure OpenAI API from its OpenAPI specification, you need to co
113
122
114
123
## Test the Azure OpenAI API
115
124
116
-
To ensure that your Azure OpenAI API is working as expected, test it in the API Management test console. You need to supply a model deployment ID (name) configured in the Azure OpenAI resource to test the API.
125
+
To ensure that your Azure OpenAI API is working as expected, test it in the API Management test console. You need to supply a model deployment ID (name) configured in the Azure OpenAI resource and the API version to test the API.
117
126
118
127
1. Select the API you created in the previous step.
119
128
1. Select the **Test** tab.
@@ -128,7 +137,8 @@ To ensure that your Azure OpenAI API is working as expected, test it in the API
128
137
> In the test console, API Management automatically populates an **Ocp-Apim-Subscription-Key** header, and configures the subscription key of the built-in [all-access subscription](api-management-subscriptions.md#all-access-subscription). This key enables access to every API in the API Management instance. Optionally display the **Ocp-Apim-Subscription-Key** header by selecting the "eye" icon next to the **HTTP Request**.
129
138
1. Select **Send**.
130
139
131
-
When the test is successful, the backend responds with a successful HTTP response code and some data. Appended to the response is token usage data to help you monitor and manage your Azure OpenAI API consumption.
140
+
When the test is successful, the backend responds with a successful HTTP response code and some data. Appended to the response is token usage data to help you monitor and manage your Azure OpenAI API token consumption.
141
+
132
142
:::image type="content" source="media/azure-openai-api-from-specification/api-response-usage.png" alt-text="Screenshot of token usage data in API response in the portal." :::
133
143
134
144
## Caching policies for Azure OpenAI APIs
@@ -138,5 +148,4 @@ In addition to the `azure-openai-token-limit` and `azure-openai-emit-token-metri
Copy file name to clipboardExpand all lines: articles/api-management/azure-openai-emit-token-metric-policy.md
+4-12Lines changed: 4 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ author: dlepow
6
6
7
7
ms.service: azure-api-management
8
8
ms.topic: reference
9
-
ms.date: 09/26/2024
9
+
ms.date: 04/01/2025
10
10
ms.author: danlep
11
11
ms.collection: ce-skilling-ai-copilot
12
12
ms.custom:
@@ -65,19 +65,11 @@ The `azure-openai-emit-token-metric` policy sends custom metrics to Application
65
65
| name | A string or policy expression. Name of dimension. | Yes | N/A |
66
66
| value | A string or policy expression. Value of dimension. Can only be omitted if `name` matches one of the default dimensions. If so, value is provided as per dimension name. | No | N/A |
67
67
68
-
### Default dimension names that may be used without value
0 commit comments