Skip to content

Commit 360b736

Browse files
committed
file rename
1 parent b97aad1 commit 360b736

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
title: Import an Azure OpenAI API as REST API - Azure API Management
3+
description: How to import an Azure OpenAI API as a REST API from its OpenAPI specification.
4+
ms.service: api-management
5+
author: dlepow
6+
ms.author: danlep
7+
ms.topic: how-to
8+
ms.date: 02/22/2024
9+
ms.custom: template-how-to
10+
---
11+
12+
# Import an Azure OpenAI API as a REST API
13+
14+
This article shows how to import an [Azure OpenAI](/azure/ai-services/openai/overview) API into an Azure API Management instance from its OpenAPI specification. After importing the API as a REST API, you can manage and secure it, and publish it to developers.
15+
16+
## Prerequisites
17+
18+
- An existing API Management instance. [Create one if you haven't already](get-started-create-service-instance.md).
19+
- Access granted to Azure OpenAI in the desired Azure subscription.
20+
You can apply for access to Azure OpenAI by completing the form at https://aka.ms/oai/access. Open an issue on this repo to contact us if you have an issue.
21+
- An Azure OpenAI resource with a model deployed. For more information about model deployment, see the [resource deployment guide](../ai-services/openai/how-to/create-resource.md).
22+
23+
Make a note of the deployment ID (name). You'll need it when you test the imported API in API Management.
24+
25+
## Download the OpenAPI specification
26+
27+
Download the OpenAPI specification for an endpoint that your model supports. For example, download the OpenAPI specification for the [chat completion endpoint](https://github.com/Azure/azure-rest-api-specs/blob/main/specification/cognitiveservices/data-plane/AzureOpenAI/inference/stable/2023-05-15/inference.json) of the GPT-35-Turbo and GPT-4 models.
28+
29+
1. In a text editor, open the specification file that you downloaded.
30+
1. In the `servers` element in the specification, substitute the name of your Azure OpenAI resource endpoint for the placeholder values in the specification. The following example `servers` element is updated with the `contoso.openai.azure.com` resource endpoint.
31+
```json
32+
[...]
33+
"servers": [
34+
{
35+
"url": "https://contoso.openai.azure.com/openai",
36+
"variables": {
37+
"endpoint": {
38+
"default": "contoso.openai.azure.com"
39+
}
40+
}
41+
}
42+
],
43+
[...]
44+
```
45+
1. Make a note of the value of the API `version` in the specification. You'll need it to test the API. Example: `2023-05-15`.
46+
47+
## Add OpenAPI specification to API Management
48+
49+
50+
1. In the [Azure portal](https://portal.azure.com), navigate to your API Management instance.
51+
1. In the left menu, select **APIs** > **+ Add API**.
52+
1. Under **Define a new API**, select **OpenAPI**. Enter a **Display name** and **Name** for the API and enter an **API URL suffix**.
53+
1. Select **Create**.
54+
55+
The API is imported and displays operations from the OpenAPI specification.
56+
57+
[!INCLUDE [api-management-test-api-portal](../../includes/api-management-test-api-portal.md)]
58+
59+
> [!IMPORTANT]
60+
> Authentication to the OpenAI API requires an API key or a managed identity. To configure authentication using API Management policies, see [Authenticate and authorize to Azure OpenAI API](api-management-authenticate-authorize-azure-openai.md).
61+
62+
[!INCLUDE [api-management-define-api-topics.md](../../includes/api-management-define-api-topics.md)]
63+
64+
## Related content
65+
66+
* [Azure OpenAI Service as a central capability with Azure API Management](/samples/azure/enterprise-azureai/enterprise-azureai/)
67+
* [Azure API Management - Azure OpenAI sample](https://github.com/galiniliev/apim-azure-openai-sample)

0 commit comments

Comments
 (0)