Skip to content

GuardContentBlock

Defined in: src/types/messages.ts:842

Guard content block for guardrail evaluation. Marks content that should be evaluated by guardrails for safety, grounding, or other policies. Can be used in both message content and system prompts.

new GuardContentBlock(data): GuardContentBlock;

Defined in: src/types/messages.ts:860

| Parameter | Type | | --------- | ---------------------------------------------------- | | data | GuardContentBlockData |

GuardContentBlock

readonly type: "guardContentBlock";

Defined in: src/types/messages.ts:848

Discriminator for guard content.


readonly optional text?: GuardContentText;

Defined in: src/types/messages.ts:853

Text content with evaluation qualifiers.

GuardContentBlockData.text


readonly optional image?: GuardContentImage;

Defined in: src/types/messages.ts:858

Image content with evaluation qualifiers.

GuardContentBlockData.image

toJSON(): {
guardContent: {
text?: {
qualifiers: GuardQualifier[];
text: string;
};
image?: {
format: GuardImageFormat;
source: {
bytes: string;
};
};
};
};

Defined in: src/types/messages.ts:880

Serializes the GuardContentBlock to a JSON-compatible ContentBlockData object. Called automatically by JSON.stringify(). Uint8Array image bytes are encoded as base64 string.

{
guardContent: {
text?: {
qualifiers: GuardQualifier[];
text: string;
};
image?: {
format: GuardImageFormat;
source: {
bytes: string;
};
};
};
}

| Name | Type | Description | Defined in | | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | | guardContent | { text?: { qualifiers: GuardQualifier[]; text: string; }; image?: { format: GuardImageFormat; source: { bytes: string; }; }; } | - | src/types/messages.ts:880 | | guardContent.text? | { qualifiers: GuardQualifier[]; text: string; } | Text content with evaluation qualifiers. | src/types/messages.ts:829 | | guardContent.text.qualifiers | GuardQualifier[] | Qualifiers that specify how this content should be evaluated. | src/types/messages.ts:798 | | guardContent.text.text | string | The text content to be evaluated. | src/types/messages.ts:803 | | guardContent.image? | { format: GuardImageFormat; source: { bytes: string; }; } | Image content with evaluation qualifiers. | src/types/messages.ts:834 | | guardContent.image.format | GuardImageFormat | Image format. | src/types/messages.ts:813 | | guardContent.image.source | { bytes: string; } | Image source (bytes only). | src/types/messages.ts:818 | | guardContent.image.source.bytes | string | - | src/types/messages.ts:789 |

JSONSerializable.toJSON

static fromJSON(data): GuardContentBlock;

Defined in: src/types/messages.ts:901

Creates a GuardContentBlock instance from its wrapped data format. Base64-encoded image bytes are decoded back to Uint8Array.

| Parameter | Type | Description | | -------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | | data | { guardContent: { text?: { qualifiers: GuardQualifier[]; text: string; }; image?: { format: GuardImageFormat; source: { bytes: string | Uint8Array<ArrayBufferLike>; }; }; }; } | Wrapped GuardContentBlockData to deserialize (accepts both string and Uint8Array for image bytes) | | data.guardContent | { text?: { qualifiers: GuardQualifier[]; text: string; }; image?: { format: GuardImageFormat; source: { bytes: string | Uint8Array<ArrayBufferLike>; }; }; } | - | | data.guardContent.text? | { qualifiers: GuardQualifier[]; text: string; } | Text content with evaluation qualifiers. | | data.guardContent.text.qualifiers | GuardQualifier[] | Qualifiers that specify how this content should be evaluated. | | data.guardContent.text.text | string | The text content to be evaluated. | | data.guardContent.image? | { format: GuardImageFormat; source: { bytes: string | Uint8Array<ArrayBufferLike>; }; } | Image content with evaluation qualifiers. | | data.guardContent.image.format | GuardImageFormat | Image format. | | data.guardContent.image.source | { bytes: string | Uint8Array<ArrayBufferLike>; } | Image source (bytes only). | | data.guardContent.image.source.bytes | string | Uint8Array<ArrayBufferLike> | - |

GuardContentBlock

GuardContentBlock instance