# Client setup

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

This Markdown file sits beside the HTML page at the same path (with a `.md` suffix). It summarizes the topic and lists links for tools and LLM context.

Companion generated at `2026-07-27T18:44:30.512320+00:00` (UTC).

## Primary page

- [Client setup](https://docs.datarobot.com/ja/docs/api/reference/sdk/client-setup.html.md): Full documentation for this topic (Markdown sidecar).

## Sections on this page

- [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)](https://docs.datarobot.com/ja/docs/api/reference/sdk/client-setup.html.md#datarobot.client.Client): In-page section heading.
- [datarobot.client.get_client()](https://docs.datarobot.com/ja/docs/api/reference/sdk/client-setup.html.md#datarobot.client.get_client): In-page section heading.
- [datarobot.client.set_client(client)](https://docs.datarobot.com/ja/docs/api/reference/sdk/client-setup.html.md#datarobot.client.set_client): In-page section heading.
- [datarobot.client.client_configuration(*args, **kwargs)](https://docs.datarobot.com/ja/docs/api/reference/sdk/client-setup.html.md#datarobot.client.client_configuration): In-page section heading.
- [RESTClientObject](https://docs.datarobot.com/ja/docs/api/reference/sdk/client-setup.html.md#datarobot.rest.RESTClientObject): In-page section heading.
- [open_in_browser()](https://docs.datarobot.com/ja/docs/api/reference/sdk/client-setup.html.md#datarobot.rest.RESTClientObject.open_in_browser): In-page section heading.

## Documentation content

### 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

| Parameter | Type | Description |
| --- | --- | --- |
| token | Optional[str] | API token. |
| endpoint | Optional[str] | Base URL of API. |
| config_path | Optional[str] | An alternate location of the config file. |
| connect_timeout | Optional[int] | How long the client should be willing to wait before giving up on establishing a connection with the server. |
| ssl_verify | bool or Optional[str] | Whether to check SSL certificate. Could be set to path with certificates of trusted certification authorities. Default: True. |
| max_retries | int or urllib3.util.retry.Retry, optional | Either an integer number of times to retry connection errors, or a urllib3.util.retry.Retry object to configure retries. |
| use_tcp_keepalive | Optional[bool] | Enable TCP keepalive for the client. If None is set to True. Default: None. |
| token_type | Optional[str] | Authentication token type: Token, Bearer. “Bearer” is for DataRobot OAuth2 token, “Token” for token generated in Developer Tools. Default: “Token”. |
| default_use_case | Optional[str] | The entity ID of the default Use Case to use with any requests made by the client. |
| enable_api_consumer_tracking | Optional[bool] | Enable and disable user metrics tracking within the datarobot module. Default: False. |
| trace_context | Optional[str] | An ID or other string for identifying which code template or AI Accelerator was used to make a request. |

Return type: [RESTClientObject](https://docs.datarobot.com/ja/docs/api/reference/sdk/client-setup.html.md#datarobot.rest.RESTClientObject)

Returns

| Returns | Description |
| --- | --- |
| The RESTClientObject instance created. |  |

### datarobot.client.get_client()

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

Return type: [RESTClientObject](https://docs.datarobot.com/ja/docs/api/reference/sdk/client-setup.html.md#datarobot.rest.RESTClientObject)

### datarobot.client.set_client(client)

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

Return type: `Optional` [ [RESTClientObject](https://docs.datarobot.com/ja/docs/api/reference/sdk/client-setup.html.md#datarobot.rest.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

| Parameter | Type | Description |
| --- | --- | --- |
| args |  | (Parameters passed to datarobot.client.Client()) |
| kwargs |  | (Keyword arguments passed to datarobot.client.Client()) |

Return type: `Generator` [ `None`, `None`, `None`]

> [!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()
> ```
> 
> ```
> # To filter by a specific use case:
> 
> from datarobot.client import Client, client_configuration
> from datarobot.models import Project
> 
> USE_CASE_ID = "your use case ID"
> with client_configuration(default_use_case=USE_CASE_ID):
>     Project.list()
> ```

### RESTClientObject

Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| connect_timeout | Optional[int] | timeout for http request and connection |
| headers |  | headers for outgoing requests |

#### open_in_browser()

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

Return type: `None`
