From cc194a357173461462c4366843b8e0961ea01ca5 Mon Sep 17 00:00:00 2001 From: Christopher Varjas Date: Fri, 10 Jan 2025 15:39:05 -0500 Subject: [PATCH] use identified api key when creating OpenAI clients --- libs/langchain/langchain/chains/moderation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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(