Open AI error: "InvalidRequestError: Resource not found". Please help to fix.

AIoTMR Architect
5
Reputation points
Dear Team
Could you please help us fixing this error? Code has been taken from sample given and key has been tried as key1 and key2 both separately. Same error is found.
python result: openai.error.InvalidRequestError: Resource not found
#Note: The openai-python library support for Azure OpenAI is in preview.
import os
import openai
openai.api_type = "azure"
openai.api_base = "https://explore123.openai.azure.com/"
openai.api_version = "2022-12-01"
#openai.api_key = os.getenv("66bcffe0ed6c440dba76940d04a7bb03")
openai.api_key = "<key>"
response = openai.Completion.create(
engine="text-davinci-002",
prompt="Classify the following news article into 1 of the following categories: categories: [Business, Tech, Politics, Sport, Entertainment]\n\nnews article: Donna Steffensen Is Cooking Up a New Kind of Perfection. The Internet’s most beloved cooking guru has a buzzy new book and a fresh new perspective:\n\nClassified category: Business",
temperature=0,
max_tokens=60,
top_p=1,
frequency_penalty=0,
presence_penalty=0,
best_of=1,
stop=None)
print(response)
Result:
Traceback (most recent call last):
File "test1.py", line 19, in <module>
stop=None)
File "/home/user/.local/lib/python3.6/site-packages/openai/api_resources/completion.py", line 31, in create
return super().create(*args, **kwargs)
File "/home/user/.local/lib/python3.6/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 67, in create
"post", url, params, headers, stream=stream
File "/home/user/.local/lib/python3.6/site-packages/openai/api_requestor.py", line 129, in request
resp = self.interpret_response(rbody, rcode, rheaders, stream=stream)
File "/home/user/.local/lib/python3.6/site-packages/openai/api_requestor.py", line 348, in interpret_response
return self.interpret_response_line(rbody, rcode, rheaders, stream)
File "/home/user/.local/lib/python3.6/site-packages/openai/api_requestor.py", line 368, in interpret_response_line
rbody, rcode, resp.data, rheaders, stream_error=stream_error
openai.error.InvalidRequestError: Resource not found
======================================================================
Curl Result: -> no error shown but how can i see the result?
curl https://explore123.openai.azure.com/openai/deployments/text-davinci-002/completions?api-version=2022-12-01 -H "Content-Type: application/json" -H "api-key: 66bcffe0ed6c440dba76940d04a7bb03" -d '{
"prompt": "Classify the following news article into 1 of the following categories: categories: [Business, Tech, Politics, Sport, Entertainment]\n\nnews article: Donna Steffensen Is Cooking Up a New Kind of Perfection. The Internet’s most beloved cooking guru has a buzzy new book and a fresh new perspective:\n\nClassified category: Business",
"max_tokens": 60,
"temperature": 0,
"frequency_penalty": 0,
"presence_penalty": 0,
"top_p": 1,
"best_of": 1,
"stop": null
}'
{"id":"cmpl-6rLFaLc8zTYo8oHbjA5WNm5Tp6i7k","object":"text_completion","created":1678171090,"model":"text-davinci-002","choices":[{"text":"","index":0,"finish_reason":"stop","logprobs":null}],"usage":{"prompt_tokens":73,"total_tokens":73}}
Regards
Champak
1 vote
I'm having the same issue. New instance.
InvalidRequestError
: Resource not found
Just to be sure I checked in the portal:
and I checked it in the Tool:
And, just to be sure I put that end point into the browser:
The resource exists, it clearly has that end point, but it looks like it's still listed as 'not found'? Thoughts?
Same problem with me.
my previous answer doesn't work for most of the cases. So I deleted it.
Please, use the endpoint shown in the Azure Portal.
Question about your post: is
<|im_start|>
part of the query syntax? Is there documentation around this? As far as I had seen the docs only take simple text strings. If there is inline text and substring operations I'd like to learn more.I have the same issiue. I cant resolve it.
I have the same issue and I cant resolve it with the answer here :)
Sign in to comment
3 answers
Sort by: Most helpful
After upgrading python version to 3.8 and later, my issue was resolved.
Yup! This solution worked. Thaks for this. The docs say 3.7.1 + but I had 3.7.0. I switched to 3.9.16 and it worked just fine.
Sign in to comment
I was also stuck with a 404 Resource Not Found response when attempting to access my deployment of chat completions (with correct API base and Key set). Networking remains on the default 'All Networks', I'm using Postman running on development laptop.
I've discovered white space characters at the end of API base & key, and at the end of the api-version parameter - a result of copying from the Azure portal and / or the ChatGPT playground. This wasn't obvious until viewing the cURL code snippet in Postman. Deleting these solved the problem.
I don't see any white space in the key or code that I have. This isn't likely going to be the cause for most. Thanks for sharing though.
Sign in to comment
I'll clean up the docs to make this more clear this week.
This corresponds to the unique endpoint address for your Azure OpenAI resource where the gpt-35-model is deployed. You can find this by going to Keys and Endpoint for your resource.
Great, thanks
I'm assuming that its the deployment name:
And the resource is this. I'm using the same variables that is in the documentation.
Just to check, I tried with the GPT-35-turbo:
Here is the full code:
The end delivers the same
InvalidRequestError: Resource not found
. Can you help me with what I'm not seeing?I'm still getting
InvalidRequestError
: Resource not found
can you help me understand what is different about my process? What am I missing?Not sure if it helps, but when I try this with:
openai.api_base = "https://exodestai.api.cognitive.microsoft.com/"
per @Marlos Bosso above, I got a different error:
APIConnectionError
: Unexpected error communicating with OpenAI. If this problem persists, let us know at support@openai.com. (Network error: ConnectionError: HTTPSConnectionPool(host='exodestai.api.cognitive.microsoft.com', port=443): Max retries exceeded with url: //v1/engines/exo-gpt-35/completions (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 11001] getaddrinfo failed')) (url=https://exodestai.api.cognitive.microsoft.com//v1/engines/exo-gpt-35/completions))
Could it be that there is a different API url?
Just to check to see if it was my deployment, I deleted the resources and created new ones.
I confirmed that it built the resources in the same way, and got all of the keys and values right. Still no dice. I think that the domain in the docs might be wrong.
Sign in to comment
Activity