Creating a client
Creating Cohere API Client
To start using all features available in the Cohere SDK, you should create a client first.
Creating a client
To start using all features available in the Cohere SDK, you should create a client first.
1 import cohere 2 3 co = cohere.ClientV2(api_key="YOUR_API_KEY")
The Cohere API client initializes with the following parameters:
Parameter | Type | Default | Description |
---|---|---|---|
api_key | str/callable | None | API key for authenticating requests to the Cohere V2 API. |
base_url | str | os.getenv("CO_API_URL") | Base URL for the Cohere API. |
environment | ClientEnvironment | ClientEnvironment.PRODUCTION | Specifies the API environment (e.g., production, staging). |
client_name | str | None | Optional name for the client instance, useful for logging. |
timeout | float | None | Timeout in seconds for API requests. |
httpx_client | httpx.Client | None | Optional pre-configured httpx.Client for making HTTP requests. |
thread_pool_executor | ThreadPoolExecutor | ThreadPoolExecutor(64) | Thread pool executor for concurrent operations, with 64 threads by default. |
log_experimental | bool | True | Enables/disables warnings for experimental features. |