You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support api_key parameter in Moderation.create method #122
create method in Moderation class initializes a new instance by calling parent constructor without any parameters. That's why it's impossible make Moderationendpoint calls without setting API key as environment variable or setting it through openai.api_key in contrast to Completion class.
How to reproduce
import openai
openai.api_key = None
moderator = openai.Moderation(api_key=api_key)
text = "hello world"
response = moderator.create(input=text, model="text-moderation-stable")
> AuthenticationError: No API key provided. You can set your API key in code using 'openai.api_key = <API-KEY>',
or you can set the environment variable OPENAI_API_KEY=<API-KEY>).
If your API key is stored in a file, you can point the openai module at it with 'openai.api_key_path = <PATH>'.
You can generate API keys in the OpenAI web interface. See https://onboard.openai.com for details, or email support@openai.com if you have any questions.
Activity
[-]Support api_key parameter in Moderation class[/-][+]Support api_key parameter in Moderation.create method[/+]hallacy commentedon Sep 18, 2022
Hey @zafercavdar! Thanks for reporting the issue. I'll continue the discussion on the PR just to keep the conversation in one place