> 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.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/guardrails/_mcp/server.

# 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.transport.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`**

---

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

---

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

---

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

async

Return this client from an asynchronous context manager.

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

async

Close owned resources when leaving an asynchronous context.

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

async

Close the owned HTTPX client at most once.

```python
nemoguardrails.http.transport.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`

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