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

Anonymous
2024-09-12T11:19:08.1733333+00:00

Hi everyone!

I am developing a RAG chatbot. I have tried different models using the AzureOpenAI center. Therefore, I had to change to a different region and therefore had to set up a new Azure OpenAI account than that I was using initially.

With the code for the chatbot, I have already managed to get through the error I am getting right now:

I am always getting the same error:

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

With the new and the old Azure OpenAI account, I am not able to resolve this error. I have checked the key and endpoint are correct etc. I am still getting this error.

I also tried minimal code example like the one below.

I'd appreciate any help!

Thanks a lot in advance!

Best,

Johanna

Minimal code example(https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/switching-endpoints?source=recommendations):

Load environment variables for Azure OpenAI

from langchain.chat_models import AzureChatOpenAI

from langchain.schema import HumanMessage

os.environ['AZURE_OPENAI_API_KEY'] = 'xxxxxxxxxxx'

os.environ['AZURE_OPENAI_ENDPOINT'] = 'https://****.openai.azure.com/'

import os

from openai import AzureOpenAI

client = AzureOpenAI(

api_key=os.getenv("AZURE_OPENAI_API_KEY"),  

api_version="2024-05-13", #used a different version number for the other Azure OpenAI account 

azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT")

)

completion = client.completions.create(

model="myexamplename", # This must match the custom deployment name you chose for your model.

prompt="<prompt>"

)

chat_completion = client.chat.completions.create(

model="gpt-4o", # model = "deployment_name".

messages="<messages>"

)

embedding = client.embeddings.create(

model="text-embedding-ada-002", # model = "deployment_name".

input="<input>"

)

gives:

NotFoundError: Error code: 404 - {'error': {'code': '404', 'message': 'Res
Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
4,098 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Daniel Fang 1,060 Reputation points MVP
    2024-09-17T10:00:51.7066667+00:00

    Hi Kemper

    Try out my code below, it worked for me.

    the issue is from api version most likely. You had api_version as '2024-05-13' and i get same error as your 404. if updated to 2024-07-01-preview, the call will get a response.

    You might be using the samples from here.

    https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/switching-endpoints

    import os
    from openai import AzureOpenAI
    
    client = AzureOpenAI(
        api_key='53f4ec2340964xxxxx',
        api_version="2024-07-01-preview",  # you had '
        azure_endpoint='https://xxxxx.openai.azure.com/',
    )
    
    
    response = client.chat.completions.create(
                    model="completions", # your deployment model name
                    messages=[
                        {"role": "system", "content": "You are a helpful assistant."},
                        {"role": "user", "content": "Who won the world series in 2020?"}
                    ]
                )
    
    print(response)
    
    
    1 person found this answer helpful.
    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.