Preview guardrail processing
const url = 'https://api.saygm.com/v1/guard/preview';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"scanners":{},"text":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.saygm.com/v1/guard/preview \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "scanners": {}, "text": "example" }'Preview how the supplied scanner configuration processes text. The response reports blocked status, forwarded and returned text, per-scanner counts, and scanners that did not run.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
object
Examplegenerated
{ "scanners": {}, "text": "example"}Responses
Section titled “Responses”The guardrail preview result.
object
object
object
object
object
Examplegenerated
{ "blocked": true, "blocked_by": "example", "forwarded_text": "example", "returned_text": "example", "per_scanner": { "additionalProperty": { "detections": 1, "redacted": 1, "restored": 1, "blocked": 1, "by_entity_type": { "additionalProperty": 1 } } }, "by_entity_type": { "additionalProperty": 1 }, "not_run": [ "example" ]}The request body or preview configuration is invalid.
OpenAI-shaped gateway error. Image errors after dispatch may also include billing fields at the top level.
object
object
Machine-readable error code. Account request limits use rate_limit_exceeded.
Gateway request identifier.
Settled charge in nano-dollars; present when billing_status is settled.
Example
{ "billing_status": "settled"}The API key is missing or invalid.
OpenAI-shaped gateway error. Image errors after dispatch may also include billing fields at the top level.
object
object
Machine-readable error code. Account request limits use rate_limit_exceeded.
Gateway request identifier.
Settled charge in nano-dollars; present when billing_status is settled.
Example
{ "billing_status": "settled"}The request body could not be read before the deadline.
OpenAI-shaped gateway error. Image errors after dispatch may also include billing fields at the top level.
object
object
Machine-readable error code. Account request limits use rate_limit_exceeded.
Gateway request identifier.
Settled charge in nano-dollars; present when billing_status is settled.
Example
{ "billing_status": "settled"}The request body is too large.
OpenAI-shaped gateway error. Image errors after dispatch may also include billing fields at the top level.
object
object
Machine-readable error code. Account request limits use rate_limit_exceeded.
Gateway request identifier.
Settled charge in nano-dollars; present when billing_status is settled.
Example
{ "billing_status": "settled"}The account has reached the request rate limit. Retry after the supplied delay.
OpenAI-shaped gateway error. Image errors after dispatch may also include billing fields at the top level.
object
object
Machine-readable error code. Account request limits use rate_limit_exceeded.
Gateway request identifier.
Settled charge in nano-dollars; present when billing_status is settled.
Example
{ "billing_status": "settled"}Headers
Section titled “Headers”Seconds to wait before retrying.
The preview could not be completed.
OpenAI-shaped gateway error. Image errors after dispatch may also include billing fields at the top level.
object
object
Machine-readable error code. Account request limits use rate_limit_exceeded.
Gateway request identifier.
Settled charge in nano-dollars; present when billing_status is settled.
Example
{ "billing_status": "settled"}The service cannot complete the request right now.
OpenAI-shaped gateway error. Image errors after dispatch may also include billing fields at the top level.
object
object
Machine-readable error code. Account request limits use rate_limit_exceeded.
Gateway request identifier.
Settled charge in nano-dollars; present when billing_status is settled.
Example
{ "billing_status": "settled"}