Issues with API calls to ai.azure.com for Models o1 and Above

Jeremy Seow 5 Reputation points
2025-03-10T18:44:11.2666667+00:00

The endpoint ai.azure.com is not functioning for models o1 and above, while oai.azure.com works fine for all models.

The following errors are encountered:

  • BadRequest: Model {modelName} is enabled only for api versions 2024-12-01-preview and later
  • 401: Access denied due to invalid subscription key or wrong API endpoint. Make sure to provide a valid key for an active subscription and use a correct regional API endpoint for your resource.

What could be the cause of these issues?

Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
3,603 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Prashanth Veeragoni 4,930 Reputation points Microsoft External Staff Moderator
    2025-03-11T04:33:26.9266667+00:00

    Hi Jeremy Seow,

    I understood that you are encountering issues with API calls to ai.azure.com for models O1 and above, while oai.azure.com works fine.

    Understanding the Issue:

    BadRequest Error: Indicates that API Version Mismatch

    The error indicates that the requested model (O1 and above) is only available for API versions 2024-12-01-preview or later.

    If you are using an older API version (e.g., 2023-06-01-preview), the request will fail because the newer models are not supported with outdated API versions.

    401 Access Denied Error: Indicates that Authentication Failure

    This error usually occurs due to

    Incorrect API Key.

    Incorrect endpoint (regional vs. global).

    Subscription does not have access to the requested model.

    The API request is being made to the wrong authentication method (e.g., trying to use ai.azure.com with an API key when it expects Azure Active Directory authentication).

    Possible Resolution Steps:

    Use the Correct API Version:

    Ensure you specify the required API version in your request. Since models O1 and above require 2024-12-01-preview, update your API calls like this:

    headers = {
        "Authorization": f"Bearer {api_key}",
        "Content-Type": "application/json"
    }
    url = f"https://{region}.api.cognitive.microsoft.com/openai/deployments/{deployment_id}/chat/completions?api-version=2024-12-01-preview"
    

    Verify the Endpoint (ai.azure.com vs. oai.azure.com):

    ai.azure.com requires Azure Active Directory (AAD) authentication.

    oai.azure.com supports API key-based authentication.

    Solution:

    If you are using an API key, switch your endpoint to oai.azure.com.

    If you must use ai.azure.com, you need to authenticate via Azure Active Directory.

    Ensure Correct Authentication Method:

    For ai.azure.com (AAD Authentication)

    Use Azure Active Directory (OAuth 2.0) token authentication.

    Retrieve a valid token before making requests:

    import requests
    from azure.identity import DefaultAzureCredential
    credential = DefaultAzureCredential()
    token = credential.get_token("https://cognitiveservices.azure.com/.default")
    headers = {
        "Authorization": f"Bearer {token.token}",
        "Content-Type": "application/json"
    }
    

    For oai.azure.com (API Key Authentication):

    Use your API key in the headers:

    headers = {
        "api-key": "YOUR_OPENAI_API_KEY",
        "Content-Type": "application/json"
    }
    

    Validate Your Subscription and Model Access:

    Go to Azure Portal → OpenAI Service → Model Deployments.

    Check if:

    Your subscription includes access to O1 and newer models.

    The models are properly deployed in your resource region.

    Your API key or AAD authentication has the necessary permissions.

    Verify Regional Endpoints:

    If using ai.azure.com, ensure your endpoint is:

    https://<your-region>.api.cognitive.microsoft.com/
    

    If using oai.azure.com, ensure it matches the deployment:

    https://<your-resource-name>.openai.azure.com/
    

    Hope this helps. Do let us know if you any further queries.   

    Thank you.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.