Get or create a singleton Cerebras client with the given configuration. Args: api_key: Cerebras API key Returns: Cerebras client instance
(api_key: str)
| 278 | |
| 279 | |
| 280 | def get_cerebras_client(api_key: str) -> Cerebras: |
| 281 | """ |
| 282 | Get or create a singleton Cerebras client with the given configuration. |
| 283 | |
| 284 | Args: |
| 285 | api_key: Cerebras API key |
| 286 | |
| 287 | Returns: |
| 288 | Cerebras client instance |
| 289 | """ |
| 290 | cache_key = _get_cache_key("cerebras", api_key=api_key) |
| 291 | |
| 292 | with _client_cache_lock: |
| 293 | cached_client = _get_cached_client(cache_key) |
| 294 | if cached_client is not None: |
| 295 | return cast(Cerebras, cached_client) |
| 296 | |
| 297 | client = Cerebras(api_key=api_key) |
| 298 | _store_client(cache_key, client) |
| 299 | return client |
| 300 | |
| 301 | |
| 302 | def get_async_cerebras_client(api_key: str) -> AsyncCerebras: |
searching dependent graphs…