I had the same issue and resolved it by updating api-version
query parameter. Specifically,
# Before
openai.api_version = "2022-12-01"
# After
openai.api_version = "2023-03-15-preview"
FYI, I am using Python 3.10.9 and openai==0.27.6.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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
I had the same issue and resolved it by updating api-version
query parameter. Specifically,
# Before
openai.api_version = "2022-12-01"
# After
openai.api_version = "2023-03-15-preview"
FYI, I am using Python 3.10.9 and openai==0.27.6.
After upgrading python version to 3.8 and later, my issue was resolved.
I ran into this issue tonight and found two problems that others might be having as well:
openai
library, resulting in a URL like: https://xxxxxxxx.openai.azure.com//openai/deployments/...
(note the double slashes).2022-12-01
, but when I switched to 2023-03-15-preview
it worked.Hope this helps save a few headaches. :-)
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 have the same errror, once moved code into Azure App Service. From local everything works fine, but once deployed into app service same error "python result: openai.error.InvalidRequestError: Resource not found" arise.
Any suggestion? Permission issue? I simply used endpoint provide by portal and key
Does anyone already faced same issue? Thanks