Edit

Endpoints for Microsoft Foundry Models (classic)

Currently viewing: Foundry (classic) portal version - Switch to version for the new Foundry portal

Microsoft Foundry Models provides access to a wide variety of models from many providers through a single endpoint and set of credentials. This capability lets you switch between models and use them in your application without making code changes.

This article explains how the Foundry services organize models and how to use the inference endpoint to access them.

Important

Azure AI Inference beta SDK is deprecated and will be retired on August 26, 2026. Switch to the generally available OpenAI/v1 API with a stable OpenAI SDK. Follow the migration guide to switch to OpenAI/v1, using the SDK for your preferred programming language.

Prerequisites

Deployments

Foundry uses deployments as aliases for model access. A deployment gives a model a name and a set of configurations. You access a model by using its deployment name in your requests.

A deployment defines:

  • 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.

A 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

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

Azure AI inference endpoint

Note

The Azure AI Inference SDK samples in this section remain fully functional. However, for new projects, we recommend using the Azure OpenAI endpoint with the OpenAI SDK. For migration guidance, see Migrate from Azure AI Inference SDK to OpenAI SDK.

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 can also use it to access non-OpenAI models.

Azure OpenAI endpoints are formatted as https://<resource-name>.openai.azure.com. Endpoints map to deployments, and each deployment has its own associated URL. However, you can use the same authentication mechanism to consume more than one deployment. 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.

Deployment URLs are formed by concatenating the Azure OpenAI base URL and the route /deployments/<model-deployment-name>. When you use the OpenAI v1 API, call the /openai/v1/ route on the base URL, https://<resource-name>.openai.azure.com/openai/v1/, and pass the deployment name in the model field of your request. The /openai/v1/ route uses implicit versioning, so you don't pass an api-version.

The following examples use the Responses API, which supports the latest inference features.

Note

The Responses API works with Azure OpenAI models and with Foundry Models sold by Azure that support it, such as DeepSeek, Llama, and Grok models. If a deployment doesn't support the Responses API, the request returns 400 Model not supported. In that case, use the Chat Completions API by calling client.chat.completions.create instead.

Use API key authentication

You can authenticate inference requests with an API key from your Foundry resource. API keys are quick to set up, but they grant full access to the resource, are hard to scope to specific users or actions, and require manual rotation to stay secure. For production workloads, use keyless authentication with Microsoft Entra ID instead.

In the following example, deepseek-v3-0324 is the name of a model deployment in the Microsoft Foundry resource. Replace it with your own deployment name, and store your API key in the AZURE_INFERENCE_CREDENTIAL environment variable.

Install the openai package by using pip:

pip install openai --upgrade

Create a client that points to the Azure OpenAI v1 endpoint, and then generate a response. The /openai/v1/ route uses implicit versioning, so you don't pass an api-version. Pass your deployment name in the model field:

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://<resource>.openai.azure.com/openai/v1/",
    api_key=os.environ["AZURE_INFERENCE_CREDENTIAL"],
)

response = client.responses.create(
    model="deepseek-v3-0324",  # Replace with your model deployment name.
    input="Explain the Riemann hypothesis in one paragraph.",
)

print(response.output_text)

For more information about how to use the Azure OpenAI endpoint, see Azure OpenAI SDK language support.

Use keyless authentication

Deployed Foundry Models support keyless authorization with Microsoft Entra ID. Keyless authorization enhances security, simplifies the user experience, reduces operational complexity, and provides robust compliance support. Use keyless authorization if your organization uses 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 OpenAI SDK using a package manager like pip:

pip install openai

For Microsoft Entra ID authentication, also install:

pip install azure-identity

Use the package to consume the model. The following example shows how to create a client and make a test call to the Responses API by using Microsoft Entra ID and your model deployment.

Replace <resource> with your Foundry resource name. Find it in the Azure portal or by running az cognitiveservices account list. Replace deepseek-v3-0324 with your actual deployment name.

from openai import OpenAI
from azure.identity import DefaultAzureCredential, get_bearer_token_provider

token_provider = get_bearer_token_provider(
    DefaultAzureCredential(), 
    "https://ai.azure.com/.default"
)

client = OpenAI(
    base_url="https://<resource>.openai.azure.com/openai/v1/",
    api_key=token_provider,
)

response = client.responses.create(
    model="deepseek-v3-0324",  # Replace with your model deployment name.
    input="What is Azure AI?",
)

print(response.output_text)

Expected output

Azure AI is a comprehensive suite of artificial intelligence services and tools from Microsoft that enables developers to build intelligent applications. It includes services for natural language processing, computer vision, speech recognition, and machine learning capabilities.

Reference: OpenAI Python SDK and DefaultAzureCredential class.

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.