Edit

Share via


Endpoints for Azure AI Foundry Models

Azure AI Foundry Models enables you to access the most powerful models from leading model providers through a single endpoint and set of credentials. This capability lets you switch between models and use them in your application without changing any code.

This article explains how the Azure AI Foundry services (formerly known as Azure AI Services) organize models and how to use the inference endpoint to access them.

Deployments

Azure AI Foundry uses deployments to make models available. Deployments give a model a name and set specific configurations. You can access a model by using its deployment name in your requests.

A deployment includes:

  • A model name
  • A model version
  • A provisioning or capacity type1
  • A content filtering configuration1
  • A rate limiting configuration1

1 These configurations can change depending on the selected model.

An Azure AI Foundry resource can have many model deployments. You only pay for inference performed on model deployments. Deployments are Azure resources, so they're subject to Azure policies.

For more information about creating deployments, see Add and configure model deployments.

Endpoints

Azure AI Foundry services provide multiple endpoints depending on the type of work you want to perform:

Azure AI inference endpoint

The Azure AI inference endpoint, usually of the form https://<resource-name>.services.ai.azure.com/models, enables you to use a single endpoint with the same authentication and schema to generate inference for the deployed models in the resource. All Foundry Models support this capability. This endpoint follows the Azure AI Model Inference API, which supports the following modalities:

  • Text embeddings
  • Image embeddings
  • Chat completions

Routing

The inference endpoint routes requests to a specific deployment by matching the name parameter in the request to the name of the deployment. This setup means that deployments work as an alias for a model under certain configurations. This flexibility lets you deploy a model multiple times in the service but with different configurations if needed.

An illustration showing how routing works for a model by indicating the model name in the 'model' parameter of the payload request.

For example, if you create a deployment named Mistral-large, you can invoke that deployment as follows:

Install the package azure-ai-inference using your package manager, like pip:

pip install azure-ai-inference

Then, you can use the package to consume the model. The following example shows how to create a client to consume chat completions:

import os
from azure.ai.inference import ChatCompletionsClient
from azure.core.credentials import AzureKeyCredential

client = ChatCompletionsClient(
    endpoint="https://<resource>.services.ai.azure.com/models",
    credential=AzureKeyCredential(os.environ["AZURE_INFERENCE_CREDENTIAL"]),
)

Explore our samples and read the API reference documentation to get yourself started.

For a chat model, you can create a request as follows:

from azure.ai.inference.models import SystemMessage, UserMessage

response = client.complete(
    messages=[
        SystemMessage(content="You are a helpful assistant."),
        UserMessage(content="Explain Riemann's conjecture in 1 paragraph"),
    ],
    model="mistral-large"
)

print(response.choices[0].message.content)

If you specify a model name that doesn't match any model deployment, you get an error that the model doesn't exist. You control which models are available to users by creating model deployments. For more information, see add and configure model deployments.

Azure OpenAI inference endpoint

The Azure OpenAI API exposes the full capabilities of OpenAI models and supports more features like assistants, threads, files, and batch inference. You might also access non-OpenAI models through this route.

Azure OpenAI endpoints, usually of the form https://<resource-name>.openai.azure.com, work at the deployment level and each deployment has its own associated URL. However, you can use the same authentication mechanism to consume the deployments. For more information, see the reference page for Azure OpenAI API.

An illustration showing how Azure OpenAI deployments contain a single URL for each deployment.

Each deployment has a URL that's formed by concatenating the Azure OpenAI base URL and the route /deployments/<model-deployment-name>.

Install the package openai using your package manager, like pip:

pip install openai --upgrade

Then, you can use the package to consume the model. The following example shows how to create a client to consume chat completions:

import os
from openai import AzureOpenAI
    
client = AzureOpenAI(
    azure_endpoint = "https://<resource>.services.ai.azure.com"
    api_key=os.getenv("AZURE_INFERENCE_CREDENTIAL"),  
    api_version="2024-10-21",
)
response = client.chat.completions.create(
    model="deepseek-v3-0324", # Replace with your model dpeloyment name.
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Explain Riemann's conjecture in 1 paragraph"}
    ]
)

print(response.model_dump_json(indent=2)

For more information about how to use the Azure OpenAI endpoint, see Azure OpenAI in Azure AI Foundry Models documentation.

Keyless authentication

Models deployed to Azure AI Foundry Models in Azure AI services support keyless authorization by using Microsoft Entra ID. Keyless authorization enhances security, simplifies the user experience, reduces operational complexity, and provides robust compliance support for modern development. It makes keyless authorization a strong choice for organizations adopting secure and scalable identity management solutions.

To use keyless authentication, configure your resource and grant access to users to perform inference. After you configure the resource and grant access, authenticate as follows:

Install the package azure-ai-inference using your package manager, like pip:

pip install azure-ai-inference

Then, you can use the package to consume the model. The following example shows how to create a client to consume chat completions with Entra ID:

import os
from azure.ai.inference import ChatCompletionsClient
from azure.identity import DefaultAzureCredential

client = ChatCompletionsClient(
    endpoint="https://<resource>.services.ai.azure.com/models",
    credential=DefaultAzureCredential(),
    credential_scopes=["https://cognitiveservices.azure.com/.default"],
)

Limitations

  • You can't use Azure OpenAI Batch with the Foundry Models endpoint. You have to use the dedicated deployment URL as explained in Batch API support in Azure OpenAI documentation.
  • Real-time API isn't supported in the inference endpoint. Use the dedicated deployment URL.