Creating a client

Creating Cohere API Client

To start using all features available in the Cohere SDK, you should create a client first.

1import cohere
2
3co = cohere.ClientV2(api_key="YOUR_API_KEY")

Source

The Cohere API client initializes with the following parameters:

ParameterTypeDefaultDescription
api_keystr/callableNoneAPI key for authenticating requests to the Cohere V2 API.
base_urlstros.getenv("CO_API_URL")Base URL for the Cohere API.
environmentClientEnvironmentClientEnvironment.PRODUCTIONSpecifies the API environment (e.g., production, staging).
client_namestrNoneOptional name for the client instance, useful for logging.
timeoutfloatNoneTimeout in seconds for API requests.
httpx_clienthttpx.ClientNoneOptional pre-configured httpx.Client for making HTTP requests.
thread_pool_executorThreadPoolExecutorThreadPoolExecutor(64)Thread pool executor for concurrent operations, with 64 threads by default.
log_experimentalboolTrueEnables/disables warnings for experimental features.
Built with