OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

OpenAI API error: "You tried to access openai.Model, but this is no longer supported in openai\>=1.0.0"

  • Thread starter Thread starter José Alonso
  • Start date Start date
J

José Alonso

Guest
Using Visual Studio Code and PyCharm, after install openai (pip install openai) a strange error is bugging me - please help.

If for example I write:

Code:
import openai

openai.api_key = "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

lista_de_modelos = openai.Model.list()
print(lista_de_modelos)

it fails and I get an this error:

Code:
PS C:\\proyectoVS_Python\> & "C:/Users/kitkatuser/AppData/Local/Programs/Python/Python312/python.exe" "c:/proyectoVS_Python/import os.py"
Traceback (most recent call last):
File "c:\\proyectoVS_Python\\import os.py", line 5, in \<module\>
lista_de_modelos = openai.Model.list()
^^^^^^^^^^^^^^^^^
File "C:\\Users\\kitkatuser\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\openai_utils_proxy.py", line 22, in __getattr__
return getattr(self.__get_proxied__(), attr)
^^^^^^^^^^^^^^^^^^^^^^
File "C:\\Users\\kitkatuser\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\openai_utils_proxy.py", line 43, in __get_proxied__  
return self.__load__()
^^^^^^^^^^^^^^^
File "C:\\Users\\kitkatuser\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\openai\\lib_old_api.py", line 33, in __load__
raise APIRemovedInV1(symbol=self.\_symbol)
openai.lib.\_old_api.APIRemovedInV1:

You tried to access openai.Model, but this is no longer supported in openai\>=1.0.0 - see the README at https://github.com/openai/openai-python for the API.

You can run `openai migrate` to automatically upgrade your codebase to use the 1.0.0 interface.

Alternatively, you can pin your installation to the old version, e.g. `pip install openai==0.28`

A detailed migration guide is available here: https://github.com/openai/openai-python/discussions/742

PS C:\\proyectoVS_Python\>

What I´m doing wrong? why I can't access openAI, I've try several keys, the same program and process to install works well with other friends. Using Pycharm shows similar. I'm used several programs to try but always similar response! I don't find a solution or similar problems! I'm really confused!Please Help
<p>Using Visual Studio Code and PyCharm, after install openai (pip install openai) a strange error is bugging me - please help.</p>
<p>If for example I write:</p>
<pre><code>import openai

openai.api_key = "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

lista_de_modelos = openai.Model.list()
print(lista_de_modelos)
</code></pre>
<p>it fails and I get an this error:</p>
<pre><code>PS C:\\proyectoVS_Python\> & "C:/Users/kitkatuser/AppData/Local/Programs/Python/Python312/python.exe" "c:/proyectoVS_Python/import os.py"
Traceback (most recent call last):
File "c:\\proyectoVS_Python\\import os.py", line 5, in \<module\>
lista_de_modelos = openai.Model.list()
^^^^^^^^^^^^^^^^^
File "C:\\Users\\kitkatuser\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\openai_utils_proxy.py", line 22, in __getattr__
return getattr(self.__get_proxied__(), attr)
^^^^^^^^^^^^^^^^^^^^^^
File "C:\\Users\\kitkatuser\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\openai_utils_proxy.py", line 43, in __get_proxied__
return self.__load__()
^^^^^^^^^^^^^^^
File "C:\\Users\\kitkatuser\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\openai\\lib_old_api.py", line 33, in __load__
raise APIRemovedInV1(symbol=self.\_symbol)
openai.lib.\_old_api.APIRemovedInV1:

You tried to access openai.Model, but this is no longer supported in openai\>=1.0.0 - see the README at https://github.com/openai/openai-python for the API.

You can run `openai migrate` to automatically upgrade your codebase to use the 1.0.0 interface.

Alternatively, you can pin your installation to the old version, e.g. `pip install openai==0.28`

A detailed migration guide is available here: https://github.com/openai/openai-python/discussions/742

PS C:\\proyectoVS_Python\>
</code></pre>
<p>What I´m doing wrong? why I can't access openAI, I've try several keys, the same program and process to install works well with other friends. Using Pycharm shows similar. I'm used several programs to try but always similar response! I don't find a solution or similar problems! I'm really confused!Please Help</p>
 
Top