Get or create a singleton Groq client with the given configuration. Args: api_key: Groq API key Returns: Groq client instance
(api_key: str)
| 234 | |
| 235 | |
| 236 | def get_groq_client(api_key: str) -> Groq: |
| 237 | """ |
| 238 | Get or create a singleton Groq client with the given configuration. |
| 239 | |
| 240 | Args: |
| 241 | api_key: Groq API key |
| 242 | |
| 243 | Returns: |
| 244 | Groq client instance |
| 245 | """ |
| 246 | cache_key = _get_cache_key("groq", api_key=api_key) |
| 247 | |
| 248 | with _client_cache_lock: |
| 249 | cached_client = _get_cached_client(cache_key) |
| 250 | if cached_client is not None: |
| 251 | return cast(Groq, cached_client) |
| 252 | |
| 253 | client = Groq(api_key=api_key) |
| 254 | _store_client(cache_key, client) |
| 255 | return client |
| 256 | |
| 257 | |
| 258 | def get_async_groq_client(api_key: str) -> AsyncGroq: |
searching dependent graphs…