Hendelser
17. mars, 21 - 21. mars, 10
Bli med i meetup-serien for å bygge skalerbare AI-løsninger basert på virkelige brukstilfeller med andre utviklere og eksperter.
Registrer deg nåDenne nettleseren støttes ikke lenger.
Oppgrader til Microsoft Edge for å dra nytte av de nyeste funksjonene, sikkerhetsoppdateringene og den nyeste tekniske støtten.
APPLIES TO: All API Management tiers
This article shows two options to import an Azure OpenAI Service API into an Azure API Management instance as a REST API:
An existing API Management instance. Create one if you haven't already.
An Azure OpenAI resource with a model deployed. For more information about model deployment, see the resource deployment guide.
Make a note of the ID (name) of the deployment. You'll need it when you test the imported API in API Management.
Permissions to grant access to the Azure OpenAI resource from the API Management instance.
You can import an Azure OpenAI API directly from Azure OpenAI Service to API Management.
Obs!
Currently, this feature isn't available in workspaces.
When you import the API, API Management automatically configures:
To import an Azure OpenAI API to API Management:
In the Azure portal, navigate to your API Management instance.
In the left menu, under APIs, select APIs > + Add API.
Under Create from Azure resource, select Azure OpenAI Service.
On the Basics tab:
Select the Azure OpenAI resource that you want to import.
Optionally select an Azure OpenAI API version. If you don't select one, the latest production-ready REST API version is used by default.
Enter a Display name and optional Description for the API.
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.
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
.
Optionally select one or more products to associate with the API. Select Next.
On the Policies tab, optionally enable policies to monitor and manage Azure OpenAI API token consumption.
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.
After settings are validated, select Create.
Alternatively, manually download the OpenAPI specification for the Azure OpenAI REST API and add it to API Management as an OpenAPI API.
Download the OpenAPI specification for the Azure OpenAI REST API, such as the 2024-02-01 GA version.
In a text editor, open the specification file that you downloaded.
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:
https://contoso.openai.azure.com/openai
contoso.openai.azure.com
[...]
"servers": [
{
"url": "https://contoso.openai.azure.com/openai",
"variables": {
"endpoint": {
"default": "contoso.openai.azure.com"
}
}
}
],
[...]
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
.
/openai
to access the Azure OpenAI API endpoints in your API Management instance. Example: my-openai-api/openai
.The API is imported and displays operations from the OpenAPI specification.
To authenticate to the Azure OpenAI API, you supply an API key or a managed identity. If you imported the Azure OpenAI API directly to your API Management instance, authentication using the API Management instance's managed identity is automatically configured.
If you added the Azure OpenAI API from its OpenAPI specification, you need to configure authentication. For more information about configuring authentication using API Management policies, see Authenticate and authorize to Azure OpenAI API.
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.
Select the API you created in the previous step.
Select the Test tab.
Select an operation that's compatible with the model you deployed in the Azure OpenAI resource. The page displays fields for parameters and headers.
In Template parameters, enter the following values:
Enter other parameters and headers as needed. Depending on the operation, you may need to configure or update a Request body.
Obs!
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. 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.
Select Send.
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.
In addition to the azure-openai-token-limit
and azure-openai-emit-token-metric
policies that you can configure when importing an Azure OpenAI Service API, API Management provides the following caching policies to help you optimize performance and reduce latency for Azure OpenAI APIs:
azure-openai-semantic-cache-store
azure-openai-semantic-cache-lookup
Hendelser
17. mars, 21 - 21. mars, 10
Bli med i meetup-serien for å bygge skalerbare AI-løsninger basert på virkelige brukstilfeller med andre utviklere og eksperter.
Registrer deg nåOpplæring
Modul
Gerenciar suas APIs de IA generativa com o Gerenciamento de API do Azure - Training
Saiba como gerenciar APIs de IA generativa com o Gerenciamento de API do Azure.
Sertifisering
Microsoft Certified: Azure AI Engineer Associate - Certifications
Crie e implemente uma solução de IA do Azure usando os serviços de IA do Azure, a Pesquisa de IA do Azure e o OpenAI do Azure.
Dokumentasjon
Autenticar na API do OpenAI do Azure – Gerenciamento de API do Azure - Azure API Management
Opções para autenticar e autorizar às APIs do OpenAI do Azure usando o Gerenciamento de API do Azure. Inclui a chave de API, identidade gerenciada e autorização do OAuth 2.0.
Recursos do gateway GenAI no Gerenciamento de API do Azure
Saiba mais sobre as políticas e os recursos do Gerenciamento de API do Azure para gerenciar APIs de IA gerativas, como limitação de taxa de token, balanceamento de carga e cache semântico.
Referência da política de Gerenciamento de API do Azure – azure-openai-token-limit
Referência para a política azure-openai-token-limit disponível para uso no Gerenciamento de API do Azure. Fornece uso, configurações e exemplos de políticas.