pythonazureopenai-apiazure-openai

Why do I get a "resource not found" error when switching resource groups for Azure OpenAI?


When I use my second Resource Group in West US (my first one is Germany), I always get the following error:

Error code: 404 - {'error': {'code': '404', 'message': 'Resource not found'}}

My Python code:

from openai import AzureOpenAI


client = AzureOpenAI(
  azure_endpoint = "https://XXXX.openai.azure.com/", 
  api_key="XXXXX",  
  api_version="2024-05-13"
)


message_text = [{"role":"system","content":"You are an AI assistant that helps people find information."},{"role":"user","content":"Was ist 4x6?"}]

completion = client.chat.completions.create(
  model="GPT-4o", # model = "deployment_name"
  messages = message_text,
  temperature=0.7,
  max_tokens=800,
  top_p=0.95,
  frequency_penalty=0,
  presence_penalty=0,
  stop=None
)

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

Model Deployment:

Model Deployment

I already checked double network, API, and endpoint. In my first resource group the code works, and in second, it doesn't.

I want to use US West because there are always the new models like gpt-4o.


Solution

  • The error is because of the API version you are using. The version given, 2024-05-13, is a model version and not the API version.

    enter image description here

    Use the API version 2024-02-15-preview and it should work:

    enter image description here

    Code in

    enter image description here