Skip to main content

Guardrails Server REST API

note

Guardrails CRUD API. The server hosts the documenation on this page in an interactive swagger UI. Typically these are available at localhost:8000/docs if you are running the server locally with default configurations.

Authentication

  • HTTP Authentication, scheme: bearer
  • API Key (ApiKeyAuth)
    • Parameter Name: authorization, in: header.

Service Health

get__health-check

GET /health-check

Example responses

200 Response

{
"status": 0,
"message": "string"
}

Responses

StatusMeaningDescriptionSchema
200OKReturns the status of the serverHealthCheck
defaultDefaultUnexpected errorHttpError

guard

getGuards

GET /guards

Fetches the configuration for all Guards the user has access to.

Example responses

200 Response

[
{
"id": "string",
"name": "string",
"description": "string",
"validators": [
{
"id": "string",
"on": "messages",
"onFail": "exception",
"args": [
true
],
"kwargs": {
"property1": null,
"property2": null
}
}
],
"output_schema": {
"definitions": {},
"dependencies": {
"property1": {},
"property2": {}
},
"$anchor": "string",
"$ref": "../dictionary",
"$dynamicRef": "../dictionary",
"$dynamicAnchor": "string",
"$vocabulary": {
"property1": true,
"property2": true
},
"$comment": "string",
"$defs": {},
"prefixItems": [
null
],
"items": null,
"contains": null,
"additionalProperties": null,
"properties": {},
"patternProperties": {},
"dependentSchemas": {
"property1": null,
"property2": null
},
"propertyNames": null,
"if": null,
"then": null,
"else": null,
"allOf": [
null
],
"anyOf": [
null
],
"oneOf": [
null
],
"not": null,
"unevaluatedItems": null,
"unevaluatedProperties": null,
"multipleOf": 0,
"maximum": 0,
"exclusiveMaximum": 0,
"minimum": 0,
"exclusiveMinimum": 0,
"maxLength": 0,
"minLength": 0,
"pattern": "/regex/",
"maxItems": 0,
"minItems": 0,
"uniqueItems": false,
"maxContains": 0,
"minContains": 0,
"maxProperties": 0,
"minProperties": 0,
"required": [],
"dependentRequired": {
"property1": [],
"property2": []
},
"const": null,
"enum": [
null
],
"type": "array",
"title": "string",
"description": "string",
"default": null,
"deprecated": false,
"readOnly": false,
"writeOnly": false,
"examples": [
null
],
"format": "string",
"contentMediaType": "string",
"contentEncoding": "string",
"contentSchema": null
},
"history": [
{
"id": "string",
"iterations": [],
"inputs": {
"llmApi": "string",
"llmOutput": "string",
"messages": [
{
"property1": null,
"property2": null
}
],
"promptParams": {
"property1": null,
"property2": null
},
"numReasks": 0,
"metadata": {
"property1": null,
"property2": null
},
"fullSchemaReask": true,
"stream": true,
"args": [
true
],
"kwargs": {
"property1": null,
"property2": null
}
},
"exception": "string"
}
]
}
]

Responses

StatusMeaningDescriptionSchema
200OKA list of Guards.Inline
defaultDefaultUnexpected errorHttpError

Response Schema

Status Code 200

NameTypeRequiredRestrictionsDescription
anonymous[guard]falsenonenone
» Guardguardfalsenonenone
»» idstring(kebab-case)truenoneThe unique identifier for the Guard.
»» namestringtruenoneThe name for the Guard.
»» descriptionstringfalsenoneA description that concisely states the expected behaviour or purpose of the Guard.
»» validators[allOf]falsenonenone
»»» ValidatorReferenceValidatorReferencefalsenonenone
»»»» idstringtruenoneThe unique identifier for this Validator. Often the hub id; e.g. guardrails/regex_match
»»»» onanyfalsenoneA reference to the property this validator should be applied against. Can be a valid JSON path or a meta-property such as "messages" or "output"

anyOf

NameTypeRequiredRestrictionsDescription
»»»»» anonymousstringfalsenonemeta-property

or

NameTypeRequiredRestrictionsDescription
»»»»» anonymousstringfalsenoneJSON path to property; e.g. $.foo.bar

continued

NameTypeRequiredRestrictionsDescription
»»»» onFailstringfalsenonenone
»» output_schemaschemafalsenonenone
»»» definitionsobjectfalsenonenone
»»»» additionalPropertiesanyfalsenonenone
»»» dependenciesobjectfalsenonenone
»»»» additionalPropertiesanyfalsenonenone

anyOf

NameTypeRequiredRestrictionsDescription
»»»»» anonymousanyfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»» anonymous[string]falsenonenone

allOf

NameTypeRequiredRestrictionsDescription
»»» anonymouscorefalsenonenone
»»»» $anchorstringfalsenonenone
»»»» $refstring(uri-reference)falsenonenone
»»»» $dynamicRefstring(uri-reference)falsenonenone
»»»» $dynamicAnchorstringfalsenonenone
»»»» $vocabularyobjectfalsenonenone
»»»»» additionalPropertiesbooleanfalsenonenone
»»»» $commentstringfalsenonenone
»»»» $defsobjectfalsenonenone
»»»»» additionalPropertiesanyfalsenonenone

and

NameTypeRequiredRestrictionsDescription
»»» anonymousapplicatorfalsenonenone
»»»» prefixItems[any]falsenonenone
»»»» itemsanyfalsenonenone
»»»» containsanyfalsenonenone
»»»» additionalPropertiesanyfalsenonenone
»»»» propertiesobjectfalsenonenone
»»»»» additionalPropertiesanyfalsenonenone
»»»» patternPropertiesobjectfalsenonenone
»»»»» additionalPropertiesanyfalsenonenone
»»»» dependentSchemasobjectfalsenonenone
»»»»» additionalPropertiesanyfalsenonenone
»»»» propertyNamesanyfalsenonenone
»»»» ifanyfalsenonenone
»»»» thenanyfalsenonenone
»»»» elseanyfalsenonenone
»»»» allOf[any]falsenonenone
»»»» anyOf[any]falsenonenone
»»»» oneOf[any]falsenonenone
»»»» notanyfalsenonenone

and

NameTypeRequiredRestrictionsDescription
»»» anonymousunevaluatedfalsenonenone
»»»» unevaluatedItemsanyfalsenonenone
»»»» unevaluatedPropertiesanyfalsenonenone

and

NameTypeRequiredRestrictionsDescription
»»» anonymousvalidationfalsenonenone
»»»» multipleOfnumberfalsenonenone
»»»» maximumnumberfalsenonenone
»»»» exclusiveMaximumnumberfalsenonenone
»»»» minimumnumberfalsenonenone
»»»» exclusiveMinimumnumberfalsenonenone
»»»» maxLengthnonNegativeIntegerfalsenonenone
»»»» minLengthnonNegativeIntegerfalsenonenone
»»»» patternstring(regex)falsenonenone
»»»» maxItemsnonNegativeIntegerfalsenonenone
»»»» minItemsnonNegativeIntegerfalsenonenone
»»»» uniqueItemsbooleanfalsenonenone
»»»» maxContainsnonNegativeIntegerfalsenonenone
»»»» minContainsnonNegativeIntegerfalsenonenone
»»»» maxPropertiesnonNegativeIntegerfalsenonenone
»»»» minPropertiesnonNegativeIntegerfalsenonenone
»»»» required[string]falsenonenone
»»»» dependentRequiredobjectfalsenonenone
»»»»» additionalProperties[string]falsenonenone
»»»» constanyfalsenonenone
»»»» enum[any]falsenonenone
»»»» typeanyfalsenonenone

anyOf

NameTypeRequiredRestrictionsDescription
»»»»» anonymousanyfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»» anonymous[simpleTypes]falsenonenone

and

NameTypeRequiredRestrictionsDescription
»»» anonymousmeta-datafalsenonenone
»»»» titlestringfalsenonenone
»»»» descriptionstringfalsenonenone
»»»» defaultanyfalsenonenone
»»»» deprecatedbooleanfalsenonenone
»»»» readOnlybooleanfalsenonenone
»»»» writeOnlybooleanfalsenonenone
»»»» examples[any]falsenonenone

and

NameTypeRequiredRestrictionsDescription
»»» anonymousformat-annotationfalsenonenone
»»»» formatstringfalsenonenone

and

NameTypeRequiredRestrictionsDescription
»»» anonymouscontentfalsenonenone
»»»» contentMediaTypestringfalsenonenone
»»»» contentEncodingstringfalsenonenone
»»»» contentSchemaanyfalsenonenone

continued

NameTypeRequiredRestrictionsDescription
»» history[call]falseread-onlynone
»»» Callcallfalsenonenone
»»»» idstringtruenoneThe unique identifier for this Call. Can be used as an identifier for a specific execution of a Guard.
»»»» iterations[iteration]falsenonenone
»»»»» Iterationiterationfalsenonenone
»»»»»» idstringtruenoneThe unique identifier for this Call. Can be used as an identifier for a specific execution of a Guard.
»»»»»» indexintegertruenoneThe zero-based index of this iteration within the current Call.
»»»»»» callIdstringtruenoneThe unique identifier for the Call that this iteration is a part of.
»»»»»» inputsinputsfalsenonenone
»»»»»»» llmApistringfalsenoneThe LLM resource targeted by the user. e.g. openai.chat.completions.create
»»»»»»» llmOutputstringfalsenoneThe string output from an external LLM call provided by the user via Guard.parse.
»»»»»»» messages[object]falsenoneThe message history for chat models.
»»»»»»»» additionalPropertiesanyfalsenonenone
»»»»»»» promptParamsobjectfalsenoneParameters to be formatted into the prompt.
»»»»»»»» additionalPropertiesanyfalsenonenone
»»»»»»» numReasksintegerfalsenoneThe total number of times the LLM can be called to correct output excluding the initial call.
»»»»»»» metadataobjectfalsenoneAdditional data to be used by Validators during execution time.
»»»»»»»» additionalPropertiesanyfalsenonenone
»»»»»»» fullSchemaReaskbooleanfalsenoneWhether to perform reasks for the entire schema rather than for individual fields.
»»»»»»» streambooleanfalsenoneWhether to use streaming.
»»»»»» outputsoutputsfalsenonenone
»»»»»»» llmResponseInfoLLMResponsefalsenoneInformation from the LLM response.
»»»»»»»» promptTokenCountintegerfalsenonenone
»»»»»»»» responseTokenCountintegerfalsenonenone
»»»»»»»» outputstringtruenonenone
»»»»»»»» streamOutput[string]falsenonenone
»»»»»»»» asyncStreamOutput[string]falsenonenone
»»»»»»» rawOutputstringfalsenoneThe string content from the LLM response.
»»»»»»» parsedOutputanyfalsenonenone

anyOf

NameTypeRequiredRestrictionsDescription
»»»»»»»» anonymousstringfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»»»»» anonymousobjectfalsenonenone
»»»»»»»»» additionalPropertiesanyfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»»»»» anonymous[anyOf]falsenonenone
»»»»»»»»» AnyTypeanyfalsenonenone

anyOf

NameTypeRequiredRestrictionsDescription
»»»»»»»»»» anonymousanyfalsenonenone

anyOf

NameTypeRequiredRestrictionsDescription
»»»»»»»»»»» anonymousbooleanfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»»»»»»»» anonymousintegerfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»»»»»»»» anonymousnullfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»»»»»»»» anonymousnumberfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»»»»»»»» anonymousstringfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»»»»»»» anonymousobjectsfalsenonenone
»»»»»»»»»»» additionalPropertiesanyfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»»»»»»» anonymous[anyOf]falsenonenone

anyOf

NameTypeRequiredRestrictionsDescription
»»»»»»»»»»» anonymousanyfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»»»»»»»» anonymousobjectsfalsenonenone

continued

NameTypeRequiredRestrictionsDescription
»»»»»»» validationResponseanyfalsenonenone

anyOf

NameTypeRequiredRestrictionsDescription
»»»»»»»» anonymousstringfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»»»»» anonymousreaskfalsenonenone
»»»»»»»»» additionalPropertiesanyfalsenonenone
»»»»»»»»» incorrectValueanyfalsenonenone
»»»»»»»»» failResults[allOf]falsenonenone
»»»»»»»»»» FailResultfail-resultfalsenoneThe output from a single Validator.
»»»»»»»»»»» outcomeanytruenonenone
»»»»»»»»»»» errorMessagestringtruenonenone
»»»»»»»»»»» fixValueanyfalsenonenone
»»»»»»»»»»» errorSpans[error-span]falsenonenone
»»»»»»»»»»»» ErrorSpanerror-spanfalsenonenone
»»»»»»»»»»»»» startintegertruenonenone
»»»»»»»»»»»»» endintegertruenonenone
»»»»»»»»»»»»» reasonstringtruenoneThe reason validation failed, specific to this chunk.

or

NameTypeRequiredRestrictionsDescription
»»»»»»»» anonymousobjectfalsenonenone
»»»»»»»»» additionalPropertiesanyfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»»»»» anonymous[anyOf]falsenonenone
»»»»»»»»» AnyTypeanyfalsenonenone

continued

NameTypeRequiredRestrictionsDescription
»»»»»»» guardedOutputanyfalsenonenone

anyOf

NameTypeRequiredRestrictionsDescription
»»»»»»»» anonymousstringfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»»»»» anonymousobjectfalsenonenone
»»»»»»»»» additionalPropertiesanyfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»»»»» anonymous[anyOf]falsenonenone
»»»»»»»»» AnyTypeanyfalsenonenone

continued

NameTypeRequiredRestrictionsDescription
»»»»»»» reasks[reask]falsenonenone
»»»»»»»» ReAskreaskfalsenonenone
»»»»»»» validatorLogs[validator-log]falsenonenone
»»»»»»»» ValidatorLogvalidator-logfalsenonenone
»»»»»»»»» validatorNamestring(PascalCase)truenoneThe class name of the validator.
»»»»»»»»» registeredNamestring(kebab-case)truenoneThe registry id of the validator.
»»»»»»»»» instanceIdanyfalsenoneA unique identifier for the validator that produced this log within the session.

anyOf

NameTypeRequiredRestrictionsDescription
»»»»»»»»»» anonymousstringfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»»»»»»» anonymousintegerfalsenonenone

continued

NameTypeRequiredRestrictionsDescription
»»»»»»»»» propertyPathstringtruenoneThe JSON path to the property which was validated that produced this log.
»»»»»»»»» valueBeforeValidationanytruenonenone
»»»»»»»»» valueAfterValidationanyfalsenonenone
»»»»»»»»» validationResultanyfalsenonenone

anyOf

NameTypeRequiredRestrictionsDescription
»»»»»»»»»» anonymouspass-resultfalsenoneThe output from a single Validator.
»»»»»»»»»»» outcomeanytruenonenone
»»»»»»»»»»» valueOverrideanyfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»»»»»»» anonymousfail-resultfalsenoneThe output from a single Validator.
»»»»»»»»»»» outcomeanytruenonenone
»»»»»»»»»»» errorMessagestringtruenonenone
»»»»»»»»»»» fixValueanyfalsenonenone
»»»»»»»»»»» errorSpans[error-span]falsenonenone

continued

NameTypeRequiredRestrictionsDescription
»»»»»»»»» startTimestring(date-time)falsenonenone
»»»»»»»»» endTimestring(date-time)falsenonenone
»»»»»»» errorstringfalsenoneThe error message from any exception which interrupted the Guard execution process.
»»»» inputsCallInputsfalsenonenone

allOf

NameTypeRequiredRestrictionsDescription
»»»»» anonymousinputsfalsenonenone

and

NameTypeRequiredRestrictionsDescription
»»»»» anonymousargs-and-kwargsfalsenonenone
»»»»»» args[anyOf]falsenonenone
»»»»»»» AnyTypeanyfalsenonenone
»»»»»» kwargsobjectfalsenonenone
»»»»»»» additionalPropertiesanyfalsenonenone

continued

NameTypeRequiredRestrictionsDescription
»»»» exceptionstringfalsenonenone

Enumerated Values

PropertyValue
anonymousmessages
anonymousoutput
onFailexception
onFailfilter
onFailfix
onFailfix_reask
onFailnoop
onFailreask
onFailrefrain
onFailcustom
anonymousarray
anonymousboolean
anonymousinteger
anonymousnull
anonymousnumber
anonymousobject
anonymousstring

createGuard

POST /guards

Creates a Guard

Body parameter

{
"id": "string",
"name": "string",
"description": "string",
"validators": [
{
"id": "string",
"on": "messages",
"onFail": "exception",
"args": [
true
],
"kwargs": {
"property1": null,
"property2": null
}
}
],
"output_schema": {
"definitions": {},
"dependencies": {
"property1": {},
"property2": {}
},
"$anchor": "string",
"$ref": "../dictionary",
"$dynamicRef": "../dictionary",
"$dynamicAnchor": "string",
"$vocabulary": {
"property1": true,
"property2": true
},
"$comment": "string",
"$defs": {},
"prefixItems": [
null
],
"items": null,
"contains": null,
"additionalProperties": null,
"properties": {},
"patternProperties": {},
"dependentSchemas": {
"property1": null,
"property2": null
},
"propertyNames": null,
"if": null,
"then": null,
"else": null,
"allOf": [
null
],
"anyOf": [
null
],
"oneOf": [
null
],
"not": null,
"unevaluatedItems": null,
"unevaluatedProperties": null,
"multipleOf": 0,
"maximum": 0,
"exclusiveMaximum": 0,
"minimum": 0,
"exclusiveMinimum": 0,
"maxLength": 0,
"minLength": 0,
"pattern": "/regex/",
"maxItems": 0,
"minItems": 0,
"uniqueItems": false,
"maxContains": 0,
"minContains": 0,
"maxProperties": 0,
"minProperties": 0,
"required": [],
"dependentRequired": {
"property1": [],
"property2": []
},
"const": null,
"enum": [
null
],
"type": "array",
"title": "string",
"description": "string",
"default": null,
"deprecated": false,
"readOnly": false,
"writeOnly": false,
"examples": [
null
],
"format": "string",
"contentMediaType": "string",
"contentEncoding": "string",
"contentSchema": null
}
}

Parameters

NameInTypeRequiredDescription
bodybodyguardtruenone
» idbodystring(kebab-case)trueThe unique identifier for the Guard.
» namebodystringtrueThe name for the Guard.
» descriptionbodystringfalseA description that concisely states the expected behaviour or purpose of the Guard.
» validatorsbody[allOf]falsenone
»» ValidatorReferencebodyValidatorReferencefalsenone
»»» idbodystringtrueThe unique identifier for this Validator. Often the hub id; e.g. guardrails/regex_match
»»» onbodyanyfalseA reference to the property this validator should be applied against. Can be a valid JSON path or a meta-property such as "prompt" or "output"
»»»» anonymousbodystringfalsemeta-property
»»»» anonymousbodystringfalseJSON path to property; e.g. $.foo.bar
»»» onFailbodystringfalsenone
» output_schemabodyschemafalsenone
»» definitionsbodyobjectfalsenone
»»» additionalPropertiesbodyanyfalsenone
»» dependenciesbodyobjectfalsenone
»»» additionalPropertiesbodyanyfalsenone
»»»» anonymousbodyanyfalsenone
»»»» anonymousbody[string]falsenone
»» anonymousbodycorefalsenone
»»» $anchorbodystringfalsenone
»»» $refbodystring(uri-reference)falsenone
»»» $dynamicRefbodystring(uri-reference)falsenone
»»» $dynamicAnchorbodystringfalsenone
»»» $vocabularybodyobjectfalsenone
»»»» additionalPropertiesbodybooleanfalsenone
»»» $commentbodystringfalsenone
»»» $defsbodyobjectfalsenone
»»»» additionalPropertiesbodyanyfalsenone
»» anonymousbodyapplicatorfalsenone
»»» prefixItemsbody[any]falsenone
»»» itemsbodyanyfalsenone
»»» containsbodyanyfalsenone
»»» additionalPropertiesbodyanyfalsenone
»»» propertiesbodyobjectfalsenone
»»»» additionalPropertiesbodyanyfalsenone
»»» patternPropertiesbodyobjectfalsenone
»»»» additionalPropertiesbodyanyfalsenone
»»» dependentSchemasbodyobjectfalsenone
»»»» additionalPropertiesbodyanyfalsenone
»»» propertyNamesbodyanyfalsenone
»»» ifbodyanyfalsenone
»»» thenbodyanyfalsenone
»»» elsebodyanyfalsenone
»»» allOfbody[any]falsenone
»»» anyOfbody[any]falsenone
»»» oneOfbody[any]falsenone
»»» notbodyanyfalsenone
»» anonymousbodyunevaluatedfalsenone
»»» unevaluatedItemsbodyanyfalsenone
»»» unevaluatedPropertiesbodyanyfalsenone
»» anonymousbodyvalidationfalsenone
»»» multipleOfbodynumberfalsenone
»»» maximumbodynumberfalsenone
»»» exclusiveMaximumbodynumberfalsenone
»»» minimumbodynumberfalsenone
»»» exclusiveMinimumbodynumberfalsenone
»»» maxLengthbodynonNegativeIntegerfalsenone
»»» minLengthbodynonNegativeIntegerfalsenone
»»» patternbodystring(regex)falsenone
»»» maxItemsbodynonNegativeIntegerfalsenone
»»» minItemsbodynonNegativeIntegerfalsenone
»»» uniqueItemsbodybooleanfalsenone
»»» maxContainsbodynonNegativeIntegerfalsenone
»»» minContainsbodynonNegativeIntegerfalsenone
»»» maxPropertiesbodynonNegativeIntegerfalsenone
»»» minPropertiesbodynonNegativeIntegerfalsenone
»»» requiredbody[string]falsenone
»»» dependentRequiredbodyobjectfalsenone
»»»» additionalPropertiesbody[string]falsenone
»»» constbodyanyfalsenone
»»» enumbody[any]falsenone
»»» typebodyanyfalsenone
»»»» anonymousbodyanyfalsenone
»»»» anonymousbody[simpleTypes]falsenone
»» anonymousbodymeta-datafalsenone
»»» titlebodystringfalsenone
»»» descriptionbodystringfalsenone
»»» defaultbodyanyfalsenone
»»» deprecatedbodybooleanfalsenone
»»» readOnlybodybooleanfalsenone
»»» writeOnlybodybooleanfalsenone
»»» examplesbody[any]falsenone
»» anonymousbodyformat-annotationfalsenone
»»» formatbodystringfalsenone
»» anonymousbodycontentfalsenone
»»» contentMediaTypebodystringfalsenone
»»» contentEncodingbodystringfalsenone
»»» contentSchemabodyanyfalsenone
» historybody[call]falsenone
»» Callbodycallfalsenone
»»» idbodystringtrueThe unique identifier for this Call. Can be used as an identifier for a specific execution of a Guard.
»»» iterationsbody[iteration]falsenone
»»»» Iterationbodyiterationfalsenone
»»»»» idbodystringtrueThe unique identifier for this Call. Can be used as an identifier for a specific execution of a Guard.
»»»»» indexbodyintegertrueThe zero-based index of this iteration within the current Call.
»»»»» callIdbodystringtrueThe unique identifier for the Call that this iteration is a part of.
»»»»» inputsbodyinputsfalsenone
»»»»»» llmApibodystringfalseThe LLM resource targeted by the user. e.g. openai.chat.completions.create
»»»»»» llmOutputbodystringfalseThe string output from an external LLM call provided by the user via Guard.parse.
»»»»»» messagesbody[object]falseThe message history for chat models.
»»»»»»» additionalPropertiesbodyanyfalsenone
»»»»»» promptParamsbodyobjectfalseParameters to be formatted into the prompt.
»»»»»»» additionalPropertiesbodyanyfalsenone
»»»»»» numReasksbodyintegerfalseThe total number of times the LLM can be called to correct output excluding the initial call.
»»»»»» metadatabodyobjectfalseAdditional data to be used by Validators during execution time.
»»»»»»» additionalPropertiesbodyanyfalsenone
»»»»»» fullSchemaReaskbodybooleanfalseWhether to perform reasks for the entire schema rather than for individual fields.
»»»»»» streambodybooleanfalseWhether to use streaming.
»»»»» outputsbodyoutputsfalsenone
»»»»»» llmResponseInfobodyLLMResponsefalseInformation from the LLM response.
»»»»»»» promptTokenCountbodyintegerfalsenone
»»»»»»» responseTokenCountbodyintegerfalsenone
»»»»»»» outputbodystringtruenone
»»»»»»» streamOutputbody[string]falsenone
»»»»»»» asyncStreamOutputbody[string]falsenone
»»»»»» rawOutputbodystringfalseThe string content from the LLM response.
»»»»»» parsedOutputbodyanyfalsenone
»»»»»»» anonymousbodystringfalsenone
»»»»»»» anonymousbodyobjectfalsenone
»»»»»»»» additionalPropertiesbodyanyfalsenone
»»»»»»» anonymousbody[anyOf]falsenone
»»»»»»»» AnyTypebodyanyfalsenone
»»»»»»»»» anonymousbodyanyfalsenone
»»»»»»»»»» anonymousbodybooleanfalsenone
»»»»»»»»»» anonymousbodyintegerfalsenone
»»»»»»»»»» anonymousbodynullfalsenone
»»»»»»»»»» anonymousbodynumberfalsenone
»»»»»»»»»» anonymousbodystringfalsenone
»»»»»»»»» anonymousbodyobjectsfalsenone
»»»»»»»»»» additionalPropertiesbodyanyfalsenone
»»»»»»»»» anonymousbody[anyOf]falsenone
»»»»»»»»»» anonymousbodyanyfalsenone
»»»»»»»»»» anonymousbodyobjectsfalsenone
»»»»»» validationResponsebodyanyfalsenone
»»»»»»» anonymousbodystringfalsenone
»»»»»»» anonymousbodyreaskfalsenone
»»»»»»»» additionalPropertiesbodyanyfalsenone
»»»»»»»» incorrectValuebodyanyfalsenone
»»»»»»»» failResultsbody[allOf]falsenone
»»»»»»»»» FailResultbodyfail-resultfalseThe output from a single Validator.
»»»»»»»»»» outcomebodyanytruenone
»»»»»»»»»» errorMessagebodystringtruenone
»»»»»»»»»» fixValuebodyanyfalsenone
»»»»»»»»»» errorSpansbody[error-span]falsenone
»»»»»»»»»»» ErrorSpanbodyerror-spanfalsenone
»»»»»»»»»»»» startbodyintegertruenone
»»»»»»»»»»»» endbodyintegertruenone
»»»»»»»»»»»» reasonbodystringtrueThe reason validation failed, specific to this chunk.
»»»»»»» anonymousbodyobjectfalsenone
»»»»»»»» additionalPropertiesbodyanyfalsenone
»»»»»»» anonymousbody[anyOf]falsenone
»»»»»»»» AnyTypebodyanyfalsenone
»»»»»» guardedOutputbodyanyfalsenone
»»»»»»» anonymousbodystringfalsenone
»»»»»»» anonymousbodyobjectfalsenone
»»»»»»»» additionalPropertiesbodyanyfalsenone
»»»»»»» anonymousbody[anyOf]falsenone
»»»»»»»» AnyTypebodyanyfalsenone
»»»»»» reasksbody[reask]falsenone
»»»»»»» ReAskbodyreaskfalsenone
»»»»»» validatorLogsbody[validator-log]falsenone
»»»»»»» ValidatorLogbodyvalidator-logfalsenone
»»»»»»»» validatorNamebodystring(PascalCase)trueThe class name of the validator.
»»»»»»»» registeredNamebodystring(kebab-case)trueThe registry id of the validator.
»»»»»»»» instanceIdbodyanyfalseA unique identifier for the validator that produced this log within the session.
»»»»»»»»» anonymousbodystringfalsenone
»»»»»»»»» anonymousbodyintegerfalsenone
»»»»»»»» propertyPathbodystringtrueThe JSON path to the property which was validated that produced this log.
»»»»»»»» valueBeforeValidationbodyanytruenone
»»»»»»»» valueAfterValidationbodyanyfalsenone
»»»»»»»» validationResultbodyanyfalsenone
»»»»»»»»» anonymousbodypass-resultfalseThe output from a single Validator.
»»»»»»»»»» outcomebodyanytruenone
»»»»»»»»»» valueOverridebodyanyfalsenone
»»»»»»»»» anonymousbodyfail-resultfalseThe output from a single Validator.
»»»»»»»»»» outcomebodyanytruenone
»»»»»»»»»» errorMessagebodystringtruenone
»»»»»»»»»» fixValuebodyanyfalsenone
»»»»»»»»»» errorSpansbody[error-span]falsenone
»»»»»»»» startTimebodystring(date-time)falsenone
»»»»»»»» endTimebodystring(date-time)falsenone
»»»»»» errorbodystringfalseThe error message from any exception which interrupted the Guard execution process.
»»» inputsbodyCallInputsfalsenone
»»»» anonymousbodyinputsfalsenone
»»»» anonymousbodyargs-and-kwargsfalsenone
»»»»» argsbody[anyOf]falsenone
»»»»»» AnyTypebodyanyfalsenone
»»»»» kwargsbodyobjectfalsenone
»»»»»» additionalPropertiesbodyanyfalsenone
»»» exceptionbodystringfalsenone

Enumerated Values

ParameterValue
»»»» anonymousmessages
»»»» anonymousoutput
»»» onFailexception
»»» onFailfilter
»»» onFailfix
»»» onFailfix_reask
»»» onFailnoop
»»» onFailreask
»»» onFailrefrain
»»» onFailcustom
»»»» anonymousarray
»»»» anonymousboolean
»»»» anonymousinteger
»»»» anonymousnull
»»»» anonymousnumber
»»»» anonymousobject
»»»» anonymousstring
»»»» anonymousarray
»»»» anonymousboolean
»»»» anonymousinteger
»»»» anonymousnull
»»»» anonymousnumber
»»»» anonymousobject
»»»» anonymousstring

Example responses

200 Response

{
"id": "string",
"name": "string",
"description": "string",
"validators": [
{
"id": "string",
"on": "messages",
"onFail": "exception",
"args": [
true
],
"kwargs": {
"property1": null,
"property2": null
}
}
],
"output_schema": {
"definitions": {},
"dependencies": {
"property1": {},
"property2": {}
},
"$anchor": "string",
"$ref": "../dictionary",
"$dynamicRef": "../dictionary",
"$dynamicAnchor": "string",
"$vocabulary": {
"property1": true,
"property2": true
},
"$comment": "string",
"$defs": {},
"prefixItems": [
null
],
"items": null,
"contains": null,
"additionalProperties": null,
"properties": {},
"patternProperties": {},
"dependentSchemas": {
"property1": null,
"property2": null
},
"propertyNames": null,
"if": null,
"then": null,
"else": null,
"allOf": [
null
],
"anyOf": [
null
],
"oneOf": [
null
],
"not": null,
"unevaluatedItems": null,
"unevaluatedProperties": null,
"multipleOf": 0,
"maximum": 0,
"exclusiveMaximum": 0,
"minimum": 0,
"exclusiveMinimum": 0,
"maxLength": 0,
"minLength": 0,
"pattern": "/regex/",
"maxItems": 0,
"minItems": 0,
"uniqueItems": false,
"maxContains": 0,
"minContains": 0,
"maxProperties": 0,
"minProperties": 0,
"required": [],
"dependentRequired": {
"property1": [],
"property2": []
},
"const": null,
"enum": [
null
],
"type": "array",
"title": "string",
"description": "string",
"default": null,
"deprecated": false,
"readOnly": false,
"writeOnly": false,
"examples": [
null
],
"format": "string",
"contentMediaType": "string",
"contentEncoding": "string",
"contentSchema": null
},
"history": [
{
"id": "string",
"iterations": [],
"inputs": {
"llmApi": "string",
"llmOutput": "string",
"messages": [
{
"property1": null,
"property2": null
}
],
"promptParams": {
"property1": null,
"property2": null
},
"numReasks": 0,
"metadata": {
"property1": null,
"property2": null
},
"fullSchemaReask": true,
"stream": true,
"args": [
true
],
"kwargs": {
"property1": null,
"property2": null
}
},
"exception": "string"
}
]
}

Responses

StatusMeaningDescriptionSchema
200OKthe new Guardguard
defaultDefaultUnexpected errorHttpError

getGuard

GET /guards/{guardName}

Fetches a specific Guard

Parameters

NameInTypeRequiredDescription
guardNamepathstringtrueGuard name
asOfquerystring(date-time)falseUsed to query for data as it existed at this date and time

Example responses

200 Response

{
"id": "string",
"name": "string",
"description": "string",
"validators": [
{
"id": "string",
"on": "messages",
"onFail": "exception",
"args": [
true
],
"kwargs": {
"property1": null,
"property2": null
}
}
],
"output_schema": {
"definitions": {},
"dependencies": {
"property1": {},
"property2": {}
},
"$anchor": "string",
"$ref": "../dictionary",
"$dynamicRef": "../dictionary",
"$dynamicAnchor": "string",
"$vocabulary": {
"property1": true,
"property2": true
},
"$comment": "string",
"$defs": {},
"prefixItems": [
null
],
"items": null,
"contains": null,
"additionalProperties": null,
"properties": {},
"patternProperties": {},
"dependentSchemas": {
"property1": null,
"property2": null
},
"propertyNames": null,
"if": null,
"then": null,
"else": null,
"allOf": [
null
],
"anyOf": [
null
],
"oneOf": [
null
],
"not": null,
"unevaluatedItems": null,
"unevaluatedProperties": null,
"multipleOf": 0,
"maximum": 0,
"exclusiveMaximum": 0,
"minimum": 0,
"exclusiveMinimum": 0,
"maxLength": 0,
"minLength": 0,
"pattern": "/regex/",
"maxItems": 0,
"minItems": 0,
"uniqueItems": false,
"maxContains": 0,
"minContains": 0,
"maxProperties": 0,
"minProperties": 0,
"required": [],
"dependentRequired": {
"property1": [],
"property2": []
},
"const": null,
"enum": [
null
],
"type": "array",
"title": "string",
"description": "string",
"default": null,
"deprecated": false,
"readOnly": false,
"writeOnly": false,
"examples": [
null
],
"format": "string",
"contentMediaType": "string",
"contentEncoding": "string",
"contentSchema": null
},
"history": [
{
"id": "string",
"iterations": [],
"inputs": {
"llmApi": "string",
"llmOutput": "string",
"messages": [
{
"property1": null,
"property2": null
}
],
"promptParams": {
"property1": null,
"property2": null
},
"numReasks": 0,
"metadata": {
"property1": null,
"property2": null
},
"fullSchemaReask": true,
"stream": true,
"args": [
true
],
"kwargs": {
"property1": null,
"property2": null
}
},
"exception": "string"
}
]
}

Responses

StatusMeaningDescriptionSchema
200OKthe fetched Guardguard
defaultDefaultUnexpected errorHttpError

updateGuard

PUT /guards/{guardName}

Updates a Guard

Body parameter

{
"id": "string",
"name": "string",
"description": "string",
"validators": [
{
"id": "string",
"on": "messages",
"onFail": "exception",
"args": [
true
],
"kwargs": {
"property1": null,
"property2": null
}
}
],
"output_schema": {
"definitions": {},
"dependencies": {
"property1": {},
"property2": {}
},
"$anchor": "string",
"$ref": "../dictionary",
"$dynamicRef": "../dictionary",
"$dynamicAnchor": "string",
"$vocabulary": {
"property1": true,
"property2": true
},
"$comment": "string",
"$defs": {},
"prefixItems": [
null
],
"items": null,
"contains": null,
"additionalProperties": null,
"properties": {},
"patternProperties": {},
"dependentSchemas": {
"property1": null,
"property2": null
},
"propertyNames": null,
"if": null,
"then": null,
"else": null,
"allOf": [
null
],
"anyOf": [
null
],
"oneOf": [
null
],
"not": null,
"unevaluatedItems": null,
"unevaluatedProperties": null,
"multipleOf": 0,
"maximum": 0,
"exclusiveMaximum": 0,
"minimum": 0,
"exclusiveMinimum": 0,
"maxLength": 0,
"minLength": 0,
"pattern": "/regex/",
"maxItems": 0,
"minItems": 0,
"uniqueItems": false,
"maxContains": 0,
"minContains": 0,
"maxProperties": 0,
"minProperties": 0,
"required": [],
"dependentRequired": {
"property1": [],
"property2": []
},
"const": null,
"enum": [
null
],
"type": "array",
"title": "string",
"description": "string",
"default": null,
"deprecated": false,
"readOnly": false,
"writeOnly": false,
"examples": [
null
],
"format": "string",
"contentMediaType": "string",
"contentEncoding": "string",
"contentSchema": null
}
}

Parameters

NameInTypeRequiredDescription
guardNamepathstringtrueGuard name
bodybodyguardtruenone
» idbodystring(kebab-case)trueThe unique identifier for the Guard.
» namebodystringtrueThe name for the Guard.
» descriptionbodystringfalseA description that concisely states the expected behaviour or purpose of the Guard.
» validatorsbody[allOf]falsenone
»» ValidatorReferencebodyValidatorReferencefalsenone
»»» idbodystringtrueThe unique identifier for this Validator. Often the hub id; e.g. guardrails/regex_match
»»» onbodyanyfalseA reference to the property this validator should be applied against. Can be a valid JSON path or a meta-property such as "prompt" or "output"
»»»» anonymousbodystringfalsemeta-property
»»»» anonymousbodystringfalseJSON path to property; e.g. $.foo.bar
»»» onFailbodystringfalsenone
» output_schemabodyschemafalsenone
»» definitionsbodyobjectfalsenone
»»» additionalPropertiesbodyanyfalsenone
»» dependenciesbodyobjectfalsenone
»»» additionalPropertiesbodyanyfalsenone
»»»» anonymousbodyanyfalsenone
»»»» anonymousbody[string]falsenone
»» anonymousbodycorefalsenone
»»» $anchorbodystringfalsenone
»»» $refbodystring(uri-reference)falsenone
»»» $dynamicRefbodystring(uri-reference)falsenone
»»» $dynamicAnchorbodystringfalsenone
»»» $vocabularybodyobjectfalsenone
»»»» additionalPropertiesbodybooleanfalsenone
»»» $commentbodystringfalsenone
»»» $defsbodyobjectfalsenone
»»»» additionalPropertiesbodyanyfalsenone
»» anonymousbodyapplicatorfalsenone
»»» prefixItemsbody[any]falsenone
»»» itemsbodyanyfalsenone
»»» containsbodyanyfalsenone
»»» additionalPropertiesbodyanyfalsenone
»»» propertiesbodyobjectfalsenone
»»»» additionalPropertiesbodyanyfalsenone
»»» patternPropertiesbodyobjectfalsenone
»»»» additionalPropertiesbodyanyfalsenone
»»» dependentSchemasbodyobjectfalsenone
»»»» additionalPropertiesbodyanyfalsenone
»»» propertyNamesbodyanyfalsenone
»»» ifbodyanyfalsenone
»»» thenbodyanyfalsenone
»»» elsebodyanyfalsenone
»»» allOfbody[any]falsenone
»»» anyOfbody[any]falsenone
»»» oneOfbody[any]falsenone
»»» notbodyanyfalsenone
»» anonymousbodyunevaluatedfalsenone
»»» unevaluatedItemsbodyanyfalsenone
»»» unevaluatedPropertiesbodyanyfalsenone
»» anonymousbodyvalidationfalsenone
»»» multipleOfbodynumberfalsenone
»»» maximumbodynumberfalsenone
»»» exclusiveMaximumbodynumberfalsenone
»»» minimumbodynumberfalsenone
»»» exclusiveMinimumbodynumberfalsenone
»»» maxLengthbodynonNegativeIntegerfalsenone
»»» minLengthbodynonNegativeIntegerfalsenone
»»» patternbodystring(regex)falsenone
»»» maxItemsbodynonNegativeIntegerfalsenone
»»» minItemsbodynonNegativeIntegerfalsenone
»»» uniqueItemsbodybooleanfalsenone
»»» maxContainsbodynonNegativeIntegerfalsenone
»»» minContainsbodynonNegativeIntegerfalsenone
»»» maxPropertiesbodynonNegativeIntegerfalsenone
»»» minPropertiesbodynonNegativeIntegerfalsenone
»»» requiredbody[string]falsenone
»»» dependentRequiredbodyobjectfalsenone
»»»» additionalPropertiesbody[string]falsenone
»»» constbodyanyfalsenone
»»» enumbody[any]falsenone
»»» typebodyanyfalsenone
»»»» anonymousbodyanyfalsenone
»»»» anonymousbody[simpleTypes]falsenone
»» anonymousbodymeta-datafalsenone
»»» titlebodystringfalsenone
»»» descriptionbodystringfalsenone
»»» defaultbodyanyfalsenone
»»» deprecatedbodybooleanfalsenone
»»» readOnlybodybooleanfalsenone
»»» writeOnlybodybooleanfalsenone
»»» examplesbody[any]falsenone
»» anonymousbodyformat-annotationfalsenone
»»» formatbodystringfalsenone
»» anonymousbodycontentfalsenone
»»» contentMediaTypebodystringfalsenone
»»» contentEncodingbodystringfalsenone
»»» contentSchemabodyanyfalsenone
» historybody[call]falsenone
»» Callbodycallfalsenone
»»» idbodystringtrueThe unique identifier for this Call. Can be used as an identifier for a specific execution of a Guard.
»»» iterationsbody[iteration]falsenone
»»»» Iterationbodyiterationfalsenone
»»»»» idbodystringtrueThe unique identifier for this Call. Can be used as an identifier for a specific execution of a Guard.
»»»»» indexbodyintegertrueThe zero-based index of this iteration within the current Call.
»»»»» callIdbodystringtrueThe unique identifier for the Call that this iteration is a part of.
»»»»» inputsbodyinputsfalsenone
»»»»»» llmApibodystringfalseThe LLM resource targeted by the user. e.g. openai.chat.completions.create
»»»»»» llmOutputbodystringfalseThe string output from an external LLM call provided by the user via Guard.parse.
»»»»»» messagesbody[object]falseThe message history for chat models.
»»»»»»» additionalPropertiesbodyanyfalsenone
»»»»»» promptParamsbodyobjectfalseParameters to be formatted into the prompt.
»»»»»»» additionalPropertiesbodyanyfalsenone
»»»»»» numReasksbodyintegerfalseThe total number of times the LLM can be called to correct output excluding the initial call.
»»»»»» metadatabodyobjectfalseAdditional data to be used by Validators during execution time.
»»»»»»» additionalPropertiesbodyanyfalsenone
»»»»»» fullSchemaReaskbodybooleanfalseWhether to perform reasks for the entire schema rather than for individual fields.
»»»»»» streambodybooleanfalseWhether to use streaming.
»»»»» outputsbodyoutputsfalsenone
»»»»»» llmResponseInfobodyLLMResponsefalseInformation from the LLM response.
»»»»»»» promptTokenCountbodyintegerfalsenone
»»»»»»» responseTokenCountbodyintegerfalsenone
»»»»»»» outputbodystringtruenone
»»»»»»» streamOutputbody[string]falsenone
»»»»»»» asyncStreamOutputbody[string]falsenone
»»»»»» rawOutputbodystringfalseThe string content from the LLM response.
»»»»»» parsedOutputbodyanyfalsenone
»»»»»»» anonymousbodystringfalsenone
»»»»»»» anonymousbodyobjectfalsenone
»»»»»»»» additionalPropertiesbodyanyfalsenone
»»»»»»» anonymousbody[anyOf]falsenone
»»»»»»»» AnyTypebodyanyfalsenone
»»»»»»»»» anonymousbodyanyfalsenone
»»»»»»»»»» anonymousbodybooleanfalsenone
»»»»»»»»»» anonymousbodyintegerfalsenone
»»»»»»»»»» anonymousbodynullfalsenone
»»»»»»»»»» anonymousbodynumberfalsenone
»»»»»»»»»» anonymousbodystringfalsenone
»»»»»»»»» anonymousbodyobjectsfalsenone
»»»»»»»»»» additionalPropertiesbodyanyfalsenone
»»»»»»»»» anonymousbody[anyOf]falsenone
»»»»»»»»»» anonymousbodyanyfalsenone
»»»»»»»»»» anonymousbodyobjectsfalsenone
»»»»»» validationResponsebodyanyfalsenone
»»»»»»» anonymousbodystringfalsenone
»»»»»»» anonymousbodyreaskfalsenone
»»»»»»»» additionalPropertiesbodyanyfalsenone
»»»»»»»» incorrectValuebodyanyfalsenone
»»»»»»»» failResultsbody[allOf]falsenone
»»»»»»»»» FailResultbodyfail-resultfalseThe output from a single Validator.
»»»»»»»»»» outcomebodyanytruenone
»»»»»»»»»» errorMessagebodystringtruenone
»»»»»»»»»» fixValuebodyanyfalsenone
»»»»»»»»»» errorSpansbody[error-span]falsenone
»»»»»»»»»»» ErrorSpanbodyerror-spanfalsenone
»»»»»»»»»»»» startbodyintegertruenone
»»»»»»»»»»»» endbodyintegertruenone
»»»»»»»»»»»» reasonbodystringtrueThe reason validation failed, specific to this chunk.
»»»»»»» anonymousbodyobjectfalsenone
»»»»»»»» additionalPropertiesbodyanyfalsenone
»»»»»»» anonymousbody[anyOf]falsenone
»»»»»»»» AnyTypebodyanyfalsenone
»»»»»» guardedOutputbodyanyfalsenone
»»»»»»» anonymousbodystringfalsenone
»»»»»»» anonymousbodyobjectfalsenone
»»»»»»»» additionalPropertiesbodyanyfalsenone
»»»»»»» anonymousbody[anyOf]falsenone
»»»»»»»» AnyTypebodyanyfalsenone
»»»»»» reasksbody[reask]falsenone
»»»»»»» ReAskbodyreaskfalsenone
»»»»»» validatorLogsbody[validator-log]falsenone
»»»»»»» ValidatorLogbodyvalidator-logfalsenone
»»»»»»»» validatorNamebodystring(PascalCase)trueThe class name of the validator.
»»»»»»»» registeredNamebodystring(kebab-case)trueThe registry id of the validator.
»»»»»»»» instanceIdbodyanyfalseA unique identifier for the validator that produced this log within the session.
»»»»»»»»» anonymousbodystringfalsenone
»»»»»»»»» anonymousbodyintegerfalsenone
»»»»»»»» propertyPathbodystringtrueThe JSON path to the property which was validated that produced this log.
»»»»»»»» valueBeforeValidationbodyanytruenone
»»»»»»»» valueAfterValidationbodyanyfalsenone
»»»»»»»» validationResultbodyanyfalsenone
»»»»»»»»» anonymousbodypass-resultfalseThe output from a single Validator.
»»»»»»»»»» outcomebodyanytruenone
»»»»»»»»»» valueOverridebodyanyfalsenone
»»»»»»»»» anonymousbodyfail-resultfalseThe output from a single Validator.
»»»»»»»»»» outcomebodyanytruenone
»»»»»»»»»» errorMessagebodystringtruenone
»»»»»»»»»» fixValuebodyanyfalsenone
»»»»»»»»»» errorSpansbody[error-span]falsenone
»»»»»»»» startTimebodystring(date-time)falsenone
»»»»»»»» endTimebodystring(date-time)falsenone
»»»»»» errorbodystringfalseThe error message from any exception which interrupted the Guard execution process.
»»» inputsbodyCallInputsfalsenone
»»»» anonymousbodyinputsfalsenone
»»»» anonymousbodyargs-and-kwargsfalsenone
»»»»» argsbody[anyOf]falsenone
»»»»»» AnyTypebodyanyfalsenone
»»»»» kwargsbodyobjectfalsenone
»»»»»» additionalPropertiesbodyanyfalsenone
»»» exceptionbodystringfalsenone

Enumerated Values

ParameterValue
»»»» anonymousmessages
»»»» anonymousoutput
»»» onFailexception
»»» onFailfilter
»»» onFailfix
»»» onFailfix_reask
»»» onFailnoop
»»» onFailreask
»»» onFailrefrain
»»» onFailcustom
»»»» anonymousarray
»»»» anonymousboolean
»»»» anonymousinteger
»»»» anonymousnull
»»»» anonymousnumber
»»»» anonymousobject
»»»» anonymousstring
»»»» anonymousarray
»»»» anonymousboolean
»»»» anonymousinteger
»»»» anonymousnull
»»»» anonymousnumber
»»»» anonymousobject
»»»» anonymousstring

Example responses

200 Response

{
"id": "string",
"name": "string",
"description": "string",
"validators": [
{
"id": "string",
"on": "messages",
"onFail": "exception",
"args": [
true
],
"kwargs": {
"property1": null,
"property2": null
}
}
],
"output_schema": {
"definitions": {},
"dependencies": {
"property1": {},
"property2": {}
},
"$anchor": "string",
"$ref": "../dictionary",
"$dynamicRef": "../dictionary",
"$dynamicAnchor": "string",
"$vocabulary": {
"property1": true,
"property2": true
},
"$comment": "string",
"$defs": {},
"prefixItems": [
null
],
"items": null,
"contains": null,
"additionalProperties": null,
"properties": {},
"patternProperties": {},
"dependentSchemas": {
"property1": null,
"property2": null
},
"propertyNames": null,
"if": null,
"then": null,
"else": null,
"allOf": [
null
],
"anyOf": [
null
],
"oneOf": [
null
],
"not": null,
"unevaluatedItems": null,
"unevaluatedProperties": null,
"multipleOf": 0,
"maximum": 0,
"exclusiveMaximum": 0,
"minimum": 0,
"exclusiveMinimum": 0,
"maxLength": 0,
"minLength": 0,
"pattern": "/regex/",
"maxItems": 0,
"minItems": 0,
"uniqueItems": false,
"maxContains": 0,
"minContains": 0,
"maxProperties": 0,
"minProperties": 0,
"required": [],
"dependentRequired": {
"property1": [],
"property2": []
},
"const": null,
"enum": [
null
],
"type": "array",
"title": "string",
"description": "string",
"default": null,
"deprecated": false,
"readOnly": false,
"writeOnly": false,
"examples": [
null
],
"format": "string",
"contentMediaType": "string",
"contentEncoding": "string",
"contentSchema": null
},
"history": [
{
"id": "string",
"iterations": [],
"inputs": {
"llmApi": "string",
"llmOutput": "string",
"messages": [
{
"property1": null,
"property2": null
}
],
"promptParams": {
"property1": null,
"property2": null
},
"numReasks": 0,
"metadata": {
"property1": null,
"property2": null
},
"fullSchemaReask": true,
"stream": true,
"args": [
true
],
"kwargs": {
"property1": null,
"property2": null
}
},
"exception": "string"
}
]
}

Responses

StatusMeaningDescriptionSchema
200OKthe updated Guardguard
defaultDefaultUnexpected errorHttpError

deleteGuard

DELETE /guards/{guardName}

Deletes a Guard

Parameters

NameInTypeRequiredDescription
guardNamepathstringtrueGuard name

Example responses

200 Response

{
"id": "string",
"name": "string",
"description": "string",
"validators": [
{
"id": "string",
"on": "messages",
"onFail": "exception",
"args": [
true
],
"kwargs": {
"property1": null,
"property2": null
}
}
],
"output_schema": {
"definitions": {},
"dependencies": {
"property1": {},
"property2": {}
},
"$anchor": "string",
"$ref": "../dictionary",
"$dynamicRef": "../dictionary",
"$dynamicAnchor": "string",
"$vocabulary": {
"property1": true,
"property2": true
},
"$comment": "string",
"$defs": {},
"prefixItems": [
null
],
"items": null,
"contains": null,
"additionalProperties": null,
"properties": {},
"patternProperties": {},
"dependentSchemas": {
"property1": null,
"property2": null
},
"propertyNames": null,
"if": null,
"then": null,
"else": null,
"allOf": [
null
],
"anyOf": [
null
],
"oneOf": [
null
],
"not": null,
"unevaluatedItems": null,
"unevaluatedProperties": null,
"multipleOf": 0,
"maximum": 0,
"exclusiveMaximum": 0,
"minimum": 0,
"exclusiveMinimum": 0,
"maxLength": 0,
"minLength": 0,
"pattern": "/regex/",
"maxItems": 0,
"minItems": 0,
"uniqueItems": false,
"maxContains": 0,
"minContains": 0,
"maxProperties": 0,
"minProperties": 0,
"required": [],
"dependentRequired": {
"property1": [],
"property2": []
},
"const": null,
"enum": [
null
],
"type": "array",
"title": "string",
"description": "string",
"default": null,
"deprecated": false,
"readOnly": false,
"writeOnly": false,
"examples": [
null
],
"format": "string",
"contentMediaType": "string",
"contentEncoding": "string",
"contentSchema": null
},
"history": [
{
"id": "string",
"iterations": [],
"inputs": {
"llmApi": "string",
"llmOutput": "string",
"messages": [
{
"property1": null,
"property2": null
}
],
"promptParams": {
"property1": null,
"property2": null
},
"numReasks": 0,
"metadata": {
"property1": null,
"property2": null
},
"fullSchemaReask": true,
"stream": true,
"args": [
true
],
"kwargs": {
"property1": null,
"property2": null
}
},
"exception": "string"
}
]
}

Responses

StatusMeaningDescriptionSchema
200OKthe deleted Guardguard
defaultDefaultUnexpected errorHttpError

getGuardHistory

GET /guards/{guardName}/history/{callId}

Fetches the history for a specific Guard execution by using the id for the most recent Call

Parameters

NameInTypeRequiredDescription
guardNamepathstringtrueGuard name
callIdpathstringtrueCall id

Example responses

200 Response

[
{
"id": "string",
"iterations": [],
"inputs": {
"llmApi": "string",
"llmOutput": "string",
"messages": [
{
"property1": null,
"property2": null
}
],
"promptParams": {
"property1": null,
"property2": null
},
"numReasks": 0,
"metadata": {
"property1": null,
"property2": null
},
"fullSchemaReask": true,
"stream": true,
"args": [
true
],
"kwargs": {
"property1": null,
"property2": null
}
},
"exception": "string"
}
]

Responses

StatusMeaningDescriptionSchema
200OKthe fetched Guard HistoryInline
defaultDefaultUnexpected errorHttpError

Response Schema

Status Code 200

NameTypeRequiredRestrictionsDescription
anonymous[call]falsenonenone
» Callcallfalsenonenone
»» idstringtruenoneThe unique identifier for this Call. Can be used as an identifier for a specific execution of a Guard.
»» iterations[iteration]falsenonenone
»»» Iterationiterationfalsenonenone
»»»» idstringtruenoneThe unique identifier for this Call. Can be used as an identifier for a specific execution of a Guard.
»»»» indexintegertruenoneThe zero-based index of this iteration within the current Call.
»»»» callIdstringtruenoneThe unique identifier for the Call that this iteration is a part of.
»»»» inputsinputsfalsenonenone
»»»»» llmApistringfalsenoneThe LLM resource targeted by the user. e.g. openai.chat.completions.create
»»»»» llmOutputstringfalsenoneThe string output from an external LLM call provided by the user via Guard.parse.
»»»»» messages[object]falsenoneThe message history for chat models.
»»»»»» additionalPropertiesanyfalsenonenone
»»»»» promptParamsobjectfalsenoneParameters to be formatted into the prompt.
»»»»»» additionalPropertiesanyfalsenonenone
»»»»» numReasksintegerfalsenoneThe total number of times the LLM can be called to correct output excluding the initial call.
»»»»» metadataobjectfalsenoneAdditional data to be used by Validators during execution time.
»»»»»» additionalPropertiesanyfalsenonenone
»»»»» fullSchemaReaskbooleanfalsenoneWhether to perform reasks for the entire schema rather than for individual fields.
»»»»» streambooleanfalsenoneWhether to use streaming.
»»»» outputsoutputsfalsenonenone
»»»»» llmResponseInfoLLMResponsefalsenoneInformation from the LLM response.
»»»»»» promptTokenCountintegerfalsenonenone
»»»»»» responseTokenCountintegerfalsenonenone
»»»»»» outputstringtruenonenone
»»»»»» streamOutput[string]falsenonenone
»»»»»» asyncStreamOutput[string]falsenonenone
»»»»» rawOutputstringfalsenoneThe string content from the LLM response.
»»»»» parsedOutputanyfalsenonenone

anyOf

NameTypeRequiredRestrictionsDescription
»»»»»» anonymousstringfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»»» anonymousobjectfalsenonenone
»»»»»»» additionalPropertiesanyfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»»» anonymous[anyOf]falsenonenone
»»»»»»» AnyTypeanyfalsenonenone

anyOf

NameTypeRequiredRestrictionsDescription
»»»»»»»» anonymousanyfalsenonenone

anyOf

NameTypeRequiredRestrictionsDescription
»»»»»»»»» anonymousbooleanfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»»»»»» anonymousintegerfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»»»»»» anonymousnullfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»»»»»» anonymousnumberfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»»»»»» anonymousstringfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»»»»» anonymousobjectsfalsenonenone
»»»»»»»»» additionalPropertiesanyfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»»»»» anonymous[anyOf]falsenonenone

anyOf

NameTypeRequiredRestrictionsDescription
»»»»»»»»» anonymousanyfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»»»»»» anonymousobjectsfalsenonenone

continued

NameTypeRequiredRestrictionsDescription
»»»»» validationResponseanyfalsenonenone

anyOf

NameTypeRequiredRestrictionsDescription
»»»»»» anonymousstringfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»»» anonymousreaskfalsenonenone
»»»»»»» additionalPropertiesanyfalsenonenone
»»»»»»» incorrectValueanyfalsenonenone
»»»»»»» failResults[allOf]falsenonenone
»»»»»»»» FailResultfail-resultfalsenoneThe output from a single Validator.
»»»»»»»»» outcomeanytruenonenone
»»»»»»»»» errorMessagestringtruenonenone
»»»»»»»»» fixValueanyfalsenonenone
»»»»»»»»» errorSpans[error-span]falsenonenone
»»»»»»»»»» ErrorSpanerror-spanfalsenonenone
»»»»»»»»»»» startintegertruenonenone
»»»»»»»»»»» endintegertruenonenone
»»»»»»»»»»» reasonstringtruenoneThe reason validation failed, specific to this chunk.

or

NameTypeRequiredRestrictionsDescription
»»»»»» anonymousobjectfalsenonenone
»»»»»»» additionalPropertiesanyfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»»» anonymous[anyOf]falsenonenone
»»»»»»» AnyTypeanyfalsenonenone

continued

NameTypeRequiredRestrictionsDescription
»»»»» guardedOutputanyfalsenonenone

anyOf

NameTypeRequiredRestrictionsDescription
»»»»»» anonymousstringfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»»» anonymousobjectfalsenonenone
»»»»»»» additionalPropertiesanyfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»»» anonymous[anyOf]falsenonenone
»»»»»»» AnyTypeanyfalsenonenone

continued

NameTypeRequiredRestrictionsDescription
»»»»» reasks[reask]falsenonenone
»»»»»» ReAskreaskfalsenonenone
»»»»» validatorLogs[validator-log]falsenonenone
»»»»»» ValidatorLogvalidator-logfalsenonenone
»»»»»»» validatorNamestring(PascalCase)truenoneThe class name of the validator.
»»»»»»» registeredNamestring(kebab-case)truenoneThe registry id of the validator.
»»»»»»» instanceIdanyfalsenoneA unique identifier for the validator that produced this log within the session.

anyOf

NameTypeRequiredRestrictionsDescription
»»»»»»»» anonymousstringfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»»»»» anonymousintegerfalsenonenone

continued

NameTypeRequiredRestrictionsDescription
»»»»»»» propertyPathstringtruenoneThe JSON path to the property which was validated that produced this log.
»»»»»»» valueBeforeValidationanytruenonenone
»»»»»»» valueAfterValidationanyfalsenonenone
»»»»»»» validationResultanyfalsenonenone

anyOf

NameTypeRequiredRestrictionsDescription
»»»»»»»» anonymouspass-resultfalsenoneThe output from a single Validator.
»»»»»»»»» outcomeanytruenonenone
»»»»»»»»» valueOverrideanyfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»»»»»»»» anonymousfail-resultfalsenoneThe output from a single Validator.
»»»»»»»»» outcomeanytruenonenone
»»»»»»»»» errorMessagestringtruenonenone
»»»»»»»»» fixValueanyfalsenonenone
»»»»»»»»» errorSpans[error-span]falsenonenone

continued

NameTypeRequiredRestrictionsDescription
»»»»»»» startTimestring(date-time)falsenonenone
»»»»»»» endTimestring(date-time)falsenonenone
»»»»» errorstringfalsenoneThe error message from any exception which interrupted the Guard execution process.
»» inputsCallInputsfalsenonenone

allOf

NameTypeRequiredRestrictionsDescription
»»» anonymousinputsfalsenonenone

and

NameTypeRequiredRestrictionsDescription
»»» anonymousargs-and-kwargsfalsenonenone
»»»» args[anyOf]falsenonenone
»»»»» AnyTypeanyfalsenonenone
»»»» kwargsobjectfalsenonenone
»»»»» additionalPropertiesanyfalsenonenone

continued

NameTypeRequiredRestrictionsDescription
»» exceptionstringfalsenonenone

openai

openaiChatCompletion

POST /guards/{guardName}/openai/v1/chat/completions

OpenAI SDK compatible endpoint for Chat Completions

Body parameter

{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "string",
"content": "string"
}
],
"max_tokens": 0,
"temperature": 0
}

Parameters

NameInTypeRequiredDescription
guardNamepathstringtrueGuard name
bodybodyOpenAIChatCompletionPayloadtruenone
» modelbodystringfalseThe model to use for the completion
» messagesbody[object]falseThe messages to use for the completion
»» rolebodystringfalseThe role of the message
»» contentbodystringfalseThe content of the message
» max_tokensbodyintegerfalseThe maximum number of tokens to generate
» temperaturebodynumberfalseThe sampling temperature

Example responses

200 Response

{
"id": "string",
"created": "string",
"model_name": "string",
"choices": [
{
"role": "string",
"content": "string"
}
]
}

Responses

StatusMeaningDescriptionSchema
200OKThe output of the completionOpenAIChatCompletion
defaultDefaultUnexpected errorHttpError

validate

validate

POST /guards/{guardName}/validate

Runs the validations specified in a Guard

Body parameter

{
"llmOutput": "stubbed llm output",
"numReasks": 0,
"promptParams": {
"property1": null,
"property2": null
},
"llmApi": "openai.Completion.create",
"property1": null,
"property2": null
}

Parameters

NameInTypeRequiredDescription
guardNamepathstringtrueGuard name
x-openai-api-keyheaderstring(password)falseA valid OpenAI API Key for calling LLM's on your behalf
bodybodyValidatePayloadtruenone
» additionalPropertiesbodyanyfalsenone
» llmOutputbodystringfalseThe LLM output as a string or the input prompts for the LLM
» numReasksbodyintegerfalseAn override for the number of re-asks to perform
» promptParamsbodyobjectfalseadditional params for llm prompts
»» additionalPropertiesbodyanyfalsenone
» llmApibodyLLMResourcefalsenone

Enumerated Values

ParameterValue
» llmApiopenai.Completion.create
» llmApiopenai.completions.create
» llmApiopenai.ChatCompletion.create
» llmApiopenai.chat.completions.create
» llmApiopenai.Completion.acreate
» llmApiopenai.ChatCompletion.acreate
» llmApilitellm.completion
» llmApilitellm.acompletion

Example responses

200 Response

{
"callId": "string",
"rawLlmOutput": "string",
"validatedOutput": "string",
"reask": {
"incorrectValue": true,
"failResults": [
{
"outcome": "pass",
"errorMessage": "string",
"fixValue": true,
"errorSpans": [
{
"start": 0,
"end": 0,
"reason": "string"
}
],
"metadata": {
"property1": null,
"property2": null
},
"validatedChunk": true
}
],
"property1": null,
"property2": null
},
"validationPassed": true,
"error": "string"
}

Responses

StatusMeaningDescriptionSchema
200OKThe output of the validationvalidation-outcome
defaultDefaultUnexpected errorHttpError

Schemas

OpenAIChatCompletionPayload

{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "string",
"content": "string"
}
],
"max_tokens": 0,
"temperature": 0
}

Properties

NameTypeRequiredRestrictionsDescription
modelstringfalsenoneThe model to use for the completion
messages[object]falsenoneThe messages to use for the completion
» rolestringfalsenoneThe role of the message
» contentstringfalsenoneThe content of the message
max_tokensintegerfalsenoneThe maximum number of tokens to generate
temperaturenumberfalsenoneThe sampling temperature

OpenAIChatCompletion

{
"id": "string",
"created": "string",
"model_name": "string",
"choices": [
{
"role": "string",
"content": "string"
}
]
}

Properties

NameTypeRequiredRestrictionsDescription
idstringtruenoneThe id
createdstringtruenoneThe created date
model_namestringtruenoneThe model name
choices[object]truenonenone
» rolestringfalsenoneThe role of the message
» contentstringfalsenoneThe content of the message

HttpError

{
"status": 0,
"message": "string",
"cause": "string",
"fields": {
"property1": [
"string"
],
"property2": [
"string"
]
},
"context": "string"
}

Properties

NameTypeRequiredRestrictionsDescription
statusintegertruenoneA valid http status code
messagestringtruenoneA message explaining the status
causestringfalsenoneUsed to describe the origin of an error if that original error has meaning to the client. This field should add specificity to 'message'.
fieldsobjectfalsenoneUsed to identify specific fields in a JSON body that caused the error. Typically only used for 4xx type responses. The key should be the json path to the invalid property and the value should be a list of error messages specific to that property.
» additionalProperties[string]falsenonenone
contextstringfalsenoneUsed to identify what part of the request caused the error for non-JSON payloads.

HealthCheck

{
"status": 0,
"message": "string"
}

Properties

NameTypeRequiredRestrictionsDescription
statusintegertruenoneA valid http status code
messagestringtruenoneA message explaining the status

ValidationOutcome

{
"callId": "string",
"rawLlmOutput": "string",
"validatedOutput": "string",
"reask": {
"incorrectValue": true,
"failResults": [
{
"outcome": "pass",
"errorMessage": "string",
"fixValue": true,
"errorSpans": [
{
"start": 0,
"end": 0,
"reason": "string"
}
],
"metadata": {
"property1": null,
"property2": null
},
"validatedChunk": true
}
],
"property1": null,
"property2": null
},
"validationPassed": true,
"error": "string"
}

Properties

None

primitives

true

Properties

anyOf

NameTypeRequiredRestrictionsDescription
anonymousbooleanfalsenonenone

or

NameTypeRequiredRestrictionsDescription
anonymousintegerfalsenonenone

or

NameTypeRequiredRestrictionsDescription
anonymousnullfalsenonenone

or

NameTypeRequiredRestrictionsDescription
anonymousnumberfalsenonenone

or

NameTypeRequiredRestrictionsDescription
anonymousstringfalsenonenone

objects

{
"property1": null,
"property2": null
}

Properties

NameTypeRequiredRestrictionsDescription
additionalPropertiesanyfalsenonenone

arrays

[
true
]

Properties

anyOf

NameTypeRequiredRestrictionsDescription
anonymousprimitivesfalsenonenone

or

NameTypeRequiredRestrictionsDescription
anonymousobjectsfalsenonenone

any-type

true

AnyType

Properties

NameTypeRequiredRestrictionsDescription
AnyTypeanyfalsenonenone

anyOf

NameTypeRequiredRestrictionsDescription
anonymousprimitivesfalsenonenone

or

NameTypeRequiredRestrictionsDescription
anonymousobjectsfalsenonenone

or

NameTypeRequiredRestrictionsDescription
anonymousarraysfalsenonenone

validation-result

{
"outcome": "pass",
"metadata": {
"property1": null,
"property2": null
},
"validatedChunk": true
}

ValidationResult

Properties

NameTypeRequiredRestrictionsDescription
outcomestringtruenonenone
metadataobjectfalsenonenone
» additionalPropertiesanyfalsenonenone
validatedChunkany-typefalsenonenone

Enumerated Values

PropertyValue
outcomepass
outcomefail

error-span

{
"start": 0,
"end": 0,
"reason": "string"
}

ErrorSpan

Properties

NameTypeRequiredRestrictionsDescription
startintegertruenonenone
endintegertruenonenone
reasonstringtruenoneThe reason validation failed, specific to this chunk.

fail-result

{
"outcome": "pass",
"errorMessage": "string",
"fixValue": true,
"errorSpans": [
{
"start": 0,
"end": 0,
"reason": "string"
}
],
"metadata": {
"property1": null,
"property2": null
},
"validatedChunk": true
}

FailResult

Properties

NameTypeRequiredRestrictionsDescription
FailResultvalidation-resultfalsenoneThe output from a single Validator.
outcomeanytruenonenone
errorMessagestringtruenonenone
fixValueany-typefalsenonenone
errorSpans[error-span]falsenonenone

reask

{
"incorrectValue": true,
"failResults": [
{
"outcome": "pass",
"errorMessage": "string",
"fixValue": true,
"errorSpans": [
{
"start": 0,
"end": 0,
"reason": "string"
}
],
"metadata": {
"property1": null,
"property2": null
},
"validatedChunk": true
}
],
"property1": null,
"property2": null
}

ReAsk

Properties

NameTypeRequiredRestrictionsDescription
additionalPropertiesanyfalsenonenone
incorrectValueany-typefalsenonenone
failResults[fail-result]falsenonenone

validation-outcome

{
"callId": "string",
"rawLlmOutput": "string",
"validatedOutput": "string",
"reask": {
"incorrectValue": true,
"failResults": [
{
"outcome": "pass",
"errorMessage": "string",
"fixValue": true,
"errorSpans": [
{
"start": 0,
"end": 0,
"reason": "string"
}
],
"metadata": {
"property1": null,
"property2": null
},
"validatedChunk": true
}
],
"property1": null,
"property2": null
},
"validationPassed": true,
"error": "string"
}

ValidationOutcome

Properties

NameTypeRequiredRestrictionsDescription
callIdstringtruenoneForeign key to the most recent Call this resulted from.
rawLlmOutputstringfalsenoneThe raw, unchanged string content from the LLM call.
validatedOutputanyfalsenoneThe validated, and potentially fixed, output from the LLM call after undergoing validation.

anyOf

NameTypeRequiredRestrictionsDescription
» anonymousstringfalsenonenone

or

NameTypeRequiredRestrictionsDescription
» anonymousobjectfalsenonenone
»» additionalPropertiesanyfalsenonenone

or

NameTypeRequiredRestrictionsDescription
» anonymous[any-type]falsenonenone

continued

NameTypeRequiredRestrictionsDescription
reaskreaskfalsenoneIf validation continuously fails and all allocated reasks are used, this field will contain the final reask that would have been sent to the LLM if additional reasks were available.
validationPassedbooleanfalsenoneA boolean to indicate whether or not the LLM output passed validation. If this is False, the validated_output may be invalid.
errorstringfalsenoneIf the validation process raised a handleable exception, this field will contain the error message.

Guard

{
"id": "string",
"name": "string",
"description": "string",
"validators": [
{
"id": "string",
"on": "messages",
"onFail": "exception",
"args": [
true
],
"kwargs": {
"property1": null,
"property2": null
}
}
],
"output_schema": {
"definitions": {},
"dependencies": {
"property1": {},
"property2": {}
},
"$anchor": "string",
"$ref": "../dictionary",
"$dynamicRef": "../dictionary",
"$dynamicAnchor": "string",
"$vocabulary": {
"property1": true,
"property2": true
},
"$comment": "string",
"$defs": {},
"prefixItems": [
null
],
"items": null,
"contains": null,
"additionalProperties": null,
"properties": {},
"patternProperties": {},
"dependentSchemas": {
"property1": null,
"property2": null
},
"propertyNames": null,
"if": null,
"then": null,
"else": null,
"allOf": [
null
],
"anyOf": [
null
],
"oneOf": [
null
],
"not": null,
"unevaluatedItems": null,
"unevaluatedProperties": null,
"multipleOf": 0,
"maximum": 0,
"exclusiveMaximum": 0,
"minimum": 0,
"exclusiveMinimum": 0,
"maxLength": 0,
"minLength": 0,
"pattern": "/regex/",
"maxItems": 0,
"minItems": 0,
"uniqueItems": false,
"maxContains": 0,
"minContains": 0,
"maxProperties": 0,
"minProperties": 0,
"required": [],
"dependentRequired": {
"property1": [],
"property2": []
},
"const": null,
"enum": [
null
],
"type": "array",
"title": "string",
"description": "string",
"default": null,
"deprecated": false,
"readOnly": false,
"writeOnly": false,
"examples": [
null
],
"format": "string",
"contentMediaType": "string",
"contentEncoding": "string",
"contentSchema": null
},
"history": [
{
"id": "string",
"iterations": [],
"inputs": {
"llmApi": "string",
"llmOutput": "string",
"messages": [
{
"property1": null,
"property2": null
}
],
"promptParams": {
"property1": null,
"property2": null
},
"numReasks": 0,
"metadata": {
"property1": null,
"property2": null
},
"fullSchemaReask": true,
"stream": true,
"args": [
true
],
"kwargs": {
"property1": null,
"property2": null
}
},
"exception": "string"
}
]
}

Properties

None

schemaArray

[
null
]

Properties

None

nonNegativeInteger

0

Properties

NameTypeRequiredRestrictionsDescription
anonymousintegerfalsenonenone

nonNegativeIntegerDefault0

0

Properties

None

simpleTypes

"array"

Properties

None

stringArray

[]

Properties

None

LLMResponse

{
"promptTokenCount": 0,
"responseTokenCount": 0,
"output": "string",
"streamOutput": [
"string"
],
"asyncStreamOutput": [
"string"
]
}

Information from the LLM response.

Properties

NameTypeRequiredRestrictionsDescription
promptTokenCountintegerfalsenonenone
responseTokenCountintegerfalsenonenone
outputstringtruenonenone
streamOutput[string]falsenonenone
asyncStreamOutput[string]falsenonenone

CallInputs

{
"llmApi": "string",
"llmOutput": "string",
"messages": [
{
"property1": null,
"property2": null
}
],
"promptParams": {
"property1": null,
"property2": null
},
"numReasks": 0,
"metadata": {
"property1": null,
"property2": null
},
"fullSchemaReask": true,
"stream": true,
"args": [
true
],
"kwargs": {
"property1": null,
"property2": null
}
}

CallInputs

Properties

allOf

NameTypeRequiredRestrictionsDescription
anonymousinputsfalsenonenone

and

NameTypeRequiredRestrictionsDescription
anonymousargs-and-kwargsfalsenonenone

ValidatorReference

{
"id": "string",
"on": "messages",
"onFail": "exception",
"args": [
true
],
"kwargs": {
"property1": null,
"property2": null
}
}

ValidatorReference

Properties

NameTypeRequiredRestrictionsDescription
ValidatorReferenceargs-and-kwargsfalsenonenone
idstringtruenoneThe unique identifier for this Validator. Often the hub id; e.g. guardrails/regex_match
onanyfalsenoneA reference to the property this validator should be applied against. Can be a valid JSON path or a meta-property such as "prompt" or "output"

anyOf

NameTypeRequiredRestrictionsDescription
» anonymousstringfalsenonemeta-property

or

NameTypeRequiredRestrictionsDescription
» anonymousstringfalsenoneJSON path to property; e.g. $.foo.bar

continued

NameTypeRequiredRestrictionsDescription
onFailstringfalsenonenone

Enumerated Values

PropertyValue
anonymousprompt
anonymousmessages
anonymousoutput
onFailexception
onFailfilter
onFailfix
onFailfix_reask
onFailnoop
onFailreask
onFailrefrain
onFailcustom

args-and-kwargs

{
"args": [
true
],
"kwargs": {
"property1": null,
"property2": null
}
}

ArgsAndKwargs

Properties

NameTypeRequiredRestrictionsDescription
args[any-type]falsenonenone
kwargsobjectfalsenonenone
» additionalPropertiesanyfalsenonenone

core

{
"$anchor": "string",
"$ref": "../dictionary",
"$dynamicRef": "../dictionary",
"$dynamicAnchor": "string",
"$vocabulary": {
"property1": true,
"property2": true
},
"$comment": "string",
"$defs": {}
}

Core vocabulary meta-schema

Properties

NameTypeRequiredRestrictionsDescription
Core vocabulary meta-schemaobject,booleanfalsenonenone
$anchorstringfalsenonenone
$refstring(uri-reference)falsenonenone
$dynamicRefstring(uri-reference)falsenonenone
$dynamicAnchorstringfalsenonenone
$vocabularyobjectfalsenonenone
» additionalPropertiesbooleanfalsenonenone
$commentstringfalsenonenone
$defsobjectfalsenonenone
» additionalPropertiesanyfalsenonenone

applicator

{
"prefixItems": [
null
],
"items": null,
"contains": null,
"additionalProperties": null,
"properties": {},
"patternProperties": {},
"dependentSchemas": {
"property1": null,
"property2": null
},
"propertyNames": null,
"if": null,
"then": null,
"else": null,
"allOf": [
null
],
"anyOf": [
null
],
"oneOf": [
null
],
"not": null
}

Applicator vocabulary meta-schema

Properties

NameTypeRequiredRestrictionsDescription
Applicator vocabulary meta-schemaobject,booleanfalsenonenone
prefixItemsschemaArrayfalsenonenone
itemsanyfalsenonenone
containsanyfalsenonenone
additionalPropertiesanyfalsenonenone
propertiesobjectfalsenonenone
» additionalPropertiesanyfalsenonenone
patternPropertiesobjectfalsenonenone
» additionalPropertiesanyfalsenonenone
dependentSchemasobjectfalsenonenone
» additionalPropertiesanyfalsenonenone
propertyNamesanyfalsenonenone
ifanyfalsenonenone
thenanyfalsenonenone
elseanyfalsenonenone
allOfschemaArrayfalsenonenone
anyOfschemaArrayfalsenonenone
oneOfschemaArrayfalsenonenone
notanyfalsenonenone

unevaluated

{
"unevaluatedItems": null,
"unevaluatedProperties": null
}

Unevaluated applicator vocabulary meta-schema

Properties

NameTypeRequiredRestrictionsDescription
Unevaluated applicator vocabulary meta-schemaobject,booleanfalsenonenone
unevaluatedItemsanyfalsenonenone
unevaluatedPropertiesanyfalsenonenone

validation

{
"multipleOf": 0,
"maximum": 0,
"exclusiveMaximum": 0,
"minimum": 0,
"exclusiveMinimum": 0,
"maxLength": 0,
"minLength": 0,
"pattern": "/regex/",
"maxItems": 0,
"minItems": 0,
"uniqueItems": false,
"maxContains": 0,
"minContains": 0,
"maxProperties": 0,
"minProperties": 0,
"required": [],
"dependentRequired": {
"property1": [],
"property2": []
},
"const": null,
"enum": [
null
],
"type": "array"
}

Validation vocabulary meta-schema

Properties

NameTypeRequiredRestrictionsDescription
Validation vocabulary meta-schemaobject,booleanfalsenonenone
multipleOfnumberfalsenonenone
maximumnumberfalsenonenone
exclusiveMaximumnumberfalsenonenone
minimumnumberfalsenonenone
exclusiveMinimumnumberfalsenonenone
maxLengthnonNegativeIntegerfalsenonenone
minLengthnonNegativeIntegerDefault0falsenonenone
patternstring(regex)falsenonenone
maxItemsnonNegativeIntegerfalsenonenone
minItemsnonNegativeIntegerDefault0falsenonenone
uniqueItemsbooleanfalsenonenone
maxContainsnonNegativeIntegerfalsenonenone
minContainsnonNegativeIntegerfalsenonenone
maxPropertiesnonNegativeIntegerfalsenonenone
minPropertiesnonNegativeIntegerDefault0falsenonenone
requiredstringArrayfalsenonenone
dependentRequiredobjectfalsenonenone
» additionalPropertiesstringArrayfalsenonenone
constanyfalsenonenone
enum[any]falsenonenone
typeanyfalsenonenone

anyOf

NameTypeRequiredRestrictionsDescription
» anonymoussimpleTypesfalsenonenone

or

NameTypeRequiredRestrictionsDescription
» anonymous[simpleTypes]falsenonenone

meta-data

{
"title": "string",
"description": "string",
"default": null,
"deprecated": false,
"readOnly": false,
"writeOnly": false,
"examples": [
null
]
}

Meta-data vocabulary meta-schema

Properties

NameTypeRequiredRestrictionsDescription
Meta-data vocabulary meta-schemaobject,booleanfalsenonenone
titlestringfalsenonenone
descriptionstringfalsenonenone
defaultanyfalsenonenone
deprecatedbooleanfalsenonenone
readOnlybooleanfalsenonenone
writeOnlybooleanfalsenonenone
examples[any]falsenonenone

format-annotation

{
"format": "string"
}

Format vocabulary meta-schema for annotation results

Properties

NameTypeRequiredRestrictionsDescription
Format vocabulary meta-schema for annotation resultsobject,booleanfalsenonenone
formatstringfalsenonenone

content

{
"contentMediaType": "string",
"contentEncoding": "string",
"contentSchema": null
}

Content vocabulary meta-schema

Properties

NameTypeRequiredRestrictionsDescription
Content vocabulary meta-schemaobject,booleanfalsenonenone
contentMediaTypestringfalsenonenone
contentEncodingstringfalsenonenone
contentSchemaanyfalsenonenone

schema

{
"definitions": {},
"dependencies": {
"property1": {},
"property2": {}
},
"$anchor": "string",
"$ref": "../dictionary",
"$dynamicRef": "../dictionary",
"$dynamicAnchor": "string",
"$vocabulary": {
"property1": true,
"property2": true
},
"$comment": "string",
"$defs": {},
"prefixItems": [
null
],
"items": null,
"contains": null,
"additionalProperties": null,
"properties": {},
"patternProperties": {},
"dependentSchemas": {
"property1": null,
"property2": null
},
"propertyNames": null,
"if": null,
"then": null,
"else": null,
"allOf": [
null
],
"anyOf": [
null
],
"oneOf": [
null
],
"not": null,
"unevaluatedItems": null,
"unevaluatedProperties": null,
"multipleOf": 0,
"maximum": 0,
"exclusiveMaximum": 0,
"minimum": 0,
"exclusiveMinimum": 0,
"maxLength": 0,
"minLength": 0,
"pattern": "/regex/",
"maxItems": 0,
"minItems": 0,
"uniqueItems": false,
"maxContains": 0,
"minContains": 0,
"maxProperties": 0,
"minProperties": 0,
"required": [],
"dependentRequired": {
"property1": [],
"property2": []
},
"const": null,
"enum": [
null
],
"type": "array",
"title": "string",
"description": "string",
"default": null,
"deprecated": false,
"readOnly": false,
"writeOnly": false,
"examples": [
null
],
"format": "string",
"contentMediaType": "string",
"contentEncoding": "string",
"contentSchema": null
}

Core and Validation specifications meta-schema

Properties

NameTypeRequiredRestrictionsDescription
Core and Validation specifications meta-schemaobject,booleanfalsenonenone
definitionsobjectfalsenonenone
» additionalPropertiesanyfalsenonenone
dependenciesobjectfalsenonenone
» additionalPropertiesanyfalsenonenone

anyOf

NameTypeRequiredRestrictionsDescription
»» anonymousanyfalsenonenone

or

NameTypeRequiredRestrictionsDescription
»» anonymousvalidation/definitions/stringArrayfalsenonenone

allOf

NameTypeRequiredRestrictionsDescription
anonymouscorefalsenonenone

and

NameTypeRequiredRestrictionsDescription
anonymousapplicatorfalsenonenone

and

NameTypeRequiredRestrictionsDescription
anonymousunevaluatedfalsenonenone

and

NameTypeRequiredRestrictionsDescription
anonymousvalidationfalsenonenone

and

NameTypeRequiredRestrictionsDescription
anonymousmeta-datafalsenonenone

and

NameTypeRequiredRestrictionsDescription
anonymousformat-annotationfalsenonenone

and

NameTypeRequiredRestrictionsDescription
anonymouscontentfalsenonenone

inputs

{
"llmApi": "string",
"llmOutput": "string",
"messages": [
{
"property1": null,
"property2": null
}
],
"promptParams": {
"property1": null,
"property2": null
},
"numReasks": 0,
"metadata": {
"property1": null,
"property2": null
},
"fullSchemaReask": true,
"stream": true
}

Inputs

Properties

NameTypeRequiredRestrictionsDescription
llmApistringfalsenoneThe LLM resource targeted by the user. e.g. openai.chat.completions.create
llmOutputstringfalsenoneThe string output from an external LLM call provided by the user via Guard.parse.
messages[object]falsenoneThe message history for chat models.
» additionalPropertiesanyfalsenonenone
promptParamsobjectfalsenoneParameters to be formatted into the prompt.
» additionalPropertiesanyfalsenonenone
numReasksintegerfalsenoneThe total number of times the LLM can be called to correct output excluding the initial call.
metadataobjectfalsenoneAdditional data to be used by Validators during execution time.
» additionalPropertiesanyfalsenonenone
fullSchemaReaskbooleanfalsenoneWhether to perform reasks for the entire schema rather than for individual fields.
streambooleanfalsenoneWhether to use streaming.

pass-result

{
"outcome": "pass",
"valueOverride": true,
"metadata": {
"property1": null,
"property2": null
},
"validatedChunk": true
}

PassResult

Properties

NameTypeRequiredRestrictionsDescription
PassResultvalidation-resultfalsenoneThe output from a single Validator.
outcomeanytruenonenone
valueOverrideany-typefalsenonenone

validator-log

{
"validatorName": "string",
"registeredName": "string",
"instanceId": "string",
"propertyPath": "string",
"valueBeforeValidation": true,
"valueAfterValidation": true,
"validationResult": {
"outcome": "pass",
"valueOverride": true,
"metadata": {
"property1": null,
"property2": null
},
"validatedChunk": true
},
"startTime": "2019-08-24T14:15:22Z",
"endTime": "2019-08-24T14:15:22Z"
}

ValidatorLog

Properties

NameTypeRequiredRestrictionsDescription
validatorNamestring(PascalCase)truenoneThe class name of the validator.
registeredNamestring(kebab-case)truenoneThe registry id of the validator.
instanceIdanyfalsenoneA unique identifier for the validator that produced this log within the session.

anyOf

NameTypeRequiredRestrictionsDescription
» anonymousstringfalsenonenone

or

NameTypeRequiredRestrictionsDescription
» anonymousintegerfalsenonenone

continued

NameTypeRequiredRestrictionsDescription
propertyPathstringtruenoneThe JSON path to the property which was validated that produced this log.
valueBeforeValidationany-typetruenonenone
valueAfterValidationany-typefalsenonenone
validationResultanyfalsenonenone

anyOf

NameTypeRequiredRestrictionsDescription
» anonymouspass-resultfalsenonenone

or

NameTypeRequiredRestrictionsDescription
» anonymousfail-resultfalsenonenone

continued

NameTypeRequiredRestrictionsDescription
startTimestring(date-time)falsenonenone
endTimestring(date-time)falsenonenone

outputs

{
"llmResponseInfo": {
"promptTokenCount": 0,
"responseTokenCount": 0,
"output": "string",
"streamOutput": [
"string"
],
"asyncStreamOutput": [
"string"
]
},
"rawOutput": "string",
"parsedOutput": "string",
"validationResponse": "string",
"guardedOutput": "string",
"reasks": [
{
"incorrectValue": true,
"failResults": [
{
"outcome": "pass",
"errorMessage": "string",
"fixValue": true,
"errorSpans": [
{
"start": 0,
"end": 0,
"reason": "string"
}
],
"metadata": {
"property1": null,
"property2": null
},
"validatedChunk": true
}
],
"property1": null,
"property2": null
}
],
"validatorLogs": [
{
"validatorName": "string",
"registeredName": "string",
"instanceId": "string",
"propertyPath": "string",
"valueBeforeValidation": true,
"valueAfterValidation": true,
"validationResult": {
"outcome": "pass",
"valueOverride": true,
"metadata": {
"property1": null,
"property2": null
},
"validatedChunk": true
},
"startTime": "2019-08-24T14:15:22Z",
"endTime": "2019-08-24T14:15:22Z"
}
],
"error": "string"
}

Outputs

Properties

NameTypeRequiredRestrictionsDescription
llmResponseInfoLLMResponsefalsenoneInformation from the LLM response.
rawOutputstringfalsenoneThe string content from the LLM response.
parsedOutputanyfalsenonenone

anyOf

NameTypeRequiredRestrictionsDescription
» anonymousstringfalsenonenone

or

NameTypeRequiredRestrictionsDescription
» anonymousobjectfalsenonenone
»» additionalPropertiesanyfalsenonenone

or

NameTypeRequiredRestrictionsDescription
» anonymous[any-type]falsenonenone

continued

NameTypeRequiredRestrictionsDescription
validationResponseanyfalsenonenone

anyOf

NameTypeRequiredRestrictionsDescription
» anonymousstringfalsenonenone

or

NameTypeRequiredRestrictionsDescription
» anonymousreaskfalsenonenone

or

NameTypeRequiredRestrictionsDescription
» anonymousobjectfalsenonenone
»» additionalPropertiesanyfalsenonenone

or

NameTypeRequiredRestrictionsDescription
» anonymous[any-type]falsenonenone

continued

NameTypeRequiredRestrictionsDescription
guardedOutputanyfalsenonenone

anyOf

NameTypeRequiredRestrictionsDescription
» anonymousstringfalsenonenone

or

NameTypeRequiredRestrictionsDescription
» anonymousobjectfalsenonenone
»» additionalPropertiesanyfalsenonenone

or

NameTypeRequiredRestrictionsDescription
» anonymous[any-type]falsenonenone

continued

NameTypeRequiredRestrictionsDescription
reasks[reask]falsenonenone
validatorLogs[validator-log]falsenonenone
errorstringfalsenoneThe error message from any exception which interrupted the Guard execution process.

iteration

{
"id": "string",
"index": 0,
"callId": "string",
"inputs": {
"llmApi": "string",
"llmOutput": "string",
"messages": [
{
"property1": null,
"property2": null
}
],
"promptParams": {
"property1": null,
"property2": null
},
"numReasks": 0,
"metadata": {
"property1": null,
"property2": null
},
"fullSchemaReask": true,
"stream": true
},
"outputs": {
"llmResponseInfo": {
"promptTokenCount": 0,
"responseTokenCount": 0,
"output": "string",
"streamOutput": [
"string"
],
"asyncStreamOutput": [
"string"
]
},
"rawOutput": "string",
"parsedOutput": "string",
"validationResponse": "string",
"guardedOutput": "string",
"reasks": [
{
"incorrectValue": true,
"failResults": [
{
"outcome": "pass",
"errorMessage": "string",
"fixValue": true,
"errorSpans": [
{
"start": 0,
"end": 0,
"reason": "string"
}
],
"metadata": {
"property1": null,
"property2": null
},
"validatedChunk": true
}
],
"property1": null,
"property2": null
}
],
"validatorLogs": [
{
"validatorName": "string",
"registeredName": "string",
"instanceId": "string",
"propertyPath": "string",
"valueBeforeValidation": true,
"valueAfterValidation": true,
"validationResult": {
"outcome": "pass",
"valueOverride": true,
"metadata": {
"property1": null,
"property2": null
},
"validatedChunk": true
},
"startTime": "2019-08-24T14:15:22Z",
"endTime": "2019-08-24T14:15:22Z"
}
],
"error": "string"
}
}

Iteration

Properties

NameTypeRequiredRestrictionsDescription
idstringtruenoneThe unique identifier for this Call. Can be used as an identifier for a specific execution of a Guard.
indexintegertruenoneThe zero-based index of this iteration within the current Call.
callIdstringtruenoneThe unique identifier for the Call that this iteration is a part of.
inputsinputsfalsenonenone
outputsoutputsfalsenonenone

call

{
"id": "string",
"iterations": [],
"inputs": {
"llmApi": "string",
"llmOutput": "string",
"messages": [
{
"property1": null,
"property2": null
}
],
"promptParams": {
"property1": null,
"property2": null
},
"numReasks": 0,
"metadata": {
"property1": null,
"property2": null
},
"fullSchemaReask": true,
"stream": true,
"args": [
true
],
"kwargs": {
"property1": null,
"property2": null
}
},
"exception": "string"
}

Call

Properties

NameTypeRequiredRestrictionsDescription
idstringtruenoneThe unique identifier for this Call. Can be used as an identifier for a specific execution of a Guard.
iterations[iteration]falsenonenone
inputsCallInputsfalsenonenone
exceptionstringfalsenonenone

guard

{
"id": "string",
"name": "string",
"description": "string",
"validators": [
{
"id": "string",
"on": "messages",
"onFail": "exception",
"args": [
true
],
"kwargs": {
"property1": null,
"property2": null
}
}
],
"output_schema": {
"definitions": {},
"dependencies": {
"property1": {},
"property2": {}
},
"$anchor": "string",
"$ref": "../dictionary",
"$dynamicRef": "../dictionary",
"$dynamicAnchor": "string",
"$vocabulary": {
"property1": true,
"property2": true
},
"$comment": "string",
"$defs": {},
"prefixItems": [
null
],
"items": null,
"contains": null,
"additionalProperties": null,
"properties": {},
"patternProperties": {},
"dependentSchemas": {
"property1": null,
"property2": null
},
"propertyNames": null,
"if": null,
"then": null,
"else": null,
"allOf": [
null
],
"anyOf": [
null
],
"oneOf": [
null
],
"not": null,
"unevaluatedItems": null,
"unevaluatedProperties": null,
"multipleOf": 0,
"maximum": 0,
"exclusiveMaximum": 0,
"minimum": 0,
"exclusiveMinimum": 0,
"maxLength": 0,
"minLength": 0,
"pattern": "/regex/",
"maxItems": 0,
"minItems": 0,
"uniqueItems": false,
"maxContains": 0,
"minContains": 0,
"maxProperties": 0,
"minProperties": 0,
"required": [],
"dependentRequired": {
"property1": [],
"property2": []
},
"const": null,
"enum": [
null
],
"type": "array",
"title": "string",
"description": "string",
"default": null,
"deprecated": false,
"readOnly": false,
"writeOnly": false,
"examples": [
null
],
"format": "string",
"contentMediaType": "string",
"contentEncoding": "string",
"contentSchema": null
},
"history": [
{
"id": "string",
"iterations": [],
"inputs": {
"llmApi": "string",
"llmOutput": "string",
"messages": [
{
"property1": null,
"property2": null
}
],
"promptParams": {
"property1": null,
"property2": null
},
"numReasks": 0,
"metadata": {
"property1": null,
"property2": null
},
"fullSchemaReask": true,
"stream": true,
"args": [
true
],
"kwargs": {
"property1": null,
"property2": null
}
},
"exception": "string"
}
]
}

Guard

Properties

NameTypeRequiredRestrictionsDescription
idstring(kebab-case)truenoneThe unique identifier for the Guard.
namestringtruenoneThe name for the Guard.
descriptionstringfalsenoneA description that concisely states the expected behaviour or purpose of the Guard.
validators[ValidatorReference]falsenonenone
output_schemaschemafalsenonenone
history[call]falseread-onlynone

ValidatePayload

{
"llmOutput": "stubbed llm output",
"numReasks": 0,
"promptParams": {
"property1": null,
"property2": null
},
"llmApi": "openai.Completion.create",
"property1": null,
"property2": null
}

Properties

NameTypeRequiredRestrictionsDescription
additionalPropertiesanyfalsenonenone
llmOutputstringfalsenoneThe LLM output as a string or the input prompts for the LLM
numReasksintegerfalsenoneAn override for the number of re-asks to perform
promptParamsobjectfalsenoneadditional params for llm prompts
» additionalPropertiesanyfalsenonenone
llmApiLLMResourcefalsenonenone

LLMResource

"openai.Completion.create"

Properties

NameTypeRequiredRestrictionsDescription
anonymousstringfalsenonenone

Enumerated Values

PropertyValue
anonymousopenai.Completion.create
anonymousopenai.completions.create
anonymousopenai.ChatCompletion.create
anonymousopenai.chat.completions.create
anonymousopenai.Completion.acreate
anonymousopenai.ChatCompletion.acreate
anonymouslitellm.completion
anonymouslitellm.acompletion