diff --git a/libs/langchain/langchain/chains/moderation.py b/libs/langchain/langchain/chains/moderation.py index 9467b8894c12b..f72cae6cc8d7d 100644 --- a/libs/langchain/langchain/chains/moderation.py +++ b/libs/langchain/langchain/chains/moderation.py @@ -67,8 +67,8 @@ def validate_environment(cls, values: Dict) -> Any: if values["openai_pre_1_0"]: values["client"] = openai.Moderation else: - values["client"] = openai.OpenAI() - values["async_client"] = openai.AsyncOpenAI() + values["client"] = openai.OpenAI(api_key=openai_api_key) + values["async_client"] = openai.AsyncOpenAI(api_key=openai_api_key) except ImportError: raise ImportError(