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

Zhou, Jie (周杰) 20 Reputation points
2024-09-04T06:36:54.55+00:00

running test code:

deployment_name = 'gpt-4o-v1' #This will correspond

client = AzureOpenAI(

azure_endpoint = "https://****.openai.azure.com/" ,

api_key='**',

api_version = '2024-05-13'

)

print('### using gpt-4o-v1 ...')

chat_messages = [{"role": "system", "content": "You are an experienced assistant of Elekta . You know the products of Monaco very well. You can answer any questions about Elekta and Monaco."}]

rsp = openai.ChatCompletion.create(

rsp = client.chat.completions.create(

model = deployment_name,

messages = chat_messages,

temperature = 0

)

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

then occur error:

Traceback (most recent call last):

File "C:\Users\Administrator\AppData\Local\Temp\1\ipykernel_16000\2497901775.py", line 10, in <module>

rsp = client.chat.completions.create(

File "C:\ProgramData\Anaconda3\envs\dbgpt_env\lib\site-packages\openai_utils_utils.py", line 274, in wrapper

return func(*args, **kwargs)

File "C:\ProgramData\Anaconda3\envs\dbgpt_env\lib\site-packages\openai\resources\chat\completions.py", line 668, in create

return self._post(

File "C:\ProgramData\Anaconda3\envs\dbgpt_env\lib\site-packages\openai_base_client.py", line 1260, in post

return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))

File "C:\ProgramData\Anaconda3\envs\dbgpt_env\lib\site-packages\openai_base_client.py", line 937, in request

return self._request(

File "C:\ProgramData\Anaconda3\envs\dbgpt_env\lib\site-packages\openai_base_client.py", line 1041, in _request

raise self._make_status_error_from_response(err.response) from None

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

do you know how to fix this?

this model is worked in Chat playground, but not work by API.

Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
2,920 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. navba-MSFT 23,625 Reputation points Microsoft Employee
    2024-09-09T05:28:38.2266667+00:00

    @Zhou, Jie (周杰) Thanks for your reply. You can select any versions listed in the model dropdown as shown below:

    User's image

    But while calling the Azure Open AI endpoint from your python application, you can use api_version="2024-07-01-preview" OR api_version="2024-05-01-preview" or api_version="2024-04-01-preview".

    Also note, while testing it from the Chat Playground, I confirmed that the Azure Open AI studio chat playground is using 2024-04-01-preview version see below:

    User's image

    If you are encountering the below error:

    AuthenticationError: Error code: 401 - {'error': {'code': 'Unauthorized', 'message': '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.'}}

    Please ensure that you are using the correct API key from the Keys and Endpoints section in your Azure Open AI:

    enter image description here

    Hope this helps.

    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.