Not able to use Moderation package of openai in python

response = openai.Moderation.create(
    input="Sample text goes here" )

The above code snippet returns:

AttributeError: module ‘openai’ has no attribute ‘Moderation’

We tried with different versions of python but it shows the same error message.

Can anyone suggest, how to overcome this ?

Here’s the API reference for moderation.

Also, what’s the version of openai installed on your environment? Did you use pip to install?

Thanks!! :slightly_smiling_face:
I upgraded the openai version and it worked.

1 Like