pythonopenai-apiazure-openaigpt-4o-mini

The chatCompletion operation does not work with the specified model gpt-4o-mini


Context

I have below the Python code.

client = AzureOpenAI(
    api_key = os.getenv("AZURE_OPENAI_API_KEY"),  
    api_version = os.getenv('AZURE_OPENAI_API_VERSION'),
    azure_endpoint = os.getenv('AZURE_OPENAI_ENDPOINT')
)  
messages = [
    {"role": "user", "content": prompt}
]
response = client.chat.completions.create(
    model="gpt-4o-mini",        
    messages=messages,
    temperature=0,  
)

Issue

I faced the below error.

openai.BadRequestError: Error code: 400 - 
{
   "error":{
      "code":"OperationNotSupported",
      "message":"The chatCompletion operation does not work with the specified model, gpt-4o-mini. Please choose different model and try again. You can learn more about which models can be used with each operation here: https://go.microsoft.com/fwlink/?linkid=2197993."
   }
}

The above code works fine when I change the model to "gpt-4o"


Solution

  • The Azure region you selected does not support this model. You need to check this list to select the appropriate region, and select the deployment type as "Standard"

    https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models#standard-deployment-model-availability