nemoguardrails.http.runtime

View as Markdown

Construction helpers for managed outbound HTTP clients.

Module Contents

Functions

NameDescription
create_http_clientCreate a transport-neutral HTTP client with optional retry behavior.

API

nemoguardrails.http.runtime.create_http_client(
httpx_client: httpx.AsyncClient | None = None,
timeout: float | None = 30.0,
limits: httpx.Limits | None = None,
retry_policy: nemoguardrails.http.retry.RetryPolicy | None = None,
follow_redirects: bool = False,
tls: nemoguardrails.http.types.HTTPTLSConfig | None = None
) -> nemoguardrails.http.client.ClosableHTTPClient

Create a transport-neutral HTTP client with optional retry behavior.

When httpx_client is provided, it remains caller-owned and timeout, limits, follow_redirects, and tls must retain their defaults. retry_policy is still applied when supplied.

Parameters:

httpx_client
httpx.AsyncClient | NoneDefaults to None

Optional caller-owned HTTPX client.

timeout
float | NoneDefaults to 30.0

Total timeout for a client created by this function.

limits
httpx.Limits | NoneDefaults to None

Connection-pool limits for a client created by this function.

retry_policy
RetryPolicy | NoneDefaults to None

Optional policy applied to created or injected clients.

follow_redirects
boolDefaults to False

Whether a client created by this function follows redirects.

tls
HTTPTLSConfig | NoneDefaults to None

TLS settings for a client created by this function.

Returns: ClosableHTTPClient

A closable transport-neutral HTTP client.

Raises:

  • ValueError: If non-default owned-client options are supplied with an injected client.