Guardrails Server REST API
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
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | Returns the status of the server | HealthCheck |
default | Default | Unexpected error | HttpError |
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": "prompt",
"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",
"instructions": "string",
"prompt": "string",
"msgHistory": [
{
"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
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | A list of Guards. | Inline |
default | Default | Unexpected error | HttpError |
Response Schema
Status Code 200
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
anonymous | [guard] | false | none | none |
» Guard | guard | false | none | none |
»» id | string(kebab-case) | true | none | The unique identifier for the Guard. |
»» name | string | true | none | The name for the Guard. |
»» description | string | false | none | A description that concisely states the expected behaviour or purpose of the Guard. |
»» validators | [allOf] | false | none | none |
»»» ValidatorReference | ValidatorReference | false | none | none |
»»»» id | string | true | none | The unique identifier for this Validator. Often the hub id; e.g. guardrails/regex_match |
»»»» on | any | false | none | A 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
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»» anonymous | string | false | none | meta-property |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»» anonymous | string | false | none | JSON path to property; e.g. $.foo.bar |
continued
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»» onFail | string | false | none | none |
»» output_schema | schema | false | none | none |
»»» definitions | object | false | none | none |
»»»» additionalProperties | any | false | none | none |
»»» dependencies | object | false | none | none |
»»»» additionalProperties | any | false | none | none |
anyOf
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»» anonymous | any | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»» anonymous | [string] | false | none | none |
allOf
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»» anonymous | core | false | none | none |
»»»» $anchor | string | false | none | none |
»»»» $ref | string(uri-reference) | false | none | none |
»»»» $dynamicRef | string(uri-reference) | false | none | none |
»»»» $dynamicAnchor | string | false | none | none |
»»»» $vocabulary | object | false | none | none |
»»»»» additionalProperties | boolean | false | none | none |
»»»» $comment | string | false | none | none |
»»»» $defs | object | false | none | none |
»»»»» additionalProperties | any | false | none | none |
and
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»» anonymous | applicator | false | none | none |
»»»» prefixItems | [any] | false | none | none |
»»»» items | any | false | none | none |
»»»» contains | any | false | none | none |
»»»» additionalProperties | any | false | none | none |
»»»» properties | object | false | none | none |
»»»»» additionalProperties | any | false | none | none |
»»»» patternProperties | object | false | none | none |
»»»»» additionalProperties | any | false | none | none |
»»»» dependentSchemas | object | false | none | none |
»»»»» additionalProperties | any | false | none | none |
»»»» propertyNames | any | false | none | none |
»»»» if | any | false | none | none |
»»»» then | any | false | none | none |
»»»» else | any | false | none | none |
»»»» allOf | [any] | false | none | none |
»»»» anyOf | [any] | false | none | none |
»»»» oneOf | [any] | false | none | none |
»»»» not | any | false | none | none |
and
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»» anonymous | unevaluated | false | none | none |
»»»» unevaluatedItems | any | false | none | none |
»»»» unevaluatedProperties | any | false | none | none |
and
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»» anonymous | validation | false | none | none |
»»»» multipleOf | number | false | none | none |
»»»» maximum | number | false | none | none |
»»»» exclusiveMaximum | number | false | none | none |
»»»» minimum | number | false | none | none |
»»»» exclusiveMinimum | number | false | none | none |
»»»» maxLength | nonNegativeInteger | false | none | none |
»»»» minLength | nonNegativeInteger | false | none | none |
»»»» pattern | string(regex) | false | none | none |
»»»» maxItems | nonNegativeInteger | false | none | none |
»»»» minItems | nonNegativeInteger | false | none | none |
»»»» uniqueItems | boolean | false | none | none |
»»»» maxContains | nonNegativeInteger | false | none | none |
»»»» minContains | nonNegativeInteger | false | none | none |
»»»» maxProperties | nonNegativeInteger | false | none | none |
»»»» minProperties | nonNegativeInteger | false | none | none |
»»»» required | [string] | false | none | none |
»»»» dependentRequired | object | false | none | none |
»»»»» additionalProperties | [string] | false | none | none |
»»»» const | any | false | none | none |
»»»» enum | [any] | false | none | none |
»»»» type | any | false | none | none |
anyOf
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»» anonymous | any | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»» anonymous | [simpleTypes] | false | none | none |
and
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»» anonymous | meta-data | false | none | none |
»»»» title | string | false | none | none |
»»»» description | string | false | none | none |
»»»» default | any | false | none | none |
»»»» deprecated | boolean | false | none | none |
»»»» readOnly | boolean | false | none | none |
»»»» writeOnly | boolean | false | none | none |
»»»» examples | [any] | false | none | none |
and
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»» anonymous | format-annotation | false | none | none |
»»»» format | string | false | none | none |
and
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»» anonymous | content | false | none | none |
»»»» contentMediaType | string | false | none | none |
»»»» contentEncoding | string | false | none | none |
»»»» contentSchema | any | false | none | none |
continued
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»» history | [call] | false | read-only | none |
»»» Call | call | false | none | none |
»»»» id | string | true | none | The unique identifier for this Call. Can be used as an identifier for a specific execution of a Guard. |
»»»» iterations | [iteration] | false | none | none |
»»»»» Iteration | iteration | false | none | none |
»»»»»» id | string | true | none | The unique identifier for this Call. Can be used as an identifier for a specific execution of a Guard. |
»»»»»» index | integer | true | none | The zero-based index of this iteration within the current Call. |
»»»»»» callId | string | true | none | The unique identifier for the Call that this iteration is a part of. |
»»»»»» inputs | inputs | false | none | none |
»»»»»»» llmApi | string | false | none | The LLM resource targeted by the user. e.g. openai.chat.completions.create |
»»»»»»» llmOutput | string | false | none | The string output from an external LLM call provided by the user via Guard.parse. |
»»»»»»» instructions | string | false | none | The instructions for chat models. |
»»»»»»» prompt | string | false | none | The prompt for the LLM. |
»»»»»»» msgHistory | [object] | false | none | The message history for chat models. |
»»»»»»»» additionalProperties | any | false | none | none |
»»»»»»» promptParams | object | false | none | Parameters to be formatted into the prompt. |
»»»»»»»» additionalProperties | any | false | none | none |
»»»»»»» numReasks | integer | false | none | The total number of times the LLM can be called to correct output excluding the initial call. |
»»»»»»» metadata | object | false | none | Additional data to be used by Validators during execution time. |
»»»»»»»» additionalProperties | any | false | none | none |
»»»»»»» fullSchemaReask | boolean | false | none | Whether to perform reasks for the entire schema rather than for individual fields. |
»»»»»»» stream | boolean | false | none | Whether to use streaming. |
»»»»»» outputs | outputs | false | none | none |
»»»»»»» llmResponseInfo | LLMResponse | false | none | Information from the LLM response. |
»»»»»»»» promptTokenCount | integer | false | none | none |
»»»»»»»» responseTokenCount | integer | false | none | none |
»»»»»»»» output | string | true | none | none |
»»»»»»»» streamOutput | [string] | false | none | none |
»»»»»»»» asyncStreamOutput | [string] | false | none | none |
»»»»»»» rawOutput | string | false | none | The string content from the LLM response. |
»»»»»»» parsedOutput | any | false | none | none |
anyOf
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»» anonymous | string | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»» anonymous | object | false | none | none |
»»»»»»»»» additionalProperties | any | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»» anonymous | [anyOf] | false | none | none |
»»»»»»»»» AnyType | any | false | none | none |
anyOf
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»»»» anonymous | any | false | none | none |
anyOf
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»»»»» anonymous | boolean | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»»»»» anonymous | integer | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»»»»» anonymous | null | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»»»»» anonymous | number | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»»»»» anonymous | string | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»»»» anonymous | objects | false | none | none |
»»»»»»»»»»» additionalProperties | any | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»»»» anonymous | [anyOf] | false | none | none |
anyOf
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»»»»» anonymous | any | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»»»»» anonymous | objects | false | none | none |
continued
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»» validationResponse | any | false | none | none |
anyOf
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»» anonymous | string | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»» anonymous | reask | false | none | none |
»»»»»»»»» additionalProperties | any | false | none | none |
»»»»»»»»» incorrectValue | any | false | none | none |
»»»»»»»»» failResults | [allOf] | false | none | none |
»»»»»»»»»» FailResult | fail-result | false | none | The output from a single Validator. |
»»»»»»»»»»» outcome | any | true | none | none |
»»»»»»»»»»» errorMessage | string | true | none | none |
»»»»»»»»»»» fixValue | any | false | none | none |
»»»»»»»»»»» errorSpans | [error-span] | false | none | none |
»»»»»»»»»»»» ErrorSpan | error-span | false | none | none |
»»»»»»»»»»»»» start | integer | true | none | none |
»»»»»»»»»»»»» end | integer | true | none | none |
»»»»»»»»»»»»» reason | string | true | none | The reason validation failed, specific to this chunk. |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»» anonymous | object | false | none | none |
»»»»»»»»» additionalProperties | any | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»» anonymous | [anyOf] | false | none | none |
»»»»»»»»» AnyType | any | false | none | none |
continued
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»» guardedOutput | any | false | none | none |
anyOf
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»» anonymous | string | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»» anonymous | object | false | none | none |
»»»»»»»»» additionalProperties | any | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»» anonymous | [anyOf] | false | none | none |
»»»»»»»»» AnyType | any | false | none | none |
continued
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»» reasks | [reask] | false | none | none |
»»»»»»»» ReAsk | reask | false | none | none |
»»»»»»» validatorLogs | [validator-log] | false | none | none |
»»»»»»»» ValidatorLog | validator-log | false | none | none |
»»»»»»»»» validatorName | string(PascalCase) | true | none | The class name of the validator. |
»»»»»»»»» registeredName | string(kebab-case) | true | none | The registry id of the validator. |
»»»»»»»»» instanceId | any | false | none | A unique identifier for the validator that produced this log within the session. |
anyOf
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»»»» anonymous | string | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»»»» anonymous | integer | false | none | none |
continued
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»»» propertyPath | string | true | none | The JSON path to the property which was validated that produced this log. |
»»»»»»»»» valueBeforeValidation | any | true | none | none |
»»»»»»»»» valueAfterValidation | any | false | none | none |
»»»»»»»»» validationResult | any | false | none | none |
anyOf
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»»»» anonymous | pass-result | false | none | The output from a single Validator. |
»»»»»»»»»»» outcome | any | true | none | none |
»»»»»»» »»»» valueOverride | any | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»»»» anonymous | fail-result | false | none | The output from a single Validator. |
»»»»»»»»»»» outcome | any | true | none | none |
»»»»»»»»»»» errorMessage | string | true | none | none |
»»»»»»»»»»» fixValue | any | false | none | none |
»»»»»»»»»»» errorSpans | [error-span] | false | none | none |
continued
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»»» startTime | string(date-time) | false | none | none |
»»»»»»»»» endTime | string(date-time) | false | none | none |
»»»»»»» error | string | false | none | The error message from any exception which interrupted the Guard execution process. |
»»»» inputs | CallInputs | false | none | none |
allOf
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»» anonymous | inputs | false | none | none |
and
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»» anonymous | args-and-kwargs | false | none | none |
»»»»»» args | [anyOf] | false | none | none |
»»»»»»» AnyType | any | false | none | none |
»»»»»» kwargs | object | false | none | none |
»»»»»»» additionalProperties | any | false | none | none |
continued
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»» exception | string | false | none | none |
Enumerated Values
Property | Value |
---|---|
anonymous | prompt |
anonymous | instructions |
anonymous | msg_history |
anonymous | messages |
anonymous | output |
onFail | exception |
onFail | filter |
onFail | fix |
onFail | fix_reask |
onFail | noop |
onFail | reask |
onFail | refrain |
onFail | custom |
anonymous | array |
anonymous | boolean |
anonymous | integer |
anonymous | null |
anonymous | number |
anonymous | object |
anonymous | string |
createGuard
POST /guards
Creates a Guard
Body parameter
{
"id": "string",
"name": "string",
"description": "string",
"validators": [
{
"id": "string",
"on": "prompt",
"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
Name | In | Type | Required | Description |
---|---|---|---|---|
body | body | guard | true | none |
» id | body | string(kebab-case) | true | The unique identifier for the Guard. |
» name | body | string | true | The name for the Guard. |
» description | body | string | false | A description that concisely states the expected behaviour or purpose of the Guard. |
» validators | body | [allOf] | false | none |
»» ValidatorReference | body | ValidatorReference | false | none |
»»» id | body | string | true | The unique identifier for this Validator. Often the hub id; e.g. guardrails/regex_match |
»»» on | body | any | false | A 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" |
»»»» anonymous | body | string | false | meta-property |
»»»» anonymous | body | string | false | JSON path to property; e.g. $.foo.bar |
»»» onFail | body | string | false | none |
» output_schema | body | schema | false | none |
»» definitions | body | object | false | none |
»»» additionalProperties | body | any | false | none |
»» dependencies | body | object | false | none |
»»» additionalProperties | body | any | false | none |
»»»» anonymous | body | any | false | none |
»»»» anonymous | body | [string] | false | none |
»» anonymous | body | core | false | none |
»»» $anchor | body | string | false | none |
»»» $ref | body | string(uri-reference) | false | none |
»»» $dynamicRef | body | string(uri-reference) | false | none |
»»» $dynamicAnchor | body | string | false | none |
»»» $vocabulary | body | object | false | none |
»»»» additionalProperties | body | boolean | false | none |
»»» $comment | body | string | false | none |
»»» $defs | body | object | false | none |
»»»» additionalProperties | body | any | false | none |
»» anonymous | body | applicator | false | none |
»»» prefixItems | body | [any] | false | none |
»»» items | body | any | false | none |
»»» contains | body | any | false | none |
»»» additionalProperties | body | any | false | none |
»»» properties | body | object | false | none |
»»»» additionalProperties | body | any | false | none |
»»» patternProperties | body | object | false | none |
»»»» additionalProperties | body | any | false | none |
»»» dependentSchemas | body | object | false | none |
»»»» additionalProperties | body | any | false | none |
»»» propertyNames | body | any | false | none |
»»» if | body | any | false | none |
»»» then | body | any | false | none |
»»» else | body | any | false | none |
»»» allOf | body | [any] | false | none |
»»» anyOf | body | [any] | false | none |
»»» oneOf | body | [any] | false | none |
»»» not | body | any | false | none |
»» anonymous | body | unevaluated | false | none |
»»» unevaluatedItems | body | any | false | none |
»»» unevaluatedProperties | body | any | false | none |
»» anonymous | body | validation | false | none |
»»» multipleOf | body | number | false | none |
»»» maximum | body | number | false | none |
»»» exclusiveMaximum | body | number | false | none |
»»» minimum | body | number | false | none |
»»» exclusiveMinimum | body | number | false | none |
»»» maxLength | body | nonNegativeInteger | false | none |
»»» minLength | body | nonNegativeInteger | false | none |
»»» pattern | body | string(regex) | false | none |
»»» maxItems | body | nonNegativeInteger | false | none |
»»» minItems | body | nonNegativeInteger | false | none |
»»» uniqueItems | body | boolean | false | none |
»»» maxContains | body | nonNegativeInteger | false | none |
»»» minContains | body | nonNegativeInteger | false | none |
»»» maxProperties | body | nonNegativeInteger | false | none |
»»» minProperties | body | nonNegativeInteger | false | none |
»»» required | body | [string] | false | none |
»»» dependentRequired | body | object | false | none |
»»»» additionalProperties | body | [string] | false | none |
»»» const | body | any | false | none |
»»» enum | body | [any] | false | none |
»»» type | body | any | false | none |
»»»» anonymous | body | any | false | none |
»»»» anonymous | body | [simpleTypes] | false | none |
»» anonymous | body | meta-data | false | none |
»»» title | body | string | false | none |
»»» description | body | string | false | none |
»»» default | body | any | false | none |
»»» deprecated | body | boolean | false | none |
»»» readOnly | body | boolean | false | none |
»»» writeOnly | body | boolean | false | none |
»»» examples | body | [any] | false | none |
»» anonymous | body | format-annotation | false | none |
»»» format | body | string | false | none |
»» anonymous | body | content | false | none |
»»» contentMediaType | body | string | false | none |
»»» contentEncoding | body | string | false | none |
»»» contentSchema | body | any | false | none |
» history | body | [call] | false | none |
»» Call | body | call | false | none |
»»» id | body | string | true | The unique identifier for this Call. Can be used as an identifier for a specific execution of a Guard. |
»»» iterations | body | [iteration] | false | none |
»»»» Iteration | body | iteration | false | none |
»»»»» id | body | string | true | The unique identifier for this Call. Can be used as an identifier for a specific execution of a Guard. |
»»»»» index | body | integer | true | The zero-based index of this iteration within the current Call. |
»»»»» callId | body | string | true | The unique identifier for the Call that this iteration is a part of. |
»»»»» inputs | body | inputs | false | none |
»»»»»» llmApi | body | string | false | The LLM resource targeted by the user. e.g. openai.chat.completions.create |
»»»»»» llmOutput | body | string | false | The string output from an external LLM call provided by the user via Guard.parse. |
»»»»»» instructions | body | string | false | The instructions for chat models. |
»»»»»» prompt | body | string | false | The prompt for the LLM. |
»»»»»» msgHistory | body | [object] | false | The message history for chat models. |
»»»»»»» additionalProperties | body | any | false | none |
»»»»»» promptParams | body | object | false | Parameters to be formatted into the prompt. |
»»»»»»» additionalProperties | body | any | false | none |
»»»»»» numReasks | body | integer | false | The total number of times the LLM can be called to correct output excluding the initial call. |
»»»»»» metadata | body | object | false | Additional data to be used by Validators during execution time. |
»»»»»»» additionalProperties | body | any | false | none |
»»»»»» fullSchemaReask | body | boolean | false | Whether to perform reasks for the entire schema rather than for individual fields. |
»»»»»» stream | body | boolean | false | Whether to use streaming. |
»»»»» outputs | body | outputs | false | none |
»»»»»» llmResponseInfo | body | LLMResponse | false | Information from the LLM response. |
»»»»»»» promptTokenCount | body | integer | false | none |
»»»»»»» responseTokenCount | body | integer | false | none |
»»»»»»» output | body | string | true | none |
»»»»»»» streamOutput | body | [string] | false | none |
»»»»»»» asyncStreamOutput | body | [string] | false | none |
»»»»»» rawOutput | body | string | false | The string content from the LLM response. |
»»»»»» parsedOutput | body | any | false | none |
»»»»»»» anonymous | body | string | false | none |
»»»»»»» anonymous | body | object | false | none |
»»»»»»»» additionalProperties | body | any | false | none |
»»»»»»» anonymous | body | [anyOf] | false | none |
»»»»»»»» AnyType | body | any | false | none |
»»»»»»»»» anonymous | body | any | false | none |
»»»»»»»»»» anonymous | body | boolean | false | none |
»»»»»»»»»» anonymous | body | integer | false | none |
»»»»»»»»»» anonymous | body | null | false | none |
»»»»»»»»»» anonymous | body | number | false | none |
»»»»»»»»»» anonymous | body | string | false | none |
»»»»»»»»» anonymous | body | objects | false | none |
»»»»»»»»»» additionalProperties | body | any | false | none |
»»»»»»»»» anonymous | body | [anyOf] | false | none |
»»»»»»»»»» anonymous | body | any | false | none |
»»»»»»»»»» anonymous | body | objects | false | none |
»»»»»» validationResponse | body | any | false | none |
»»»»»»» anonymous | body | string | false | none |
»»»»»»» anonymous | body | reask | false | none |
»»»»»»»» additionalProperties | body | any | false | none |
»»»»»»»» incorrectValue | body | any | false | none |
»»»»»»»» failResults | body | [allOf] | false | none |
»»»»»»»»» FailResult | body | fail-result | false | The output from a single Validator. |
»»»»»»»»»» outcome | body | any | true | none |
»»»»»»»»»» errorMessage | body | string | true | none |
»»»»»»»»»» fixValue | body | any | false | none |
»»»»»»»»»» errorSpans | body | [error-span] | false | none |
»»»»»»»»»»» ErrorSpan | body | error-span | false | none |
»»»»»»»»»»»» start | body | integer | true | none |
»»»»»»»»»»»» end | body | integer | true | none |
»»»»»»»»»»»» reason | body | string | true | The reason validation failed, specific to this chunk. |
»»»»»»» anonymous | body | object | false | none |
»»»»»»»» additionalProperties | body | any | false | none |
»»»»»»» anonymous | body | [anyOf] | false | none |
»»»»»»»» AnyType | body | any | false | none |
»»»»»» guardedOutput | body | any | false | none |
»»»»»»» anonymous | body | string | false | none |
»»»»»»» anonymous | body | object | false | none |
»»»»»»»» additionalProperties | body | any | false | none |
»»»»»»» anonymous | body | [anyOf] | false | none |
»»»»»»»» AnyType | body | any | false | none |
»»»»»» reasks | body | [reask] | false | none |
»»»»»»» ReAsk | body | reask | false | none |
»»»»»» validatorLogs | body | [validator-log] | false | none |
»»»»»»» ValidatorLog | body | validator-log | false | none |
»»»»»»»» validatorName | body | string(PascalCase) | true | The class name of the validator. |
»»»»»»»» registeredName | body | string(kebab-case) | true | The registry id of the validator. |
»»»»»»»» instanceId | body | any | false | A unique identifier for the validator that produced this log within the session. |
»»»»»»»»» anonymous | body | string | false | none |
»»»»»»»»» anonymous | body | integer | false | none |
»»»»»»»» propertyPath | body | string | true | The JSON path to the property which was validated that produced this log. |
»»»»»»»» valueBeforeValidation | body | any | true | none |
»»»»»»»» valueAfterValidation | body | any | false | none |
»»»»»»»» validationResult | body | any | false | none |
»»»»»» »»» anonymous | body | pass-result | false | The output from a single Validator. |
»»»»»»»»»» outcome | body | any | true | none |
»»»»»»»»»» valueOverride | body | any | false | none |
»»»»»»»»» anonymous | body | fail-result | false | The output from a single Validator. |
»»»»»»»»»» outcome | body | any | true | none |
»»»»»»»»»» errorMessage | body | string | true | none |
»»»»»»»»»» fixValue | body | any | false | none |
»»»»»»»»»» errorSpans | body | [error-span] | false | none |
»»»»»»»» startTime | body | string(date-time) | false | none |
»»»»»»»» endTime | body | string(date-time) | false | none |
»»»»»» error | body | string | false | The error message from any exception which interrupted the Guard execution process. |
»»» inputs | body | CallInputs | false | none |
»»»» anonymous | body | inputs | false | none |
»»»» anonymous | body | args-and-kwargs | false | none |
»»»»» args | body | [anyOf] | false | none |
»»»»»» AnyType | body | any | false | none |
»»»»» kwargs | body | object | false | none |
»»»»»» additionalProperties | body | any | false | none |
»»» exception | body | string | false | none |
Enumerated Values
Parameter | Value |
---|---|
»»»» anonymous | prompt |
»»»» anonymous | instructions |
»»»» anonymous | msg_history |
»»»» anonymous | messages |
»»»» anonymous | output |
»»» onFail | exception |
»»» onFail | filter |
»»» onFail | fix |
»»» onFail | fix_reask |
»»» onFail | noop |
»»» onFail | reask |
»»» onFail | refrain |
»»» onFail | custom |
»»»» anonymous | array |
»»»» anonymous | boolean |
»»»» anonymous | integer |
»»»» anonymous | null |
»»»» anonymous | number |
»»»» anonymous | object |
»»»» anonymous | string |
»»»» anonymous | array |
»»»» anonymous | boolean |
»»»» anonymous | integer |
»»»» anonymous | null |
»»»» anonymous | number |
»»»» anonymous | object |
»»»» anonymous | string |
Example responses
200 Response
{
"id": "string",
"name": "string",
"description": "string",
"validators": [
{
"id": "string",
"on": "prompt",
"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",
"instructions": "string",
"prompt": "string",
"msgHistory": [
{
"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
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | the new Guard | guard |
default | Default | Unexpected error | HttpError |
getGuard
GET /guards/{guardName}
Fetches a specific Guard
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
guardName | path | string | true | Guard name |
asOf | query | string(date-time) | false | Used 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": "prompt",
"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",
"instructions": "string",
"prompt": "string",
"msgHistory": [
{
"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
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | the fetched Guard | guard |
default | Default | Unexpected error | HttpError |
updateGuard
PUT /guards/{guardName}
Updates a Guard
Body parameter
{
"id": "string",
"name": "string",
"description": "string",
"validators": [
{
"id": "string",
"on": "prompt",
"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
Name | In | Type | Required | Description |
---|---|---|---|---|
guardName | path | string | true | Guard name |
body | body | guard | true | none |
» id | body | string(kebab-case) | true | The unique identifier for the Guard. |
» name | body | string | true | The name for the Guard. |
» description | body | string | false | A description that concisely states the expected behaviour or purpose of the Guard. |
» validators | body | [allOf] | false | none |
»» ValidatorReference | body | ValidatorReference | false | none |
»»» id | body | string | true | The unique identifier for this Validator. Often the hub id; e.g. guardrails/regex_match |
»»» on | body | any | false | A 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" |
»»»» anonymous | body | string | false | meta-property |
»»»» anonymous | body | string | false | JSON path to property; e.g. $.foo.bar |
»»» onFail | body | string | false | none |
» output_schema | body | schema | false | none |
»» definitions | body | object | false | none |
»»» additionalProperties | body | any | false | none |
»» dependencies | body | object | false | none |
»»» additionalProperties | body | any | false | none |
»»»» anonymous | body | any | false | none |
»»»» anonymous | body | [string] | false | none |
»» anonymous | body | core | false | none |
»»» $anchor | body | string | false | none |
»»» $ref | body | string(uri-reference) | false | none |
»»» $dynamicRef | body | string(uri-reference) | false | none |
»»» $dynamicAnchor | body | string | false | none |
»»» $vocabulary | body | object | false | none |
»»»» additionalProperties | body | boolean | false | none |
»»» $comment | body | string | false | none |
»»» $defs | body | object | false | none |
»»»» additionalProperties | body | any | false | none |
»» anonymous | body | applicator | false | none |
»»» prefixItems | body | [any] | false | none |
»»» items | body | any | false | none |
»»» contains | body | any | false | none |
»»» additionalProperties | body | any | false | none |
»»» properties | body | object | false | none |
»»»» additionalProperties | body | any | false | none |
»»» patternProperties | body | object | false | none |
»»»» additionalProperties | body | any | false | none |
»»» dependentSchemas | body | object | false | none |
»»»» additionalProperties | body | any | false | none |
»»» propertyNames | body | any | false | none |
»»» if | body | any | false | none |
»»» then | body | any | false | none |
»»» else | body | any | false | none |
»»» allOf | body | [any] | false | none |
»»» anyOf | body | [any] | false | none |
»»» oneOf | body | [any] | false | none |
»»» not | body | any | false | none |
»» anonymous | body | unevaluated | false | none |
»»» unevaluatedItems | body | any | false | none |
»»» unevaluatedProperties | body | any | false | none |
»» anonymous | body | validation | false | none |
»»» multipleOf | body | number | false | none |
»»» maximum | body | number | false | none |
»»» exclusiveMaximum | body | number | false | none |
»»» minimum | body | number | false | none |
»»» exclusiveMinimum | body | number | false | none |
»»» maxLength | body | nonNegativeInteger | false | none |
»»» minLength | body | nonNegativeInteger | false | none |
»»» pattern | body | string(regex) | false | none |
»»» maxItems | body | nonNegativeInteger | false | none |
»»» minItems | body | nonNegativeInteger | false | none |
»»» uniqueItems | body | boolean | false | none |
»»» maxContains | body | nonNegativeInteger | false | none |
»»» minContains | body | nonNegativeInteger | false | none |
»»» maxProperties | body | nonNegativeInteger | false | none |
»»» minProperties | body | nonNegativeInteger | false | none |
»»» required | body | [string] | false | none |
»»» dependentRequired | body | object | false | none |
»»»» additionalProperties | body | [string] | false | none |
»»» const | body | any | false | none |
»»» enum | body | [any] | false | none |
»»» type | body | any | false | none |
»»»» anonymous | body | any | false | none |
»»»» anonymous | body | [simpleTypes] | false | none |
»» anonymous | body | meta-data | false | none |
»»» title | body | string | false | none |
»»» description | body | string | false | none |
»»» default | body | any | false | none |
»»» deprecated | body | boolean | false | none |
»»» readOnly | body | boolean | false | none |
»»» writeOnly | body | boolean | false | none |
»»» examples | body | [any] | false | none |
»» anonymous | body | format-annotation | false | none |
»»» format | body | string | false | none |
»» anonymous | body | content | false | none |
»»» contentMediaType | body | string | false | none |
»»» contentEncoding | body | string | false | none |
»»» contentSchema | body | any | false | none |
» history | body | [call] | false | none |
»» Call | body | call | false | none |
»»» id | body | string | true | The unique identifier for this Call. Can be used as an identifier for a specific execution of a Guard. |
»»» iterations | body | [iteration] | false | none |
»»»» Iteration | body | iteration | false | none |
»»»»» id | body | string | true | The unique identifier for this Call. Can be used as an identifier for a specific execution of a Guard. |
»»»»» index | body | integer | true | The zero-based index of this iteration within the current Call. |
»»»»» callId | body | string | true | The unique identifier for the Call that this iteration is a part of. |
»»»»» inputs | body | inputs | false | none |
»»»»»» llmApi | body | string | false | The LLM resource targeted by the user. e.g. openai.chat.completions.create |
»»»»»» llmOutput | body | string | false | The string output from an external LLM call provided by the user via Guard.parse. |
»»»»»» instructions | body | string | false | The instructions for chat models. |
»»»»»» prompt | body | string | false | The prompt for the LLM. |
»»»»»» msgHistory | body | [object] | false | The message history for chat models. |
»»»»»»» additionalProperties | body | any | false | none |
»»»»»» promptParams | body | object | false | Parameters to be formatted into the prompt. |
»»»»»»» additionalProperties | body | any | false | none |
»»»»»» numReasks | body | integer | false | The total number of times the LLM can be called to correct output excluding the initial call. |
»»»»»» metadata | body | object | false | Additional data to be used by Validators during execution time. |
»»»»»»» additionalProperties | body | any | false | none |
»»»»»» fullSchemaReask | body | boolean | false | Whether to perform reasks for the entire schema rather than for individual fields. |
»»»»»» stream | body | boolean | false | Whether to use streaming. |
»»»»» outputs | body | outputs | false | none |
»»»»»» llmResponseInfo | body | LLMResponse | false | Information from the LLM response. |
»»»»»»» promptTokenCount | body | integer | false | none |
»»»»»»» responseTokenCount | body | integer | false | none |
»»»»»»» output | body | string | true | none |
»»»»»»» streamOutput | body | [string] | false | none |
»»»»»»» asyncStreamOutput | body | [string] | false | none |
»»»»»» rawOutput | body | string | false | The string content from the LLM response. |
»»»» »» parsedOutput | body | any | false | none |
»»»»»»» anonymous | body | string | false | none |
»»»»»»» anonymous | body | object | false | none |
»»»»»»»» additionalProperties | body | any | false | none |
»»»»»»» anonymous | body | [anyOf] | false | none |
»»»»»»»» AnyType | body | any | false | none |
»»»»»»»»» anonymous | body | any | false | none |
»»»»»»»»»» anonymous | body | boolean | false | none |
»»»»»»»»»» anonymous | body | integer | false | none |
»»»»»»»»»» anonymous | body | null | false | none |
»»»»»»»»»» anonymous | body | number | false | none |
»»»»»»»»»» anonymous | body | string | false | none |
»»»»»»»»» anonymous | body | objects | false | none |
»»»»»»»»»» additionalProperties | body | any | false | none |
»»»»»»»»» anonymous | body | [anyOf] | false | none |
»»»»»»»»»» anonymous | body | any | false | none |
»»»»»»»»»» anonymous | body | objects | false | none |
»»»»»» validationResponse | body | any | false | none |
»»»»»»» anonymous | body | string | false | none |
»»»»»»» anonymous | body | reask | false | none |
»»»»»»»» additionalProperties | body | any | false | none |
»»»»»»»» incorrectValue | body | any | false | none |
»»»»»»»» failResults | body | [allOf] | false | none |
»»»»»»»»» FailResult | body | fail-result | false | The output from a single Validator. |
»»»»»»»»»» outcome | body | any | true | none |
»»»»»»»»»» errorMessage | body | string | true | none |
»»»»»»»»»» fixValue | body | any | false | none |
»»»»»»»»»» errorSpans | body | [error-span] | false | none |
»»»»»»»»»»» ErrorSpan | body | error-span | false | none |
»»»»»»»»»»»» start | body | integer | true | none |
»»»»»»»»»»»» end | body | integer | true | none |
»»»»»»»»»»»» reason | body | string | true | The reason validation failed, specific to this chunk. |
»»»»»»» anonymous | body | object | false | none |
»»»»»»»» additionalProperties | body | any | false | none |
»»»»»»» anonymous | body | [anyOf] | false | none |
»»»»»»»» AnyType | body | any | false | none |
»»»»»» guardedOutput | body | any | false | none |
»»»»»»» anonymous | body | string | false | none |
»»»»»»» anonymous | body | object | false | none |
»»»»»»»» additionalProperties | body | any | false | none |
»»»»»»» anonymous | body | [anyOf] | false | none |
»»»»»»»» AnyType | body | any | false | none |
»»»»»» reasks | body | [reask] | false | none |
»»»»»»» ReAsk | body | reask | false | none |
»»»»»» validatorLogs | body | [validator-log] | false | none |
»»»»»»» ValidatorLog | body | validator-log | false | none |
»»»»»»»» validatorName | body | string(PascalCase) | true | The class name of the validator. |
»»»»»»»» registeredName | body | string(kebab-case) | true | The registry id of the validator. |
»»»»»»»» instanceId | body | any | false | A unique identifier for the validator that produced this log within the session. |
»»»»»»»»» anonymous | body | string | false | none |
»»»»»»»»» anonymous | body | integer | false | none |
»»»»»»»» propertyPath | body | string | true | The JSON path to the property which was validated that produced this log. |
»»»»»»»» valueBeforeValidation | body | any | true | none |
»»»»»»»» valueAfterValidation | body | any | false | none |
»»»»»»»» validationResult | body | any | false | none |
»»»»»»»»» anonymous | body | pass-result | false | The output from a single Validator. |
»»»»»»»»»» outcome | body | any | true | none |
»»»»»»»»»» valueOverride | body | any | false | none |
»»»»»»»»» anonymous | body | fail-result | false | The output from a single Validator. |
»»»»»»»»»» outcome | body | any | true | none |
»»»»»»»»»» errorMessage | body | string | true | none |
»»»»»»»»»» fixValue | body | any | false | none |
»»»»»»»»»» errorSpans | body | [error-span] | false | none |
»»»»»»»» startTime | body | string(date-time) | false | none |
»»»»»»»» endTime | body | string(date-time) | false | none |
»»»»»» error | body | string | false | The error message from any exception which interrupted the Guard execution process. |
»»» inputs | body | CallInputs | false | none |
»»»» anonymous | body | inputs | false | none |
»»»» anonymous | body | args-and-kwargs | false | none |
»»»»» args | body | [anyOf] | false | none |
»»»»»» AnyType | body | any | false | none |
»»»»» kwargs | body | object | false | none |
»»»»»» additionalProperties | body | any | false | none |
»»» exception | body | string | false | none |
Enumerated Values
Parameter | Value |
---|---|
»»»» anonymous | prompt |
»»»» anonymous | instructions |
»»»» anonymous | msg_history |
»»»» anonymous | messages |
»»»» anonymous | output |
»»» onFail | exception |
»»» onFail | filter |
»»» onFail | fix |
»»» onFail | fix_reask |
»»» onFail | noop |
»»» onFail | reask |
»»» onFail | refrain |
»»» onFail | custom |
»»»» anonymous | array |
»»»» anonymous | boolean |
»»»» anonymous | integer |
»»»» anonymous | null |
»»»» anonymous | number |
»»»» anonymous | object |
»»»» anonymous | string |
»»»» anonymous | array |
»»»» anonymous | boolean |
»»»» anonymous | integer |
»»»» anonymous | null |
»»»» anonymous | number |
»»»» anonymous | object |
»»»» anonymous | string |
Example responses
200 Response
{
"id": "string",
"name": "string",
"description": "string",
"validators": [
{
"id": "string",
"on": "prompt",
"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",
"instructions": "string",
"prompt": "string",
"msgHistory": [
{
"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
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | the updated Guard | guard |
default | Default | Unexpected error | HttpError |
deleteGuard
DELETE /guards/{guardName}
Deletes a Guard
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
guardName | path | string | true | Guard name |
Example responses
200 Response
{
"id": "string",
"name": "string",
"description": "string",
"validators": [
{
"id": "string",
"on": "prompt",
"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",
"instructions": "string",
"prompt": "string",
"msgHistory": [
{
"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
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | the deleted Guard | guard |
default | Default | Unexpected error | HttpError |
getGuardHistory
GET /guards/{guardName}/history/{callId}
Fetches the history for a specific Guard execution by using the id for the most recent Call
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
guardName | path | string | true | Guard name |
callId | path | string | true | Call id |
Example responses
200 Response
[
{
"id": "string",
"iterations": [],
"inputs": {
"llmApi": "string",
"llmOutput": "string",
"instructions": "string",
"prompt": "string",
"msgHistory": [
{
"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
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | the fetched Guard History | Inline |
default | Default | Unexpected error | HttpError |
Response Schema
Status Code 200
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
anonymous | [call] | false | none | none |
» Call | call | false | none | none |
»» id | string | true | none | The unique identifier for this Call. Can be used as an identifier for a specific execution of a Guard. |
»» iterations | [iteration] | false | none | none |
»»» Iteration | iteration | false | none | none |
»»»» id | string | true | none | The unique identifier for this Call. Can be used as an identifier for a specific execution of a Guard. |
»»»» index | integer | true | none | The zero-based index of this iteration within the current Call. |
»»»» callId | string | true | none | The unique identifier for the Call that this iteration is a part of. |
»»»» inputs | inputs | false | none | none |
»»»»» llmApi | string | false | none | The LLM resource targeted by the user. e.g. openai.chat.completions.create |
»»»»» llmOutput | string | false | none | The string output from an external LLM call provided by the user via Guard.parse. |
»»»»» instructions | string | false | none | The instructions for chat models. |
»»»»» prompt | string | false | none | The prompt for the LLM. |
»»»»» msgHistory | [object] | false | none | The message history for chat models. |
»»»»»» additionalProperties | any | false | none | none |
»»»»» promptParams | object | false | none | Parameters to be formatted into the prompt. |
»»»»»» additionalProperties | any | false | none | none |
»»»»» numReasks | integer | false | none | The total number of times the LLM can be called to correct output excluding the initial call. |
»»»»» metadata | object | false | none | Additional data to be used by Validators during execution time. |
»»»»»» additionalProperties | any | false | none | none |
»»»»» fullSchemaReask | boolean | false | none | Whether to perform reasks for the entire schema rather than for individual fields. |
»»»»» stream | boolean | false | none | Whether to use streaming. |
»»»» outputs | outputs | false | none | none |
»»»»» llmResponseInfo | LLMResponse | false | none | Information from the LLM response. |
»»»»»» promptTokenCount | integer | false | none | none |
»»»»»» responseTokenCount | integer | false | none | none |
»»»»»» output | string | true | none | none |
»»»»»» streamOutput | [string] | false | none | none |
»»»»»» asyncStreamOutput | [string] | false | none | none |
»»»»» rawOutput | string | false | none | The string content from the LLM response. |
»»»»» parsedOutput | any | false | none | none |
anyOf
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»» anonymous | string | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»» anonymous | object | false | none | none |
»»»»»»» additionalProperties | any | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»» anonymous | [anyOf] | false | none | none |
»»»»»»» AnyType | any | false | none | none |
anyOf
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»» anonymous | any | false | none | none |
anyOf
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»»» anonymous | boolean | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»»» anonymous | integer | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»»» anonymous | null | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»»» anonymous | number | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»»» anonymous | string | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»» anonymous | objects | false | none | none |
»»»»»»»»» additionalProperties | any | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»» anonymous | [anyOf] | false | none | none |
anyOf
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»»» anonymous | any | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»»» anonymous | objects | false | none | none |
continued
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»» validationResponse | any | false | none | none |
anyOf
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»» anonymous | string | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»» anonymous | reask | false | none | none |
»»»»»»» additionalProperties | any | false | none | none |
»»»»»»» incorrectValue | any | false | none | none |
»»»»»»» failResults | [allOf] | false | none | none |
»»»»»»»» FailResult | fail-result | false | none | The output from a single Validator. |
»»»»»»»»» outcome | any | true | none | none |
»»»»»»»»» errorMessage | string | true | none | none |
»»»»»»»»» fixValue | any | false | none | none |
»»»»»»»»» errorSpans | [error-span] | false | none | none |
»»»»»»»»»» ErrorSpan | error-span | false | none | none |
»»»»»»»»»»» start | integer | true | none | none |
»»»»»»»»»»» end | integer | true | none | none |
»»»»»»»»»»» reason | string | true | none | The reason validation failed, specific to this chunk. |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»» anonymous | object | false | none | none |
»»»»»»» additionalProperties | any | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»» anonymous | [anyOf] | false | none | none |
»»»»»»» AnyType | any | false | none | none |
continued
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»» guardedOutput | any | false | none | none |
anyOf
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»» anonymous | string | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»» anonymous | object | false | none | none |
»»»»»»» additionalProperties | any | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»» anonymous | [anyOf] | false | none | none |
»»»»»»» AnyType | any | false | none | none |
continued
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»» reasks | [reask] | false | none | none |
»»»»»» ReAsk | reask | false | none | none |
»»»»» validatorLogs | [validator-log] | false | none | none |
»»»»»» ValidatorLog | validator-log | false | none | none |
»»»»»»» validatorName | string(PascalCase) | true | none | The class name of the validator. |
»»»»»»» registeredName | string(kebab-case) | true | none | The registry id of the validator. |
»»»»»»» instanceId | any | false | none | A unique identifier for the validator that produced this log within the session. |
anyOf
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»» anonymous | string | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»» anonymous | integer | false | none | none |
continued
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»» propertyPath | string | true | none | The JSON path to the property which was validated that produced this log. |
»»»»»»» valueBeforeValidation | any | true | none | none |
»»»»»»» valueAfterValidation | any | false | none | none |
»»»»»»» validationResult | any | false | none | none |
anyOf
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»» anonymous | pass-result | false | none | The output from a single Validator. |
»»»»»»»»» outcome | any | true | none | none |
»»»»»»»»» valueOverride | any | false | none | none |
or
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»»» anonymous | fail-result | false | none | The output from a single Validator. |
»»»»»»»»» outcome | any | true | none | none |
»»»»»»»»» errorMessage | string | true | none | none |
»»»»»»»»» fixValue | any | false | none | none |
»»»»»»»»» errorSpans | [error-span] | false | none | none |
continued
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»»»»»» startTime | string(date-time) | false | none | none |
»»»»»»» endTime | string(date-time) | false | none | none |
»»»»» error | string | false | none | The error message from any exception which interrupted the Guard execution process. |
»» inputs | CallInputs | false | none | none |
allOf
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»» anonymous | inputs | false | none | none |
and
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»»» anonymous | args-and-kwargs | false | none | none |
»»»» args | [anyOf] | false | none | none |
»»»»» AnyType | any | false | none | none |
»»»» kwargs | object | false | none | none |
»»»»» additionalProperties | any | false | none | none |
continued
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
»» exception | string | false | none | none |
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
Name | In | Type | Required | Description |
---|---|---|---|---|
guardName | path | string | true | Guard name |
body | body | OpenAIChatCompletionPayload | true | none |
» model | body | string | false | The model to use for the completion |
» messages | body | [object] | false | The messages to use for the completion |
»» role | body | string | false | The role of the message |
»» content | body | string | false | The content of the message |
» max_tokens | body | integer | false | The maximum number of tokens to generate |
» temperature | body | number | false | The sampling temperature |
Example responses
200 Response
{
"id": "string",
"created": "string",
"model_name": "string",
"choices": [
{
"role": "string",
"content": "string"
}
]
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | The output of the completion | OpenAIChatCompletion |
default | Default | Unexpected error | HttpError |
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
Name | In | Type | Required | Description |
---|---|---|---|---|
guardName | path | string | true | Guard name |
x-openai-api-key | header | string(password) | false | A valid OpenAI API Key for calling LLM's on your behalf |
body | body | ValidatePayload | true | none |
» additionalProperties | body | any | false | none |