skip to Main Content

I have some problems with my Azure Openai..
When i use my second Recource Group in westus (my first one is germany), i always get the folowing error:

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

My quick and dirty 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)

Bild von Model Deployment:
Model Deployment

I already checked double network, api and endpoint.
In my first recource group the code work and in second doesent.

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

best regards

I already checked double network, api and endpoint. In my first recource group the code work and in second doesent.

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

2

Answers


  1. Chosen as BEST ANSWER

    when i click on playground --> show code --> python.

    it shows me only a example code:

    import os
    from openai import AzureOpenAI
    from azure.identity import DefaultAzureCredential, get_bearer_token_provider
    
    endpoint = os.environ["AZURE_OPENAI_ENDPOINT"]
    deployment = os.environ["CHAT_COMPLETIONS_DEPLOYMENT_NAME"]
    search_endpoint = os.environ["SEARCH_ENDPOINT"]
    search_index = os.environ["SEARCH_INDEX"]
          
    token_provider = get_bearer_token_provider(DefaultAzureCredential(), "https://cognitiveservices.azure.com/.default")
          
    client = AzureOpenAI(
        azure_endpoint=endpoint,
        azure_ad_token_provider=token_provider,
        api_version="2024-02-01",
    )
          
    completion = client.chat.completions.create(
        model=deployment,
        messages=[
            {
                "role": "user",
                "content": "Who is DRI?",
            },
            {
                "role": "assistant",
                "content": "DRI stands for Directly Responsible Individual of a service. Which service are you asking about?"
            },
            {
                "role": "user",
                "content": "Opinion mining service"
            }
        ],
        extra_body={
            "data_sources": [
                {
                    "type": "azure_search",
                    "parameters": {
                        "endpoint": search_endpoint,
                        "index_name": search_index,
                        "authentication": {
                            "type": "system_assigned_managed_identity"
                        }
                    }
                }
            ]
        }
    )
          
    print(completion.to_json())
    

    thx for the link and your help (https://learn.microsoft.com/en-us/azure/ai-services/openai/reference)

    best regards


  2. The error is because of api version you are using.

    The version given 2024-05-13 is model version and not the api version.

    enter image description here

    Use the api version 2024-02-15-preview it works.

    enter image description here

    Code in

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search