Skip to navigation

nemoguardrails.server.experimental.providers.openai.integration

View as MarkdownOpen in Claude

Compose explicit OpenAI operation sets and provider-native errors.

Module Contents

Functions

NameDescription
create_openai_chat_integrationCreate a Chat-only OpenAI instance with an explicitly reviewed endpoint.
create_openai_chat_routerCreate the private buffered and streaming OpenAI Chat proxy surface.
create_openai_integrationCreate an OpenAI instance with the selected built-in guard bindings.

Data

OpenAIOperation

API

nemoguardrails.server.experimental.providers.openai.integration.create_openai_chat_integration(
instance_id: str = 'openai',
base_url: str | None = None,
mount_path: str = '',

Create a Chat-only OpenAI instance with an explicitly reviewed endpoint.

Omitting endpoint selects the strict OpenAI Chat boundary through create_openai_integration. A trusted application may instead supply an OpenAI-wire-compatible dialect endpoint; it must use the OpenAI error mapping. Other instances are unaffected. Unselected routes retain the application’s passthrough behavior.

nemoguardrails.server.experimental.providers.openai.integration.create_openai_chat_router(
checker: nemoguardrails.server.experimental._content_checker.ContentChecker,
dispatch: nemoguardrails.server.experimental._http_kernel.HttpDispatch,
stream_dispatch: nemoguardrails.server.experimental._streaming_http.StreamingHttpDispatch | None = None,
reserved_routes: collections.abc.Mapping[str, collections.abc.Collection[str]] | None = None,
max_request_body_bytes: int = DEFAULT_MAX_REQUEST_BODY_BYTES,
max_response_body_bytes: int = DEFAULT_MAX_RESPONSE_BODY_B...,
) -> fastapi.APIRouter

Create the private buffered and streaming OpenAI Chat proxy surface.

A trusted application may explicitly supply a reviewed OpenAI-wire-compatible endpoint, such as the LiteLLM subset. Omitting it retains the OpenAI policy. This does not detect a backend, load a contract, or select a dialect from request data. The supplied endpoint must use the OpenAI error mapping.

nemoguardrails.server.experimental.providers.openai.integration.create_openai_integration(
instance_id: str = 'openai',
base_url: str | None = None,
mount_path: str = '',
operations: collections.abc.Sequence[nemoguardrails.server.experimental.providers.openai.integration.OpenAIOperation] = ('chat_completions', 'respo...

Create an OpenAI instance with the selected built-in guard bindings.

operations is a nonempty sequence of unique names, in binding order. The fixed default selects Chat Completions and Responses; it does not mean all operations a future version might support. A bare string is invalid.

Selection installs guard bindings, not a route allowlist. Unselected routes retain the application’s passthrough behavior and are not thereby guarded. These are strict OpenAI boundaries: an upstream URL does not select a dialect. Trusted applications can customize explicit endpoint bindings.

Raises:

  • TypeError: operations is not a sequence of operation names.
  • ValueError: The selection is empty, unknown, or contains duplicates.
nemoguardrails.server.experimental.providers.openai.integration.OpenAIOperation = Literal['chat_completions', 'responses']

Built-in operation names accepted by the OpenAI integration factory.