---
sidebar:
  label: roboto.http.options
  order: 3
title: roboto.http.options
---
## Module Contents

### HttpClientOptions

```python
class roboto.http.options.HttpClientOptions
```

`from roboto.http import HttpClientOptions`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/http/options.py#L69-L76)

Settings of an [`HttpClient`](/docs/reference/python-sdk/roboto/http/http_client#roboto.http.http_client.HttpClient) that apply to every request it makes.

**Attributes**

- **HttpClientOptions.logging** (`HttpLoggingOptions`): Settings for how the client logs requests.
- **HttpClientOptions.retry** (`HttpRetryOptions`): Settings for when the client retries a failed request.

### HttpLoggingOptions

```python
class roboto.http.options.HttpLoggingOptions
```

`from roboto.http import HttpLoggingOptions`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/http/options.py#L32-L48)

Logging settings of an [`HttpClient`](/docs/reference/python-sdk/roboto/http/http_client#roboto.http.http_client.HttpClient): which parts of a request it hides in its logs.

**Attributes**

- **HttpLoggingOptions.log_only_method_and_origin** (`bool`) = `False`: Whether the client's debug log names each request by its method and its URL's origin only.

  The origin is the URL's scheme, host and port. When `True`, the log leaves out the URL's path and query, the request headers, and the body. A response's line gives only its status, and a failed request's line gives only an HTTP error's status or the exception's class, with no message or traceback. The `ConnectionRefusedError` the client raises names only the origin. Turn it on for a client whose request URLs or bodies hold secrets or personal data, such as one that posts to a Slack incoming webhook.

- **HttpLoggingOptions.scrub_headers** (`Sequence[str]`) = `()`: Names of headers whose values the client replaces with `*` when it logs a request.

  Names are compared case-insensitively. The `Authorization` header's value is always replaced, whether or not it is listed here.

### HttpRetryOptions

```python
class roboto.http.options.HttpRetryOptions
```

`from roboto.http import HttpRetryOptions`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/http/options.py#L52-L65)

Retry settings of an [`HttpClient`](/docs/reference/python-sdk/roboto/http/http_client#roboto.http.http_client.HttpClient): which failed requests it retries and how many times.

**Attributes**

- **HttpRetryOptions.max_attempts** (`int`) = `10`: Maximum number of attempts per request, the first included.

  A value below 1 behaves as 1: the first attempt always runs.

- **HttpRetryOptions.predicate** (`RetryPredicate | None`) = `None`: Function called with the request and the exception a failed attempt raised; `True` retries the request.

  `None` uses [`is_expected_to_be_transient()`](/docs/reference/python-sdk/roboto/http/http_client#roboto.http.http_client.is_expected_to_be_transient), which retries a failed DNS lookup and HTTP 429, 502 and 503 on any request, and connection errors, timeouts, and HTTP 408, 500 and 504 only on a request marked `idempotent`. `never_retry` retries nothing.

### RetryPredicate

```python
roboto.http.options.RetryPredicate
```

`from roboto.http import RetryPredicate`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/http/options.py#L12-L12)

Function that decides whether to retry a failed request, and returns `True` to retry it.

It is called with the request and the exception the failed attempt raised. `HttpRetryOptions.predicate` holds one.

### never_retry()

```python
def roboto.http.options.never_retry(
    _request: roboto.http.request.HttpRequest,
    _exc: BaseException,
) -> bool
```

`from roboto.http import never_retry`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/http/options.py#L18-L28)

Return `False` to decline every retry, so the client attempts each request once.

Use it for a request whose effect must not happen twice, such as sending a chat message or an email, when the server cannot recognize a repeated request: a retry after a timeout could deliver the message a second time.

**Usage**

```python
from roboto.http import HttpClient, HttpClientOptions, HttpRetryOptions, never_retry
client = HttpClient(options=HttpClientOptions(retry=HttpRetryOptions(predicate=never_retry)))
```

**Parameters**

- **`_request`** (`roboto.http.request.HttpRequest`)
- **`_exc`** (`BaseException`)

**Returns**

- `bool`
