Creating a reusable client

Gemini suggestion - creating a reusable client

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
Will Bonde
2025-07-03 11:51:21 -04:00
committed by GitHub
parent 2cf6951228
commit 62f7d96bbb

View File

@@ -77,8 +77,10 @@ class ChatOpenRouter(BaseChatModel):
Returns:
AsyncOpenAI: An instance of the AsyncOpenAI client with OpenRouter base URL.
"""
client_params = self._get_client_params()
return AsyncOpenAI(**client_params)
if not hasattr(self, '_client'):
client_params = self._get_client_params()
self._client = AsyncOpenAI(**client_params)
return self._client
@property
def name(self) -> str: