AttributeError: module 'openai.api_resources' has no attribute 'Model'

Hi Guys,

I have been working with the openai GPT-3 API in a jupyter notebook for a couple of months now, and suddenly I get the following error message all time, even when running the following simple line of code:


AttributeError Traceback (most recent call last)
in
6
---->7 response = openai.Completion.create(engine=“davinci”, prompt=“This is a test”, max_tokens=5)

~/opt/anaconda3/lib/python3.8/site-packages/openai/api_resources/completion.py in create(cls, timeout, *args, **kwargs)
16 Creates a new completion for the provided prompt and parameters.
17
—> 18 See OpenAI API for a list
19 of valid parameters.
20 “”"

~/opt/anaconda3/lib/python3.8/site-packages/openai/api_resources/abstract/engine_api_resource.py in create(cls, api_key, api_base, idempotency_key, request_id, api_version, organization, **params)
122 else MAX_TIMEOUT
123 )
→ 124 if self.timeout < 0:
125 del self.timeout
126 break

~/opt/anaconda3/lib/python3.8/site-packages/openai/util.py in convert_to_openai_object(resp, api_key, api_version, organization, engine, plain_old_data)

~/opt/anaconda3/lib/python3.8/site-packages/openai/util.py in get_object_classes()
140 else:
141 return obj
→ 142
143
144 def merge_dicts(x, y):

~/opt/anaconda3/lib/python3.8/site-packages/openai/object_classes.py in
7 “file”: api_resources.File,
8 “fine-tune”: api_resources.FineTune,
----> 9 “model”: api_resources.Model,
10 }

AttributeError: module ‘openai.api_resources’ has no attribute ‘Model’

Does anyone know what causes this error and how to solve it?

Kind regards,

Louk

Hello @l.h.r.deloijer! Welcome to the OpenAI community!

Do you possibly have a Python file that’s named the same as one of the imported modules?

If it clashes with any imported modules, you’ll get that error, in which case you’ll need to rename that file to something else.

Same issue as this person here:
https://githubmemory.com/repo/openai/openai-python/issues/3

1 Like

Thanks,

the problem was that I indeed named the python file the same as a module I imported :sweat_smile:

It is solved now

1 Like

Glad I was able to help!