Skip to navigation

Run guardrail checks on a text

View as Markdown

Runs the requested checks on the text through the Opik inference decision service and returns a verdict per check. Writes nothing: the SDK reports the results to the guardrails batch endpoint, as before.

Request

This endpoint expects an object.
textstringRequired>=1 character

The text to check, at most 16384 characters as the decision service counts them: on the text’s JSON encoding, so the two quotes count, a quote, backslash or line break counts as 2, and any other control or non-ASCII character as 6 (an emoji as 12). In practice about 16,380 characters of English text fit, about 2,730 of text in Cyrillic, Greek, Hebrew, Arabic, Chinese or Japanese, and about 1,365 emoji. A longer text is rejected rather than cut.

validationslist of objectsRequired

The checks to run. Together they must fit in 64 questions to the decision service, asked in up to two calls of 32: each PII class and each topic list is one question, prompt injection is one

Response

A verdict per check
validationslist of objects
validation_passedbooleanOptional

Errors

400
Bad Request Error
401
Unauthorized Error
403
Forbidden Error
422
Unprocessable Entity Error
429
Too Many Requests Error
503
Service Unavailable Error