Skip to main content
Version: 3.6.2-rc.1

Connect Azure OpenAI models

This guide shows how to connect a model deployed in your own Azure OpenAI resource, such as GPT-4o, so your tenant can use it in Chat and through the platform API, the same way as the platform's own models.

Before you start​

  1. The Editor or Owner role in your tenant. See Roles in a tenant.
  2. Access to an Azure subscription. To create a resource and copy its keys, you need the Cognitive Services Contributor role. To deploy a model, Cognitive Services OpenAI Contributor is also enough. See Role-based access control for Azure OpenAI.

Get your Azure values​

You need four values from Azure: the Deployment name, Endpoint, Key and API version when connecting to a model deployed in your own Azure OpenAI resource.

  1. Create an Azure OpenAI resource

    Skip this step if you already have one. In the Azure portal, select Create a resource, search for Azure OpenAI and select Create. See Create and deploy an Azure OpenAI resource.

  2. Deploy a model

    Open Microsoft Foundry select the model you want to deploy.

  3. Get the endpoint and API key

    After deploying the model, come back to Microsoft Foundry and open the model you just deployed. There you can find the Deployment name, Endpoint and Key.

  4. Pick an API version

    Choose a dated version from Azure OpenAI API versions, or the one your existing code uses, such as 2024-02-01. Chat works without it, but calls from code don't.

Connect to an Azure OpenAI model​

  1. In the sidebar of the CM portal, go to Models → External Models → Connect external model.

  2. Fill in the form:

    FieldEnterExample
    ProviderAzure OpenAI—
    Provider model IDThe Deployment name from step 3. Not the model's name. It can't be changed later.gpt-4o-prod
    API keyThe Key from step 33f9a...
    Base URLThe Endpoint from step 3https://my-resource.openai.azure.com
    API versionThe version from step 4. The form doesn't require it, but calls from code fail without it.2024-02-01
    API model idThe name your apps use to call the model. It copies Provider model ID until you edit it. It must be unique on the platform and can't be changed later.gpt-4o
    Display nameThe name people see in the portal and in ChatGPT-4o (Azure)
    Model typeChat, Embedding, Transcription or Guardrail. Choosing it ticks the matching modalities. See Choose the model type and modalities.Chat
    Input modalitiesWhat the model accepts. Keep the ticked ones and add any the model also supports. See Choose the model type and modalities.Text, Image
    Output modalitiesWhat the model returns. Keep the ticked ones. See Choose the model type and modalities.Text
    Context lengthThe model's maximum tokens per request. Optional, but Azure doesn't report it, and apps and Chat use it to size prompts.128000
  3. Select Connect model. The model appears on the External Models tab.

  4. Share it. Right now only you and the tenant's Owners can use it. Open the model, go to the Users tab and share it with the people, groups or whole tenant that should use it. See Share a resource.

note

Connect model saves the form without checking anything with Azure. If a value is wrong, you only find out when the first request fails, so test the model to verify it works.

Test it​

In Chat: select Open chat in the sidebar, pick your model and send a message.

From code:

  1. Open the model and copy its full API model id. The platform puts your tenant's name in front of the id you entered, so gpt-4o becomes something like acme/gpt-4o.

  2. On the same page, select Create API key. It opens the key form with this model already granted.

  3. Copy the API URL from the bottom of the sidebar, then call the model:

    curl "<API URL>/v1/chat/completions" \
    -H "Authorization: Bearer <your platform API key>" \
    -H "Content-Type: application/json" \
    -d '{"model": "acme/gpt-4o", "messages": [{"role": "user", "content": "Hello"}]}'

    Use your platform API key, not the Azure key.

warning

Test from code even if Chat works. Chat doesn't use the API version, so it works without one. Calls to Chat Completions, Embeddings and Audio transcriptions fail when API version is empty. To fix it, open the model, edit its provider connection and enter an API version.

Good to know​

  • Which APIs work: Responses, Chat Completions, Embeddings and Audio transcriptions. The Messages API also works, but it uses Anthropic's format and the platform translates it.
  • The API version is only used for Chat Completions, Embeddings and Audio transcriptions. Responses and Messages calls go to Azure's /openai/v1/responses without it.
  • Azure bills usage to your Azure subscription. The platform also counts the tokens in your tenant's usage.
  • Prompts are processed in your Azure resource's region. Choose a region that fits your organization's data policy.
  • Azure rate limits apply. Your deployment's tokens-per-minute quota limits how much traffic it can handle.

Troubleshooting​

ProblemWhat to check
Requests fail with "deployment not found" or a 404 from AzureProvider model ID matches the Azure deployment name exactly, including upper and lower case. It can't be edited, so connect the model again with the right name.
Every request fails with an authentication errorThe API key belongs to the same Azure resource as the Base URL.
Chat works, but calls from code to Chat Completions, Embeddings or Audio transcriptions failAPI version is set, and your Azure resource supports it. If it's empty, edit the model's provider connection and enter one.
Every request fails with a connection or 404 errorBase URL is the plain endpoint, with no path, query or trailing /.
Connect model fails because the id is takenAnother model, alias or preset agent already uses that API model id. Choose a unique one.
The model works for you but others can't see itShare it on the model's Users tab.
The model is missing from ChatModel type is Chat, and the model is shared with you.
A call from code returns 404 with model "..." not found or not readySet model to the full API model id, with your tenant's name in front.
A call from code is refused with a permission errorThe API key is granted this model. Create one from the model's page with Create API key.