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)
---->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/ in create(cls, timeout, *args, **kwargs)
16 Creates a new completion for the provided prompt and parameters.
—> 18 See OpenAI API for a list
19 of valid parameters.
20 “”"

~/opt/anaconda3/lib/python3.8/site-packages/openai/api_resources/abstract/ 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/ in convert_to_openai_object(resp, api_key, api_version, organization, engine, plain_old_data)

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

~/opt/anaconda3/lib/python3.8/site-packages/openai/ 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,


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:

1 Like


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!