# Client setup
URL: https://docs.datarobot.com/en/docs/api/reference/sdk/client-setup.html

# Client setup

### datarobot.client.Client(token=None, endpoint=None, config_path=None, connect_timeout=None, ssl_verify=None, max_retries=None, use_tcp_keepalive=None, token_type=None, default_use_case=None, enable_api_consumer_tracking=None, trace_context=None)

Configures the global API client for the Python SDK. The client will be configured in one of
the following ways, in order of priority.

> [!NOTE] Notes
> Token and endpoint must be specified from one source only. This is a restriction
> to prevent token leakage if environment variables or config file are used.
> 
> The DataRobotClientConfig params will be looking up to find the configuration parameters
> in one of the following ways,
> 
> From call kwargs if specified;
> From a YAML file at the path specified in the
> config_path
> kwarg;
> From a YAML file at the path specified in the environment variables
> DATAROBOT_CONFIG_FILE
> ;
> From environment variables;
> From the default values in the default YAML file
>    at the path $HOME/.config/datarobot/drconfig.yaml.
> 
> This can also have the side effect of setting a default Use Case for client API requests.

- Parameters:
- Return type: RESTClientObject
- Returns: The RESTClientObject instance created.

### datarobot.client.get_client()

Returns the global HTTP client for the Python SDK, instantiating it
if necessary.

- Return type: RESTClientObject

### datarobot.client.set_client(client)

Configure the global HTTP client for the Python SDK.
Returns previous instance.

- Return type: Optional [ RESTClientObject ]

### datarobot.client.client_configuration(*args, **kwargs)

This context manager can be used to temporarily change the global HTTP client.

In multithreaded scenarios, it is highly recommended to use a fresh manager object
per thread.

DataRobot does not recommend nesting these contexts.

- Parameters:

> [!NOTE] Examples
> ```
> from datarobot.client import client_configuration
> from datarobot.models import Project
> 
> with client_configuration(default_use_case=[]):
>     # Interact with all accessible projects, not just those associated
>     # with the current use case.
>     Project.list()
> 
> with client_configuration(token="api-key-here", endpoint="https://host-name.com"):
>     # Interact with projects on a different DataRobot instance.
>     Project.list()
> ```
> 
> ```
> from datarobot.client import Client, client_configuration
> from datarobot.models import Project
> 
> Client()  # Interact with DataRobot using the default configuration.
> Project.list()
> 
> with client_configuration(config_path="/path/to/a/drconfig.yaml"):
>     # Interact with DataRobot using a different configuration.
>     Project.list()
> ```

### class datarobot.rest.RESTClientObject

- Parameters:

#### open_in_browser()

Opens the DataRobot app in a web browser, or logs the
URL if a browser is not available.

- Return type: None

---
