error thrown
(base) sergio@Ubuntu-22-04-Python:~/ Testingdalle$ ./create_painting.py
Traceback (most recent call last):
File “/home/sergio/Testingdalle/./create_painting.py”, line 16, in
openai.Model.list()
File “/home/sergio/.local/lib/python3.10/site-packages/openai/api_resources/abstract/listable_api_resource.py”, line 60, in list
response, _, api_key = requestor.request(
File “/home/sergio/.local/lib/python3.10/site-packages/openai/api_requestor.py”, line 298, in request
resp, got_stream = self._interpret_response(result, stream)
File “/home/sergio/.local/lib/python3.10/site-packages/openai/api_requestor.py”, line 700, in _interpret_response
self._interpret_response_line(
File “/home/sergio/.local/lib/python3.10/site-packages/openai/api_requestor.py”, line 763, in _interpret_response_line
raise self.handle_error_response(
openai.error.InvalidRequestError: Resource not found
I also tried to encode openai variables but didn’t work either e.g. openai.api_key.encode(‘utf-8’)
I can create API keys, curl and postman work, I assume my api account is valid?!
Thank you @_j , I created and run on python 3.9 env but didn’t work; pasting your code returned the same error “Resource not found”. The quote character in my initial code broke when pasting to this post but it’s correct in the script. Any other ideas please?
You’re a member of the given organization name (not the organization id)?
If you have your own account, own payment method supplied or are in free trial, I would go to platform.openai.com and under API keys, select your own organization as default at the bottom, and generate a new API key. Use that key, but no organization line in the code.
If working then, work backwards to discover the breaking modification if you are attempting to use someone else’s organization.
The error only seems widely evoked for Microsoft Azure users, who can pick a different version of the API. You don’t show being an Azure user as being the case in your code.
Thanks @_j I do have an account with Azure and maybe linked to the user email I use for OpenAI, not sure. I tried as you suggested but still can’t get it to work, same error
I am also experiencing the same error. I have Python 3.8 and my keys work using the CURL method. I have revoked keys and created ones, and used all the organizations I am part of and also still getting errors. Since I am paying for GPT-4, this is quite frustrating.
I would also check that your API key is properly stored in the environment variable, if you are using the export command, make sure you are not using " quotes around the API key,
You should end up with something like this, assume the API key is stored correctly, as a test you can just manually enter it into python as openai.api_key = “your_key”
OK. Here is the test I did: I created a new key to start fresh and tested it in two computers: 1) My laptop with the exact same Python version (3.8.10), same OpenAI API (0.28.0), both running WSL in Windows 11.
Test on my laptop works.
Test on a PC w/ the same key and it does not work, and I get the same error.
Created an additional Virtual Environment on the PC, and used the same key, and now it works.
It seems like the Python virtual environment may be corrupt?