> This page is for version v0.25.0.
> For other versions, use one of these documentation indexes:
> - Latest (default): https://docs.nvidia.com/nemo/guardrails/latest/llms.txt
> - v0.25.0: https://docs.nvidia.com/nemo/guardrails/v0.25.0/llms.txt
> - v0.24.1: https://docs.nvidia.com/nemo/guardrails/v0.24.1/llms.txt
> - v0.24.0: https://docs.nvidia.com/nemo/guardrails/v0.24.0/llms.txt
> - v0.23.0: https://docs.nvidia.com/nemo/guardrails/v0.23.0/llms.txt
> - v0.22.0: https://docs.nvidia.com/nemo/guardrails/v0.22.0/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/guardrails/llms.txt.

# nemoguardrails.http.transport

HTTPX transport adapter for the transport-neutral HTTP client contract.

## Module Contents

### Classes

| Name                                                                | Description                                                      |
| ------------------------------------------------------------------- | ---------------------------------------------------------------- |
| [`HttpxHTTPClient`](#nemoguardrails-http-transport-HttpxHTTPClient) | Adapt an HTTPX asynchronous client to the neutral HTTP contract. |

### Functions

| Name                                                                                | Description |
| ----------------------------------------------------------------------------------- | ----------- |
| [`_sanitize_request_error`](#nemoguardrails-http-transport-_sanitize_request_error) | -           |

### Data

[`_DEFAULT_TIMEOUT_SECONDS`](#nemoguardrails-http-transport-_DEFAULT_TIMEOUT_SECONDS)

### API

```python
class nemoguardrails.http.HttpxHTTPClient(
    client: httpx.AsyncClient | None = None,
    timeout: float | None = _DEFAULT_TIMEOUT_SECONDS,
    limits: httpx.Limits | None = None,
    follow_redirects: bool = False,
    tls: nemoguardrails.http.types.HTTPTLSConfig | None = None
)
```

Adapt an HTTPX asynchronous client to the neutral HTTP contract.

A client created by this adapter is owned and closed by the adapter. An
injected client remains owned by its caller. The configured timeout covers
the complete request rather than each HTTPX timeout phase independently.

**`_client`**

---

**`_close_task`** `Task[None] | None = None`

---

**`_owns_client`** `= client is None`

---

**`_timeout`** `= timeout if self._owns_client else None`

---

```python
nemoguardrails.http.HttpxHTTPClient.__aenter__() -> nemoguardrails.http.transport.HttpxHTTPClient
```

async

Return this client from an asynchronous context manager.

```python
nemoguardrails.http.HttpxHTTPClient.__aexit__(
    exc_type: object,
    exc_value: object,
    traceback: object
) -> None
```

async

Close owned resources when leaving an asynchronous context.

```python
nemoguardrails.http.HttpxHTTPClient.close() -> None
```

async

Close owned resources, retaining unfinished cleanup for another call.

Caller cancellation leaves the transport close running; later calls
await the same attempt. A failed close remains failed because HTTPX may
already have discarded partially closed connection state.

```python
nemoguardrails.http.HttpxHTTPClient.request(
    method: str,
    url: str,
    headers: typing.Mapping[str, str] | None = None,
    params: typing.Mapping[str, typing.Any] | None = None,
    json: typing.Any = None,
    content: bytes | str | None = None,
    timeout: float | None = None
) -> nemoguardrails.http.types.HTTPResponse
```

async

Send one request and materialize the HTTPX response.

**Parameters:**

**`method`** `str`

HTTP method.

---

**`url`** `str`

Absolute request URL.

---

**`headers`** `Mapping[str, str] | None` — default: None

Optional request headers.

---

**`params`** `Mapping[str, Any] | None` — default: None

Optional query parameters.

---

**`json`** `Any` — default: None

Optional JSON-serializable request body.

---

**`content`** `bytes | str | None` — default: None

Optional raw request body.

---

**`timeout`** `float | None` — default: None

Optional per-request total timeout in seconds.

---

**Returns:** [`HTTPResponse`](/nemo/guardrails/v0.25.0/guardrails-python-sdk/nemoguardrails/http/types#nemoguardrails-http-types-HTTPResponse)

A neutral response containing copied headers and body bytes.

**Raises:**

* `HTTPTimeoutError`: If the request exceeds its total timeout.
* `HTTPConnectionError`: If HTTPX reports a request failure.
* `ValueError`: If the per-request timeout is not positive.

```python
nemoguardrails.http.transport._sanitize_request_error(
    error: httpx.RequestError
) -> httpx.RequestError
```

```python
nemoguardrails.http.transport._DEFAULT_TIMEOUT_SECONDS = 30.0
```