Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
APPLIES TO: All API Management tiers
You can import AI model endpoints deployed in Azure AI Foundry to your API Management instance as APIs. Use AI gateway policies and other capabilities in API Management to simplify integration, improve observability, and enhance control over the model endpoints.
Learn more about managing AI APIs in API Management:
Client compatibility options
API Management supports two client compatibility options for AI APIs. Choose the option suitable for your model deployment. The option determines how clients call the API and how the API Management instance routes requests to the AI service.
Azure AI - Manage model endpoints in Azure AI Foundry that are exposed through the Azure AI Model Inference API.
Clients call the deployment at a
/models
endpoint such as/my-model/models/chat/completions
. Deployment name is passed in the request body. Use this option if you want flexibility to switch between models exposed through the Azure AI Model Inference API and those deployed in Azure OpenAI Service.Azure OpenAI Service - Manage model endpoints deployed in Azure OpenAI Service.
Clients call the deployment at an
/openai
endpoint such as/openai/deployments/my-deployment/chat/completions
. Deployment name is passed in the request path. Use this option if your AI service only includes Azure OpenAI Service model deployments.
Prerequisites
- An existing API Management instance. Create one if you haven't already.
- An Azure AI service in your subscription with one or more models deployed. Examples include models deployed in Azure AI Foundry or Azure OpenAI Service.
Import AI Foundry API using the portal
Use the following steps to import an AI API to API Management.
When you import the API, API Management automatically configures:
- Operations for each of the API's REST API endpoints
- A system-assigned identity with the necessary permissions to access the AI service deployment.
- A backend resource and a set-backend-service policy that direct API requests to the AI service endpoint.
- Authentication to the backend using the instance's system-assigned managed identity.
- (optionally) Policies to help you monitor and manage the API.
To import an AI Foundry 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 AI Foundry.
On the Select AI service tab:
- Select the Subscription in which to search for AI services. To get information about the model deployments in a service, select the deployments link next to the service name.
- Select an AI service.
- Select Next.
- Select the Subscription in which to search for AI services. To get information about the model deployments in a service, select the deployments link next to the service name.
On the Configure API tab:
Enter a Display name and optional Description for the API.
In Base path, enter a path that your API Management instance uses to access the deployment endpoint.
Optionally select one or more Products to associate with the API.
In Client compatibility, select either of the following based on the types of client you intend to support. See Client compatibility options for more information.
- Azure OpenAI - Select this option if your clients only need to access Azure OpenAI Service model deployments.
- Azure AI - Select this option if your clients need to access other models in Azure AI Foundry.
Select Next.
On the Manage token consumption tab, optionally enter settings or accept defaults that define the following policies to help monitor and manage the API:
On the Apply semantic caching tab, optionally enter settings or accept defaults that define the policies to help optimize performance and reduce latency for the API:
On the AI content safety, optionally enter settings or accept defaults to configure the Azure AI Content Safety service to block prompts with unsafe content:
Select Review.
After settings are validated, select Create.
Test the AI API
To ensure that your AI API is working as expected, test it in the API Management test console.
Select the API you created in the previous step.
Select the Test tab.
Select an operation that's compatible with the model deployment. The page displays fields for parameters and headers.
Enter parameters and headers as needed. Depending on the operation, you might need to configure or update a Request body.
Note
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 language model token consumption.
Related content
- API import limitations
- Import an OpenAPI specification
- Import a SOAP API
- Import a SOAP API and convert it to REST
- Import an App Service API
- Import a container app API
- Import a WebSocket API
- Import a GraphQL API
- Import a GraphQL schema and set up field resolvers
- Import a function app API
- Import a logic app API
- Import a Service Fabric service
- Import an Azure AI Foundry API
- Import an Azure OpenAI API
- Import an LLM API
- Import an OData API
- Import SAP OData metadata
- Import a gRPC API
- Edit an API