> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/aistore/llms.txt.
> For full documentation content, see https://docs.nvidia.com/aistore/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/aistore/_mcp/server.

# aistore.sdk.request_client

## Module Contents

### Classes

| Name                                                         | Description                                                                             |
| ------------------------------------------------------------ | --------------------------------------------------------------------------------------- |
| [`RequestClient`](#aistore-sdk-request_client-RequestClient) | Internal client for making requests to an AIS cluster or a specific proxy (e.g. AuthN). |

### Data

[`T`](#aistore-sdk-request_client-T)

[`logger`](#aistore-sdk-request_client-logger)

### API

```python
class aistore.sdk.request_client.RequestClient(
    endpoint: str,
    session_manager: aistore.sdk.session_manager.SessionManager,
    timeout: typing.Optional[typing.Union[float, typing.Tuple[float, float]]] = None,
    token: str = '',
    response_handler: aistore.sdk.response_handler.ResponseHandler = AISResponseHandler(),
    retry_config: typing.Optional[aistore.sdk.retry_config.RetryConfig] = None
)
```

Internal client for making requests to an AIS cluster or a specific proxy (e.g. AuthN).

**Parameters:**

Endpoint to either the AIS cluster or a specific proxy (e.g. AuthN).

SessionManager for creating and accessing requests session.

Request timeout in seconds; a single float.
for both connect/read timeouts (e.g., 5.0), a tuple for separate connect/read timeouts (e.g., (3.0, 10.0)),
or None to disable timeout.

Authorization token.

Handler for processing HTTP responses. Defaults to AISResponseHandler.

Return the base URL.

Return the SessionManager used to create sessions for this client.

Return the timeout for requests.

Return the token for authorization.

```python
aistore.sdk.request_client.RequestClient._calculate_content_length(
    data: typing.Union[bytes, str, typing.Any]
) -> typing.Optional[int]
```

Calculate the content length of data for HTTP requests.

Handles multiple data types including bytes, strings, and file-like objects.

**Parameters:**

The data whose length needs to be calculated. Can be:

* bytes or str: Direct length calculation
* File-like object with fileno(): Uses fstat for efficiency
* File-like object with seek(): Uses seek to determine size
* Other types: Returns None with a warning

**Returns:** `Optional[int]`

The content length in bytes, or None if it cannot be determined

**Raises:**

* `IOError`: If file operations fail during content length calculation

```python
aistore.sdk.request_client.RequestClient._prepare_proxy_request(
    headers: typing.Optional[typing.Dict[str, typing.Any]],
    kwargs: typing.Dict[str, typing.Any]
) -> typing.Dict[str, typing.Any]
```

Prepare the request parameters for the initial proxy request.

When data is present, the Content-Length header is calculated and set if possible,
but the actual data is replaced with an empty byte string to avoid
SSL EOF errors and improve efficiency.

**Parameters:**

Request headers to be sent

Additional request parameters including optional 'data'

**Returns:** `Dict[str, Any]`

Dict containing the prepared request parameters for the proxy

**Raises:**

* `IOError`: If file operations fail during content length calculation

```python
aistore.sdk.request_client.RequestClient._request_with_manual_redirect(
    method: str,
    url: str,
    headers: typing.Optional[typing.Dict[str, typing.Any]],
    kwargs = {}
) -> requests.Response
```

Execute a request with manual redirect handling for HTTPS connections with data.

This method implements a two-phase request pattern:

1. Send a request to the proxy to obtain the redirect URL
2. Send the actual request with data to the redirected target

This workaround is necessary because the `requests` library does not properly
handle 307 redirects from TLS-enabled servers when data is present in the request,
resulting in SSL EOF errors: SSLEOFError(8, 'EOF occurred in violation of protocol')

When cluster authentication is enabled, the proxy requires the Content-Length header
to compute the HMAC signature, but the actual data payload is not needed until the
request reaches the target node.

**Parameters:**

HTTP method (e.g., 'GET', 'POST', 'PUT', 'DELETE')

Initial URL to the AIS proxy

HTTP headers to be sent with the request

Additional request parameters (e.g., data, params, timeout)

**Returns:** `Response`

The HTTP response from the final target server

**Raises:**

* `ValueError`: If the proxy does not return a redirect or the redirect URL is missing
* `TypeError`: If data type is not supported
* `IOError`: If file operations fail during content length calculation

```python
aistore.sdk.request_client.RequestClient.clone(
    base_url: typing.Optional[str] = None
) -> aistore.sdk.request_client.RequestClient
```

Create a copy of the current RequestClient instance with an optional new base URL.

**Parameters:**

New base URL for the cloned client. Defaults to the existing base URL.

**Returns:** `RequestClient`

A new instance with the same settings but an optional different base URL.

```python
aistore.sdk.request_client.RequestClient.get_full_url(
    path: str,
    params: typing.Dict[str, typing.Any]
) -> str
```

Get the full URL to the path on the cluster with the given parameters.

**Parameters:**

Path on the cluster.

Query parameters to include.

**Returns:** `str`

URL including cluster base URL and parameters.

```python
aistore.sdk.request_client.RequestClient.get_smap(
    force_update: bool = False
) -> aistore.sdk.types.Smap
```

Return the smap.

```python
aistore.sdk.request_client.RequestClient.request(
    method: str,
    path: str,
    endpoint: typing.Optional[str] = None,
    headers: typing.Optional[typing.Dict[str, typing.Any]] = None,
    kwargs = {}
) -> requests.Response
```

Make a request with the request\_client's retry manager.

If the request is an HTTPS request with a payload (`data`), it uses
`_request_with_manual_redirect`. Otherwise, it delegates to the
`RequestExecutor` for a single send through the configured endpoint.

**Parameters:**

HTTP method (e.g. POST, GET, PUT, DELETE).

URL path to call.

Alternative endpoint for the AIS cluster
(e.g. for connecting to a specific proxy).

Extra headers to be passed with the request.
Content-Type and User-Agent will be overridden by the executor.

Optional keyword arguments to pass with the call to request.

**Returns:** `Response`

The HTTP response from the server.

```python
aistore.sdk.request_client.RequestClient.request_deserialize(
    method: str,
    path: str,
    res_model: typing.Type[aistore.sdk.request_client.T],
    kwargs = {}
) -> aistore.sdk.request_client.T
```

Make a request and deserialize the response to a defined type.

**Parameters:**

HTTP method (e.g. POST, GET, PUT, DELETE).

URL path to call.

Resulting type to which the response should be deserialized.

Optional keyword arguments to pass with the call to request.

**Returns:** `T`

Parsed result of the call to the API, as res\_model.

```python
aistore.sdk.request_client.T = TypeVar('T')
```

```python
aistore.sdk.request_client.logger = get_logger(__name__)
```