Skip to content

AttributeError: module 'openai' has no attribute 'ChatCompletion' #253

@emilycowe

Description

@emilycowe

Describe the bug

Hello.

I cant access gpt-3.5-turbo with python because I seem to be getting the error " AttributeError: module ‘openai’ has no attribute ‘ChatCompletion’"

I have updated to openai v0.27.0, as well as tried using new API keys just incase that was causing the issue. Ive double checked that I actually have updated to the new version of openai 0.27.0 by running “pip list”. Ive also tried " pip install --upgrade openai " and “pip install openai-0.27.0-py3-none-any.whl”

Im not sure what else I can try, does anyone have any ideas?
Thanks.

To Reproduce

import os
import openai
openai.api_key = os.getenv("key")

completion = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "user", "content": "Hello!"}
]
)

print(completion.choices[0].message)

Code snippets

No response

OS

macOS

Python version

Python v3.11.2

Library version

openai 0.27.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions