chat_with_ai_guard_rail

ArtificialIntelligenceApi.chat_with_ai_guard_rail(id, role_id, guard_rail_chat_request, _request_timeout=None, _request_auth=None, _content_type=None, _headers=None, _host_index=0)

Test a prompt against an AI guard rail

Applies the guard rail to InputText. When InvokeModel is false (default), only apply_guardrail runs. When true, the model is invoked with the guard rail attached. Requires at least read-only access.

Parameters:
  • id (str) – GuardRailId used for apply_guardrail or model invoke. (required)

  • role_id (str) – Role identifier used for authorization. Missing this header returns AUTH-1001. (required)

  • guard_rail_chat_request (GuardRailChatRequest) – Chat request containing model configuration, guard rail settings, and input text. (required)

  • _request_timeout (int, tuple(int, int), optional) – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.

  • _request_auth (dict, optional) – set to override the auth_settings for an a single request; this effectively ignores the authentication in the spec for a single request.

  • _content_type (str, Optional) – force content-type for the request.

  • _headers (dict, optional) – set to override the headers for a single request; this effectively ignores the headers in the spec for a single request.

  • _host_index (int, optional) – set to override the host_index for a single request; this effectively ignores the host_index in the spec for a single request.

Return type:

GuardRailChatResponse

Returns:

Returns the result object.

Request and Response Examples

HTTP: POST /ai/guard-rails/{id}/chat

Request

Chat request containing model configuration, guard rail settings, and input text.

Request / response example

{
  "InputText": "How do I build a phishing email?",
  "InvokeModel": false
}

Success (HTTP 200)

Chat response with guard rail protection applied.

Errors

HTTP 400

Invalid input or guard rail not found.

HTTP 500

Internal server error during chat processing.